diff options
author | Ivan Komissarov <abbapoh@gmail.com> | 2021-11-03 17:16:11 +0300 |
---|---|---|
committer | Ivan Komissarov <abbapoh@gmail.com> | 2021-11-03 17:16:11 +0300 |
commit | addb0dc30b5866743c7574770630b5a0252306d4 (patch) | |
tree | 44df80c4ee10d3506f8d5ed74e1553d3cd5e82df /tests/auto | |
parent | 96d7358c6bd222a70d3a945e6f56a623364a4e2c (diff) | |
parent | ae937f07673aa95b67218e4be36a38e4438c0171 (diff) |
Merge branch '1.21' into master
Change-Id: I27ad0920ab12443c8e2c744e3509bce28607c3f0
Diffstat (limited to 'tests/auto')
19 files changed, 140 insertions, 19 deletions
diff --git a/tests/auto/blackbox/testdata-qt/pkgconfig-qt/dump-libpath.qbs b/tests/auto/blackbox/testdata-qt/pkgconfig-qt/dump-libpath.qbs new file mode 100644 index 000000000..9aa1c5d17 --- /dev/null +++ b/tests/auto/blackbox/testdata-qt/pkgconfig-qt/dump-libpath.qbs @@ -0,0 +1,6 @@ +QtApplication { + files: "main.cpp" + property bool test: { + console.info("libPath="+Qt.core.libPath) + } +} diff --git a/tests/auto/blackbox/testdata-qt/pkgconfig-qt/main.cpp b/tests/auto/blackbox/testdata-qt/pkgconfig-qt/main.cpp new file mode 100644 index 000000000..237c8ce18 --- /dev/null +++ b/tests/auto/blackbox/testdata-qt/pkgconfig-qt/main.cpp @@ -0,0 +1 @@ +int main() {} diff --git a/tests/auto/blackbox/testdata-qt/pkgconfig-qt/module-providers/dummyProvider.qbs b/tests/auto/blackbox/testdata-qt/pkgconfig-qt/module-providers/dummyProvider.qbs new file mode 100644 index 000000000..6ed2ca82e --- /dev/null +++ b/tests/auto/blackbox/testdata-qt/pkgconfig-qt/module-providers/dummyProvider.qbs @@ -0,0 +1,3 @@ +ModuleProvider { + relativeSearchPaths: "" +} diff --git a/tests/auto/blackbox/testdata-qt/pkgconfig-qt/pkgconfig-qt.qbs b/tests/auto/blackbox/testdata-qt/pkgconfig-qt/pkgconfig-qt.qbs new file mode 100644 index 000000000..a1d8d8974 --- /dev/null +++ b/tests/auto/blackbox/testdata-qt/pkgconfig-qt/pkgconfig-qt.qbs @@ -0,0 +1,6 @@ +QtApplication { + name: "p" + files: "main.cpp" + qbsSearchPaths: "." + qbsModuleProviders: "qbspkgconfig" +} diff --git a/tests/auto/blackbox/testdata/conanfile-probe/testapp/conanfile-probe-project.qbs b/tests/auto/blackbox/testdata/conanfile-probe/testapp/conanfile-probe-project.qbs index c1cb1ddda..adcb2bd9c 100644 --- a/tests/auto/blackbox/testdata/conanfile-probe/testapp/conanfile-probe-project.qbs +++ b/tests/auto/blackbox/testdata/conanfile-probe/testapp/conanfile-probe-project.qbs @@ -2,11 +2,12 @@ import qbs.Probes import qbs.TextFile Project { + readonly property bool forceFailure: false Probes.ConanfileProbe { id: conan conanfilePath: path + "/conanfile.py" - options: ({opt: "True"}) + options: ({opt: "True", forceFailure: (project.forceFailure ? "True" : "False")}) settings: ({os: "AIX"}) } diff --git a/tests/auto/blackbox/testdata/conanfile-probe/testapp/conanfile.py b/tests/auto/blackbox/testdata/conanfile-probe/testapp/conanfile.py index 630cf0283..59e40cc80 100644 --- a/tests/auto/blackbox/testdata/conanfile-probe/testapp/conanfile.py +++ b/tests/auto/blackbox/testdata/conanfile-probe/testapp/conanfile.py @@ -7,12 +7,13 @@ class TestApp(ConanFile): version = "6.6.6" settings = "os" - options = {"opt": [True, False]} - default_options = {"opt": False} + options = {"opt": [True, False], "forceFailure": [True, False]} + default_options = {"opt": False, "forceFailure": False} requires = "testlib/1.2.3@qbs/testing" def configure(self): + assert(not self.options.forceFailure) self.options["testlib"].opt = self.options.opt def source(self): diff --git a/tests/auto/blackbox/testdata/grpc/grpc_cpp.qbs b/tests/auto/blackbox/testdata/grpc/grpc_cpp.qbs index 4e46da210..1ecbd0394 100644 --- a/tests/auto/blackbox/testdata/grpc/grpc_cpp.qbs +++ b/tests/auto/blackbox/testdata/grpc/grpc_cpp.qbs @@ -18,6 +18,7 @@ CppApplication { property bool hasDependencies: { console.info("has grpc: " + protobuf.cpp.present); + console.info("has modules: " + grpcpp.present); return protobuf.cpp.present; } diff --git a/tests/auto/blackbox/testdata/protobuf/addressbook_cpp.qbs b/tests/auto/blackbox/testdata/protobuf/addressbook_cpp.qbs index ac97f6bd5..8e8735b69 100644 --- a/tests/auto/blackbox/testdata/protobuf/addressbook_cpp.qbs +++ b/tests/auto/blackbox/testdata/protobuf/addressbook_cpp.qbs @@ -15,6 +15,7 @@ CppApplication { Depends { name: "protobuf.cpp"; required: false } property bool hasProtobuf: { console.info("has protobuf: " + protobuf.cpp.present); + console.info("has modules: " + protobuflib.present); return protobuf.cpp.present; } diff --git a/tests/auto/blackbox/testdata/protobuf/addressbook_nanopb.qbs b/tests/auto/blackbox/testdata/protobuf/addressbook_nanopb.qbs index 92243d31f..61a44fc0f 100644 --- a/tests/auto/blackbox/testdata/protobuf/addressbook_nanopb.qbs +++ b/tests/auto/blackbox/testdata/protobuf/addressbook_nanopb.qbs @@ -15,6 +15,7 @@ CppApplication { Depends { name: "protobuf.nanopb"; required: false } property bool hasProtobuf: { console.info("has protobuf: " + protobuf.nanopb.present); + console.info("has modules: false"); return protobuf.nanopb.present; } protobuf.nanopb.importPaths: product.sourceDirectory diff --git a/tests/auto/blackbox/testdata/protobuf/addressbook_objc.qbs b/tests/auto/blackbox/testdata/protobuf/addressbook_objc.qbs index 448a9284a..95b03d7d7 100644 --- a/tests/auto/blackbox/testdata/protobuf/addressbook_objc.qbs +++ b/tests/auto/blackbox/testdata/protobuf/addressbook_objc.qbs @@ -12,6 +12,7 @@ CppApplication { Depends { name: "protobuf.objc"; required: false } property bool hasProtobuf: { console.info("has protobuf: " + protobuf.objc.present); + console.info("has modules: false"); return protobuf.objc.present; } diff --git a/tests/auto/blackbox/testdata/protobuf/create-proto-library.qbs b/tests/auto/blackbox/testdata/protobuf/create-proto-library.qbs index d888937f1..9938fcdd4 100644 --- a/tests/auto/blackbox/testdata/protobuf/create-proto-library.qbs +++ b/tests/auto/blackbox/testdata/protobuf/create-proto-library.qbs @@ -17,6 +17,7 @@ Project { Depends { name: "protobuf.cpp"; required: false } property bool hasProtobuf: { console.info("has protobuf: " + protobuf.cpp.present); + console.info("has modules: " + protobuflib.present); return protobuf.cpp.present; } diff --git a/tests/auto/blackbox/testdata/protobuf/import.qbs b/tests/auto/blackbox/testdata/protobuf/import.qbs index 4d7e1b5c9..d7ae5e1a2 100644 --- a/tests/auto/blackbox/testdata/protobuf/import.qbs +++ b/tests/auto/blackbox/testdata/protobuf/import.qbs @@ -16,6 +16,7 @@ CppApplication { Depends { name: "protobuf.cpp"; required: false } property bool hasProtobuf: { console.info("has protobuf: " + protobuf.cpp.present); + console.info("has modules: " + protobuflib.present); return protobuf.cpp.present; } diff --git a/tests/auto/blackbox/testdata/protobuf/needs-import-dir.qbs b/tests/auto/blackbox/testdata/protobuf/needs-import-dir.qbs index 4914ea484..80a9d9a88 100644 --- a/tests/auto/blackbox/testdata/protobuf/needs-import-dir.qbs +++ b/tests/auto/blackbox/testdata/protobuf/needs-import-dir.qbs @@ -17,6 +17,7 @@ CppApplication { Depends { name: "protobuf.cpp"; required: false } property bool hasProtobuf: { console.info("has protobuf: " + protobuf.cpp.present); + console.info("has modules: " + protobuflib.present); return protobuf.cpp.present; } diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index debcc6f30..b37b1e81e 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -1867,8 +1867,18 @@ void TestBlackbox::cxxLanguageVersion_data() std::make_pair(QString("msvc-new"), QString("/std:"))}); } +void TestBlackbox::conanfileProbe_data() +{ + QTest::addColumn<bool>("forceFailure"); + + QTest::newRow("success") << false; + QTest::newRow("failure") << true; +} + void TestBlackbox::conanfileProbe() { + QFETCH(bool, forceFailure); + QString executable = findExecutable({"conan"}); if (executable.isEmpty()) QSKIP("conan is not installed or not available in PATH."); @@ -1883,7 +1893,10 @@ void TestBlackbox::conanfileProbe() QVERIFY(waitForProcessSuccess(conan)); QDir::setCurrent(testDataDir + "/conanfile-probe/testapp"); - QCOMPARE(runQbs(QbsRunParameters("resolve", {"--force-probe-execution"})), 0); + QCOMPARE(runQbs(QbsRunParameters("resolve", + {"--force-probe-execution", + QStringLiteral("projects.conanfile-probe-project.forceFailure:") + + (forceFailure ? "true" : "false")})), forceFailure ? 1 : 0); QFile file(relativeBuildDir() + "/results.json"); QVERIFY(file.open(QIODevice::ReadOnly)); @@ -5790,18 +5803,24 @@ void TestBlackbox::protobuf_data() { QTest::addColumn<QString>("projectFile"); QTest::addColumn<QStringList>("properties"); + QTest::addColumn<bool>("hasModules"); QTest::addColumn<bool>("successExpected"); - QTest::newRow("cpp") << QString("addressbook_cpp.qbs") << QStringList() << true; - QTest::newRow("objc") << QString("addressbook_objc.qbs") << QStringList() << true; - QTest::newRow("nanopb") << QString("addressbook_nanopb.qbs") << QStringList() << true; - QTest::newRow("import") << QString("import.qbs") << QStringList() << true; + QTest::newRow("cpp") << QString("addressbook_cpp.qbs") << QStringList() << false << true; + QTest::newRow("cpp-pkgconfig") + << QString("addressbook_cpp.qbs") + << QStringList("project.qbsModuleProviders:qbspkgconfig") + << true + << true; + QTest::newRow("objc") << QString("addressbook_objc.qbs") << QStringList() << false << true; + QTest::newRow("nanopb") << QString("addressbook_nanopb.qbs") << QStringList() << false << true; + QTest::newRow("import") << QString("import.qbs") << QStringList() << false << true; QTest::newRow("missing import dir") << QString("needs-import-dir.qbs") - << QStringList() << false; + << QStringList() << false << false; QTest::newRow("provided import dir") << QString("needs-import-dir.qbs") - << QStringList("products.app.theImportDir:subdir") << true; + << QStringList("products.app.theImportDir:subdir") << false << true; QTest::newRow("create proto library") - << QString("create-proto-library.qbs") << QStringList() << true; + << QString("create-proto-library.qbs") << QStringList() << false << true; } void TestBlackbox::protobuf() @@ -5809,6 +5828,7 @@ void TestBlackbox::protobuf() QDir::setCurrent(testDataDir + "/protobuf"); QFETCH(QString, projectFile); QFETCH(QStringList, properties); + QFETCH(bool, hasModules); QFETCH(bool, successExpected); rmDirR(relativeBuildDir()); QbsRunParameters resolveParams("resolve", QStringList{"-f", projectFile} << properties); @@ -5820,6 +5840,10 @@ void TestBlackbox::protobuf() QVERIFY2(withProtobuf || withoutProtobuf, m_qbsStdout.constData()); if (withoutProtobuf) QSKIP("protobuf module not present"); + const bool hasMods = m_qbsStdout.contains("has modules: true"); + const bool dontHaveMods = m_qbsStdout.contains("has modules: false"); + QVERIFY2(hasMods == !dontHaveMods, m_qbsStdout.constData()); + QCOMPARE(hasMods, hasModules); QbsRunParameters runParams("run"); runParams.expectFailure = !successExpected; QCOMPARE(runQbs(runParams) == 0, successExpected); @@ -8342,21 +8366,42 @@ void TestBlackbox::groupsInModules() void TestBlackbox::grpc_data() { QTest::addColumn<QString>("projectFile"); - QTest::newRow("cpp") << QString("grpc_cpp.qbs"); + QTest::addColumn<QStringList>("arguments"); + QTest::addColumn<bool>("hasModules"); + + QTest::newRow("cpp") << QString("grpc_cpp.qbs") << QStringList() << false; + + QStringList pkgConfigArgs("project.qbsModuleProviders:qbspkgconfig"); + // on macOS, openSSL is hidden from pkg-config by default + if (qbs::Internal::HostOsInfo::isMacosHost()) { + pkgConfigArgs + << "moduleProviders.qbspkgconfig.extraPaths:/usr/local/opt/openssl@1.1/lib/pkgconfig"; + } + QTest::newRow("cpp-pkgconfig") << QString("grpc_cpp.qbs") << pkgConfigArgs << true; } void TestBlackbox::grpc() { QDir::setCurrent(testDataDir + "/grpc"); QFETCH(QString, projectFile); + QFETCH(QStringList, arguments); + QFETCH(bool, hasModules); + rmDirR(relativeBuildDir()); QbsRunParameters resolveParams("resolve", QStringList{"-f", projectFile}); + resolveParams.arguments << arguments; QCOMPARE(runQbs(resolveParams), 0); const bool withGrpc = m_qbsStdout.contains("has grpc: true"); const bool withoutGrpc = m_qbsStdout.contains("has grpc: false"); QVERIFY2(withGrpc || withoutGrpc, m_qbsStdout.constData()); if (withoutGrpc) QSKIP("grpc module not present"); + + const bool hasMods = m_qbsStdout.contains("has modules: true"); + const bool dontHaveMods = m_qbsStdout.contains("has modules: false"); + QVERIFY2(hasMods == !dontHaveMods, m_qbsStdout.constData()); + QCOMPARE(hasMods, hasModules); + if (m_qbsStdout.contains("targetPlatform differs from hostPlatform")) QSKIP("Cannot run binaries in cross-compiled build"); diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index 2f443f681..987c87d6a 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -89,6 +89,7 @@ private slots: void conflictingArtifacts(); void cxxLanguageVersion(); void cxxLanguageVersion_data(); + void conanfileProbe_data(); void conanfileProbe(); void cpuFeatures(); void dependenciesProperty(); diff --git a/tests/auto/blackbox/tst_blackboxqt.cpp b/tests/auto/blackbox/tst_blackboxqt.cpp index 53fadc490..1702d4ad6 100644 --- a/tests/auto/blackbox/tst_blackboxqt.cpp +++ b/tests/auto/blackbox/tst_blackboxqt.cpp @@ -298,6 +298,49 @@ void TestBlackboxQt::pkgconfig() QSKIP("pkgconfig or Qt not found"); } +void TestBlackboxQt::pkgconfigQt() +{ + QFETCH(QStringList, arguments); + QFETCH(bool, success); + + QDir::setCurrent(testDataDir + "/pkgconfig-qt"); + rmDirR(relativeBuildDir()); + + QbsRunParameters dumpParams("resolve", {"-f", "dump-libpath.qbs"}); + QCOMPARE(runQbs(dumpParams), 0); + auto lines = QString::fromUtf8(m_qbsStdout).split('\n'); + const QString needle = "libPath="; + qbs::Internal::removeIf( + lines, [&needle](const auto &line) { return !line.startsWith(needle); }); + QCOMPARE(lines.size(), 1); + const auto libPath = lines[0].mid(needle.size()); + const auto prefix = QFileInfo(libPath).path(); + const auto pkgConfigPath = libPath + "/pkgconfig/"; + if (!QFileInfo(pkgConfigPath).exists()) + QSKIP("No *.pc files found"); + + rmDirR(relativeBuildDir()); + QbsRunParameters params("build", {"-f", "pkgconfig-qt.qbs"}); + // need to override prefix for the downloaded Qt + params.environment.insert("PKG_CONFIG_QT5CORE_PREFIX", prefix); + params.arguments << "moduleProviders.qbspkgconfig.extraPaths:" + pkgConfigPath; + params.arguments << arguments; + + QCOMPARE(runQbs(params) == 0, success); + + if (!success) + QVERIFY(m_qbsStderr.contains("Dependency 'Qt.core' not found for product 'p'")); +} + +void TestBlackboxQt::pkgconfigQt_data() +{ + QTest::addColumn<QStringList>("arguments"); + QTest::addColumn<bool>("success"); + QTest::newRow("pkgconfig") << QStringList() << true; + QTest::newRow("dummy") + << QStringList({"products.p.qbsModuleProviders:dummyProvider"}) << false; +} + void TestBlackboxQt::pluginMetaData() { QDir::setCurrent(testDataDir + "/plugin-meta-data"); diff --git a/tests/auto/blackbox/tst_blackboxqt.h b/tests/auto/blackbox/tst_blackboxqt.h index 820df26d9..dfc024a3e 100644 --- a/tests/auto/blackbox/tst_blackboxqt.h +++ b/tests/auto/blackbox/tst_blackboxqt.h @@ -58,6 +58,8 @@ private slots: void mocCompilerDefines(); void mocSameFileName(); void pkgconfig(); + void pkgconfigQt(); + void pkgconfigQt_data(); void pluginMetaData(); void pluginSupport_data(); void pluginSupport(); diff --git a/tests/auto/pkgconfig/tst_pkgconfig.cpp b/tests/auto/pkgconfig/tst_pkgconfig.cpp index 542984378..ec62e1a7f 100644 --- a/tests/auto/pkgconfig/tst_pkgconfig.cpp +++ b/tests/auto/pkgconfig/tst_pkgconfig.cpp @@ -90,12 +90,13 @@ void TestPkgConfig::pkgConfig() QCOMPARE(QString::fromStdString(package.description), json.value("Description").toString()); QCOMPARE(QString::fromStdString(package.version), json.value("Version").toString()); - auto vars = json["Vars"].toMap(); - vars["pcfiledir"] = QFileInfo(m_workingDataDir).absoluteFilePath(); + auto variables = json["Vars"].toMap(); + variables["pcfiledir"] = QFileInfo(m_workingDataDir).absoluteFilePath(); - for (const auto &[key, value]: package.vars) { + QCOMPARE(size_t(variables.size()), package.variables.size()); + for (const auto &[key, value]: package.variables) { QCOMPARE(QString::fromStdString(value), - vars.value(QString::fromStdString(key)).toString()); + variables.value(QString::fromStdString(key)).toString()); } const auto jsonLibs = json.value("Libs").toJsonArray().toVariantList(); @@ -191,6 +192,10 @@ void TestPkgConfig::pkgConfig_data() << QStringLiteral("tilde") << QString() << QVariantMap(); QTest::newRow("variables") << QStringLiteral("variables") << QString() << QVariantMap(); + QTest::newRow("variables-merged") + << QStringLiteral("variables") + << QString() + << QVariantMap({{"mergeDependencies", true}}); QTest::newRow("whitespace") << QStringLiteral("whitespace") << QString() << QVariantMap(); QTest::newRow("base.name") diff --git a/tests/auto/tools/tst_tools.cpp b/tests/auto/tools/tst_tools.cpp index 894cfdcf6..a872bdd0d 100644 --- a/tests/auto/tools/tst_tools.cpp +++ b/tests/auto/tools/tst_tools.cpp @@ -308,10 +308,10 @@ void TestTools::testSettingsMigration() QFETCH(bool, hasOldSettings); Settings settings(baseDir); if (hasOldSettings) { - QVERIFY(QFileInfo(settings.baseDirectory() + "/qbs/" QBS_VERSION "/profiles/right.txt") + // checks that we do not copy old "profiles/" dir anymore + QVERIFY(!QFileInfo(settings.baseDirectory() + "/qbs/" QBS_VERSION "/profiles/right.txt") .exists()); - QCOMPARE(settings.value("key", Settings::UserScope).toString(), - settings.baseDirectory() + "/qbs/" QBS_VERSION "/profilesright"); + QVERIFY(!settings.value("key", Settings::UserScope).toString().isEmpty()); } else { QVERIFY(!QFileInfo(settings.baseDirectory() + "/qbs/" QBS_VERSION "/profiles").exists()); QVERIFY(settings.allKeys(Settings::UserScope).empty()); |