aboutsummaryrefslogtreecommitdiffstats
path: root/tests
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
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')
-rw-r--r--tests/auto/api/tst_api.cpp10
-rw-r--r--tests/auto/shared.h22
2 files changed, 24 insertions, 8 deletions
diff --git a/tests/auto/api/tst_api.cpp b/tests/auto/api/tst_api.cpp
index 0786a6e8a..4c747929d 100644
--- a/tests/auto/api/tst_api.cpp
+++ b/tests/auto/api/tst_api.cpp
@@ -1051,16 +1051,18 @@ void TestApi::multiArch()
QScopedPointer<qbs::BuildJob> buildJob(project.buildAllProducts(qbs::BuildOptions()));
waitForFinished(buildJob.data());
QVERIFY2(!buildJob->error().hasError(), qPrintable(buildJob->error().toString()));
- const QString outputBaseDir(setupParams.buildRoot() + "/qbs_autotests-debug");
- QFile p1HostArtifact(outputBaseDir + "/p1.host/host+target.output");
+ const QString outputBaseDir = setupParams.buildRoot() + '/';
+ QFile p1HostArtifact(outputBaseDir
+ + relativeProductBuildDir("p1", "host") + "/host+target.output");
QVERIFY2(p1HostArtifact.exists(), qPrintable(p1HostArtifact.fileName()));
QVERIFY2(p1HostArtifact.open(QIODevice::ReadOnly), qPrintable(p1HostArtifact.errorString()));
QCOMPARE(p1HostArtifact.readAll().constData(), "host-arch");
- QFile p1TargetArtifact(outputBaseDir + "/p1.target/host+target.output");
+ QFile p1TargetArtifact(outputBaseDir + relativeProductBuildDir("p1", "target")
+ + "/host+target.output");
QVERIFY2(p1TargetArtifact.exists(), qPrintable(p1TargetArtifact.fileName()));
QVERIFY2(p1TargetArtifact.open(QIODevice::ReadOnly), qPrintable(p1TargetArtifact.errorString()));
QCOMPARE(p1TargetArtifact.readAll().constData(), "target-arch");
- QFile p2Artifact(outputBaseDir + "/p2.host/host-tool.output");
+ QFile p2Artifact(outputBaseDir + relativeProductBuildDir("p2", "host") + "/host-tool.output");
QVERIFY2(p2Artifact.exists(), qPrintable(p2Artifact.fileName()));
QVERIFY2(p2Artifact.open(QIODevice::ReadOnly), qPrintable(p2Artifact.errorString()));
QCOMPARE(p2Artifact.readAll().constData(), "host-arch");
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)