aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/shared.h
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2014-08-14 16:35:26 +0200
committerChristian Kandeler <christian.kandeler@digia.com>2014-08-20 17:12:35 +0200
commit3957eac2205256ebe7784d2bc95fc4913c52801e (patch)
tree651350b27c92fac9d8f5cec0361501f35e896b4b /tests/auto/shared.h
parentaf0e67f574ba294915881cf64b0d3ba64fc10d45 (diff)
Use modified product names for build directories.
Users should be able to use any product name they want. In particular, they should not be limited by what the file system supports; this is why we have the "targetName" property. However, we currently subvert this by using the product name as-is in the build directory. Instead, we now use a super-safe version of the product name consisting only of selected ASCII characters and make it unique by appending a hash of the original name. Change-Id: I3acf06d83a1c8a8c0a4716a7ac47a5bf8652075d Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'tests/auto/shared.h')
-rw-r--r--tests/auto/shared.h22
1 files changed, 18 insertions, 4 deletions
diff --git a/tests/auto/shared.h b/tests/auto/shared.h
index 7ec6ed5ea..01621d772 100644
--- a/tests/auto/shared.h
+++ b/tests/auto/shared.h
@@ -31,6 +31,7 @@
#include <tools/hostosinfo.h>
+#include <QCryptographicHash>
#include <QFile>
#include <QFileInfo>
#include <QtTest>
@@ -56,14 +57,27 @@ inline bool regularFileExists(const QString &filePath)
return fi.exists() && fi.isFile();
}
-inline QString uniqueProductName(const QString &productName)
+inline QString uniqueProductName(const QString &productName, const QString &_profileName)
{
- return productName + '.' + profileName();
+ const QString p = _profileName.isEmpty() ? profileName() : _profileName;
+ return productName + '.' + p;
}
-inline QString relativeProductBuildDir(const QString &productName)
+inline QString relativeProductBuildDir(const QString &productName,
+ const QString &profileName = QString())
{
- return relativeBuildDir() + '/' + uniqueProductName(productName);
+ const QString fullName = uniqueProductName(productName, profileName);
+ QString dirName = fullName;
+ for (int i = 0; i < dirName.count(); ++i) {
+ QCharRef c = dirName[i];
+ const bool okChar = (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z')
+ || (c >= 'a' && c <= 'z') || c == '_' || c == '.';
+ if (!okChar)
+ c = QChar::fromLatin1('_');
+ }
+ const QByteArray hash = QCryptographicHash::hash(fullName.toUtf8(), QCryptographicHash::Sha1);
+ dirName.append('.').append(hash.toHex().left(8));
+ return relativeBuildDir() + '/' + dirName;
}
inline QString relativeExecutableFilePath(const QString &productName)