summaryrefslogtreecommitdiff
path: root/tests/auto/shared.h
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2017-05-10 11:53:36 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2017-05-10 13:53:59 +0000
commit7c163caf130d221345e367f7596ad49526eed7e9 (patch)
tree51ea0f551106d1668bb7fc6ec0b5b170bba6a2a8 /tests/auto/shared.h
parent37974243d4215f1e76994175ebc1988292ccc45a (diff)
downloadqbs-7c163caf130d221345e367f7596ad49526eed7e9.tar.gz
Support providing a settings directory to the autotests
This allows us to run several instances of an autotest in parallel for the same qbs version. Change-Id: I17652ffeba01679800f30fe73d033f7f10e2ded5 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'tests/auto/shared.h')
-rw-r--r--tests/auto/shared.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/auto/shared.h b/tests/auto/shared.h
index 777239c26..38183f152 100644
--- a/tests/auto/shared.h
+++ b/tests/auto/shared.h
@@ -37,10 +37,20 @@
#include <QtCore/qdir.h>
#include <QtCore/qfile.h>
#include <QtCore/qfileinfo.h>
+#include <QtCore/qstring.h>
#include <QtCore/qtemporaryfile.h>
#include <QtTest/qtest.h>
+#include <memory>
+
+using SettingsPtr = std::unique_ptr<qbs::Settings>;
+inline SettingsPtr settings()
+{
+ const QString settingsDir = QLatin1String(qgetenv("QBS_AUTOTEST_SETTINGS_DIR"));
+ return SettingsPtr(new qbs::Settings(settingsDir));
+}
+
inline QString profileName() { return QLatin1String("qbs_autotests"); }
inline QString relativeBuildDir(const QString &configurationName = QString())
{
@@ -127,8 +137,8 @@ inline void copyFileAndUpdateTimestamp(const QString &source, const QString &tar
inline QString objectFileName(const QString &baseName, const QString &profileName)
{
- qbs::Settings settings((QString()));
- qbs::Profile profile(profileName, &settings);
+ const SettingsPtr s = settings();
+ qbs::Profile profile(profileName, s.get());
const QString suffix = profile.value("qbs.toolchain").toStringList().contains("msvc")
? "obj" : "o";
return baseName + '.' + suffix;
@@ -153,8 +163,8 @@ inline QString testWorkDir(const QString &testName)
inline qbs::Internal::HostOsInfo::HostOs targetOs()
{
- qbs::Settings settings((QString()));
- const qbs::Profile buildProfile(profileName(), &settings);
+ const SettingsPtr s = settings();
+ const qbs::Profile buildProfile(profileName(), s.get());
const QStringList targetOS = buildProfile.value("qbs.targetOS").toStringList();
if (targetOS.contains("windows"))
return qbs::Internal::HostOsInfo::HostOsWindows;