diff options
author | Christian Kandeler <christian.kandeler@digia.com> | 2014-02-21 11:36:02 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@digia.com> | 2014-02-21 12:04:25 +0100 |
commit | bab99ac39ad9de7f1c244006ccfd49852941ac26 (patch) | |
tree | ebc89a823692e632cf775d1b01edb4ff307e851a /tests | |
parent | ee7eb1f45529a16a4337c33fac82b205406ca1a0 (diff) |
Allow the user to specify a custom place for settings.
Task-number: QBS-509
Change-Id: I4ad32c648121068880d652e3ba39d4eea59dfbc3
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/api/tst_api.cpp | 2 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.cpp | 8 | ||||
-rw-r--r-- | tests/auto/cmdlineparser/tst_cmdlineparser.cpp | 61 | ||||
-rw-r--r-- | tests/auto/tools/tst_tools.cpp | 2 |
4 files changed, 32 insertions, 41 deletions
diff --git a/tests/auto/api/tst_api.cpp b/tests/auto/api/tst_api.cpp index 764ebdc5a..5f55259e1 100644 --- a/tests/auto/api/tst_api.cpp +++ b/tests/auto/api/tst_api.cpp @@ -503,7 +503,7 @@ qbs::SetupProjectParameters TestApi::defaultSetupParameters() const const QString qbsRootPath = QDir::cleanPath(QCoreApplication::applicationDirPath() + QLatin1String("/../")); - SettingsPtr settings = qbsSettings(); + SettingsPtr settings = qbsSettings(QString()); const QString profileName = QLatin1String("qbs_autotests"); const qbs::Preferences prefs(settings.data(), profileName); setupParams.setSearchPaths(prefs.searchPaths(qbsRootPath)); diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index b4364cddc..5b63eed65 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -178,7 +178,7 @@ void TestBlackbox::initTestCase() { QVERIFY(QFile::exists(qbsExecutableFilePath)); - SettingsPtr settings = qbsSettings(); + SettingsPtr settings = qbsSettings(QString()); if (!settings->profiles().contains(buildProfileName)) QFAIL(QByteArray("The build profile '" + buildProfileName.toLocal8Bit() + "' could not be found. Please set it up on your machine.")); @@ -1787,7 +1787,7 @@ private: void TestBlackbox::missingProfile() { - SettingsPtr settings = qbsSettings(); + SettingsPtr settings = qbsSettings(QString()); TemporaryDefaultProfileRemover dpr(settings); QVERIFY(settings->defaultProfile().isEmpty()); QDir::setCurrent(testDataDir + "/project_filepath_check"); @@ -1801,7 +1801,7 @@ void TestBlackbox::missingProfile() void TestBlackbox::testAssembly() { - SettingsPtr settings = qbsSettings(); + SettingsPtr settings = qbsSettings(QString()); Profile profile(buildProfileName, settings.data()); bool haveGcc = profile.value("qbs.toolchain").toStringList().contains("gcc"); QDir::setCurrent(testDataDir + "/assembly"); @@ -1844,7 +1844,7 @@ void TestBlackbox::testNsis() return; } - SettingsPtr settings = qbsSettings(); + SettingsPtr settings = qbsSettings(QString()); Profile profile(buildProfileName, settings.data()); bool targetIsWindows = profile.value("qbs.targetOS").toStringList().contains("windows"); QDir::setCurrent(testDataDir + "/nsis"); diff --git a/tests/auto/cmdlineparser/tst_cmdlineparser.cpp b/tests/auto/cmdlineparser/tst_cmdlineparser.cpp index 63287ce23..5aaa2fdbf 100644 --- a/tests/auto/cmdlineparser/tst_cmdlineparser.cpp +++ b/tests/auto/cmdlineparser/tst_cmdlineparser.cpp @@ -29,7 +29,6 @@ #include <app/qbs/parser/commandlineparser.h> #include <app/shared/logging/consolelogger.h> -#include <app/shared/qbssettings.h> #include <tools/buildoptions.h> #include <tools/error.h> #include <tools/fileinfo.h> @@ -41,8 +40,6 @@ using namespace qbs; -static SettingsPtr settings = qbsSettings(); - class TestCmdLineParser : public QObject { Q_OBJECT @@ -67,7 +64,7 @@ private slots: args << "--check-timestamps"; CommandLineParser parser; - QVERIFY(parser.parseCommandLine(args, settings.data())); + QVERIFY(parser.parseCommandLine(args)); QCOMPARE(ConsoleLogger::instance().logSink()->logLevel(), LoggerTrace); QCOMPARE(parser.command(), BuildCommandType); QCOMPARE(parser.products(), QStringList() << "blubb"); @@ -78,46 +75,44 @@ private slots: QVERIFY(!parser.logTime()); QCOMPARE(parser.buildConfigurations().count(), 1); - QVERIFY(parser.parseCommandLine(QStringList() << "-vvvqqq" << fileArgs, settings.data())); + QVERIFY(parser.parseCommandLine(QStringList() << "-vvvqqq" << fileArgs)); QCOMPARE(ConsoleLogger::instance().logSink()->logLevel(), defaultLogLevel()); QVERIFY(!parser.force()); - QVERIFY(parser.parseCommandLine(QStringList() << "-t" << fileArgs, settings.data())); + QVERIFY(parser.parseCommandLine(QStringList() << "-t" << fileArgs)); QVERIFY(parser.logTime()); if (!Internal::HostOsInfo::isWindowsHost()) { // Windows has no progress bar atm. // Note: We cannot just check for !parser.logTime() here, because if the test is not // run in a terminal, "--show-progress" is ignored, in which case "--log-time" // takes effect. - QVERIFY(parser.parseCommandLine(QStringList() << "-t" << "--show-progress" << fileArgs, - settings.data())); + QVERIFY(parser.parseCommandLine(QStringList() << "-t" << "--show-progress" + << fileArgs)); QVERIFY(parser.showProgress() != parser.logTime()); } - QVERIFY(parser.parseCommandLine(QStringList() << "-vvqqq" << fileArgs, settings.data())); + QVERIFY(parser.parseCommandLine(QStringList() << "-vvqqq" << fileArgs)); QCOMPARE(ConsoleLogger::instance().logSink()->logLevel(), LoggerWarning); - QVERIFY(parser.parseCommandLine(QStringList() << "-vvvqq" << fileArgs, settings.data())); + QVERIFY(parser.parseCommandLine(QStringList() << "-vvvqq" << fileArgs)); QCOMPARE(ConsoleLogger::instance().logSink()->logLevel(), LoggerDebug); - QVERIFY(parser.parseCommandLine(QStringList() << "--log-level" << "trace" << fileArgs, - settings.data())); + QVERIFY(parser.parseCommandLine(QStringList() << "--log-level" << "trace" << fileArgs)); QCOMPARE(ConsoleLogger::instance().logSink()->logLevel(), LoggerTrace); // Second "global" profile overwrites first. - QVERIFY(parser.parseCommandLine(QStringList(fileArgs) << "profile:a" << "profile:b", - settings.data())); + QVERIFY(parser.parseCommandLine(QStringList(fileArgs) << "profile:a" << "profile:b")); QCOMPARE(parser.buildConfigurations().count(), 1); QCOMPARE(parser.buildConfigurations().first().value("qbs.profile").toString(), QLatin1String("b")); // Second build variant-specific profile overwrites first. QVERIFY(parser.parseCommandLine(QStringList(fileArgs) << "debug" << "profile:a" - << "profile:b", settings.data())); + << "profile:b")); QCOMPARE(parser.buildConfigurations().count(), 1); QCOMPARE(parser.buildConfigurations().first().value("qbs.profile").toString(), QLatin1String("b")); QVERIFY(parser.parseCommandLine(QStringList(fileArgs) << "debug" << "profile:a" - << "debug" << "profile:b", settings.data())); + << "debug" << "profile:b")); QCOMPARE(parser.buildConfigurations().count(), 2); QCOMPARE(parser.buildConfigurations().first().value("qbs.buildVariant").toString(), QLatin1String("debug")); QCOMPARE(parser.buildConfigurations().first().value("qbs.profile").toString(), QLatin1String("a")); @@ -126,11 +121,11 @@ private slots: // Redundant build request QVERIFY(parser.parseCommandLine(QStringList(fileArgs) << "debug" << "profile:a" - << "debug" << "profile:a", settings.data())); + << "debug" << "profile:a")); QCOMPARE(parser.buildConfigurations().count(), 1); QVERIFY(parser.parseCommandLine(QStringList(fileArgs) << "debug" << "profile:a" - << "release" << "profile:b", settings.data())); + << "release" << "profile:b")); QCOMPARE(parser.buildConfigurations().count(), 2); QCOMPARE(parser.buildConfigurations().first().value("qbs.buildVariant").toString(), QLatin1String("debug")); QCOMPARE(parser.buildConfigurations().first().value("qbs.profile").toString(), QLatin1String("a")); @@ -139,7 +134,7 @@ private slots: // Non-global property takes precedence. QVERIFY(parser.parseCommandLine(QStringList(fileArgs) << "profile:a" << "debug" - << "profile:b", settings.data())); + << "profile:b")); QCOMPARE(parser.buildConfigurations().count(), 1); QCOMPARE(parser.buildConfigurations().first().value("qbs.buildVariant").toString(), QLatin1String("debug")); QCOMPARE(parser.buildConfigurations().first().value("qbs.profile").toString(), QLatin1String("b")); @@ -151,18 +146,14 @@ private slots: QVERIFY(projectFile.open()); const QStringList fileArgs = QStringList() << "-f" << projectFile.fileName(); CommandLineParser parser; - QVERIFY(!parser.parseCommandLine(QStringList() << fileArgs << "-x", settings.data())); // Unknown short option. - QVERIFY(!parser.parseCommandLine(QStringList() << fileArgs << "--xyz", settings.data())); // Unknown long option. - QVERIFY(!parser.parseCommandLine(QStringList() << fileArgs << "-vjv", settings.data())); // Invalid position. - QVERIFY(!parser.parseCommandLine(QStringList() << fileArgs << "-j", settings.data())); // Missing argument. - QVERIFY(!parser.parseCommandLine(QStringList() << "-j" << "0" << fileArgs, - settings.data())); // Wrong argument. - QVERIFY(!parser.parseCommandLine(QStringList() << fileArgs << "--products", - settings.data())); // Missing argument. - QVERIFY(!parser.parseCommandLine(QStringList() << "--changed-files" << "," << fileArgs, - settings.data())); // Wrong argument. - QVERIFY(!parser.parseCommandLine(QStringList() << "--log-level" << "blubb" << fileArgs, - settings.data())); // Wrong argument. + QVERIFY(!parser.parseCommandLine(QStringList() << fileArgs << "-x")); // Unknown short option. + QVERIFY(!parser.parseCommandLine(QStringList() << fileArgs << "--xyz")); // Unknown long option. + QVERIFY(!parser.parseCommandLine(QStringList() << fileArgs << "-vjv")); // Invalid position. + QVERIFY(!parser.parseCommandLine(QStringList() << fileArgs << "-j")); // Missing argument. + QVERIFY(!parser.parseCommandLine(QStringList() << "-j" << "0" << fileArgs)); // Wrong argument. + QVERIFY(!parser.parseCommandLine(QStringList() << fileArgs << "--products")); // Missing argument. + QVERIFY(!parser.parseCommandLine(QStringList() << "--changed-files" << "," << fileArgs)); // Wrong argument. + QVERIFY(!parser.parseCommandLine(QStringList() << "--log-level" << "blubb" << fileArgs)); // Wrong argument. } void testProjectFileLookup() @@ -176,13 +167,13 @@ private slots: CommandLineParser parser; const QStringList args(QLatin1String("-f")); QString projectFilePath = multiProjectsDir + QLatin1String("/project.qbs"); - QVERIFY(parser.parseCommandLine(args + QStringList(projectFilePath), settings.data())); + QVERIFY(parser.parseCommandLine(args + QStringList(projectFilePath))); QCOMPARE(projectFilePath, parser.projectFilePath()); projectFilePath = oneProjectDir + QLatin1String("/project.qbs"); - QVERIFY(parser.parseCommandLine(args + QStringList(oneProjectDir), settings.data())); + QVERIFY(parser.parseCommandLine(args + QStringList(oneProjectDir))); QCOMPARE(projectFilePath, parser.projectFilePath()); - QVERIFY(!parser.parseCommandLine(args + QStringList(noProjectsDir), settings.data())); - QVERIFY(!parser.parseCommandLine(args + QStringList(multiProjectsDir), settings.data())); + QVERIFY(!parser.parseCommandLine(args + QStringList(noProjectsDir))); + QVERIFY(!parser.parseCommandLine(args + QStringList(multiProjectsDir))); } }; diff --git a/tests/auto/tools/tst_tools.cpp b/tests/auto/tools/tst_tools.cpp index 90c9a71d8..7a1f8fd77 100644 --- a/tests/auto/tools/tst_tools.cpp +++ b/tests/auto/tools/tst_tools.cpp @@ -36,7 +36,7 @@ int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); - SettingsPtr settings = qbsSettings(); + SettingsPtr settings = qbsSettings(QString()); qbs::Internal::TestTools tt(settings.data()); return QTest::qExec(&tt, argc, argv); } |