diff options
author | Ivan Komissarov <abbapoh@gmail.com> | 2023-08-17 17:46:53 +1100 |
---|---|---|
committer | Ivan Komissarov <ABBAPOH@gmail.com> | 2023-08-21 11:14:41 +0000 |
commit | 6b109ab5da543d1ee7a23a582c0de5238b64437d (patch) | |
tree | 2166583c0720068b9b458319dcaab27188b90ee2 | |
parent | 7cbb842efb4a7cab534aabc5c23a5aa925d5fab6 (diff) |
apple: fix tests with xcode-less profile
Change-Id: Ib606da3047c078afc0bbc44fa62cb1c111e15755
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r-- | tests/auto/blackbox/find/find-xcode.qbs | 4 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackboxapple.cpp | 36 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackboxapple.h | 6 |
3 files changed, 37 insertions, 9 deletions
diff --git a/tests/auto/blackbox/find/find-xcode.qbs b/tests/auto/blackbox/find/find-xcode.qbs index bb6ee9718..15c2aa17e 100644 --- a/tests/auto/blackbox/find/find-xcode.qbs +++ b/tests/auto/blackbox/find/find-xcode.qbs @@ -14,7 +14,9 @@ Product { cmd.description = output.filePath; cmd.sourceCode = function() { var tools = {}; - if (product.moduleProperty("xcode", "present")) { + var present = product.moduleProperty("xcode", "present"); + tools["present"] = !!present; + if (present) { var keys = [ "developerPath", "version" diff --git a/tests/auto/blackbox/tst_blackboxapple.cpp b/tests/auto/blackbox/tst_blackboxapple.cpp index 01446c815..fdb656c72 100644 --- a/tests/auto/blackbox/tst_blackboxapple.cpp +++ b/tests/auto/blackbox/tst_blackboxapple.cpp @@ -191,10 +191,12 @@ void TestBlackboxApple::initTestCase() void TestBlackboxApple::appleMultiConfig() { const auto xcodeVersion = findXcodeVersion(); + if (!xcodeVersion) + QSKIP("requires Xcode profile"); QDir::setCurrent(testDataDir + "/apple-multiconfig"); QCOMPARE(runQbs(QbsRunParameters(QStringList{ "qbs.installPrefix:''", - QStringLiteral("project.xcodeVersion:") + xcodeVersion.toString()})), 0); + QStringLiteral("project.xcodeVersion:") + xcodeVersion->toString()})), 0); if (m_qbsStdout.contains("isShallow: false")) { QVERIFY(QFileInfo2(defaultInstallRoot + "/singleapp.app/Contents/MacOS/singleapp").isExecutable()); @@ -304,6 +306,10 @@ void TestBlackboxApple::appleMultiConfig() void TestBlackboxApple::aggregateDependencyLinking() { const auto xcodeVersion = findXcodeVersion(); + + if (!xcodeVersion) + QSKIP("requires Xcode profile"); + // XCode 11 produces warning about deprecation of 32-bit apps, but still works const bool hasX86Mac = xcodeVersion < qbs::Version(12); const bool hasArmMac = xcodeVersion >= qbs::Version(12, 2); @@ -363,6 +369,9 @@ void TestBlackboxApple::assetCatalog() rmDirR(relativeBuildDir()); + if (!findXcode()) + QSKIP("requires Xcode profile"); + QbsRunParameters params; const QString flattens = "modules.ib.flatten:" + QString(flatten ? "true" : "false"); const QString macosTarget = "modules.cpp.minimumMacosVersion:'10.15'"; @@ -709,6 +718,9 @@ void TestBlackboxApple::codesign() const auto xcodeVersion = findXcodeVersion(); + if (!xcodeVersion) + QSKIP("requires Xcode profile"); + QDir::setCurrent(testDataDir + "/codesign"); QbsRunParameters params(QStringList{"qbs.installPrefix:''"}); params.arguments @@ -716,7 +728,7 @@ void TestBlackboxApple::codesign() params.arguments << QStringLiteral("project.enableSigning:%1").arg(enableSigning ? "true" : "false"); if (multiArch) - params.arguments << QStringLiteral("project.xcodeVersion:") + xcodeVersion.toString(); + params.arguments << QStringLiteral("project.xcodeVersion:") + xcodeVersion->toString(); rmDirR(relativeBuildDir()); QCOMPARE(runQbs(params), 0); @@ -791,6 +803,9 @@ void TestBlackboxApple::deploymentTarget() QDir::setCurrent(testDataDir + "/deploymentTarget"); + if (!findXcode()) + QSKIP("requires Xcode profile"); + QbsRunParameters params; params.arguments = QStringList() << "--command-echo-mode" @@ -1097,6 +1112,9 @@ void TestBlackboxApple::overrideInfoPlist() void TestBlackboxApple::xcode() { + if (!findXcode()) + QSKIP("requires Xcode profile"); + QProcess xcodeSelect; xcodeSelect.start("xcode-select", QStringList() << "--print-path"); QVERIFY2(xcodeSelect.waitForStarted(), qPrintable(xcodeSelect.errorString())); @@ -1149,7 +1167,7 @@ void TestBlackboxApple::xcode() QTEST_MAIN(TestBlackboxApple) -QVariantMap TestBlackboxApple::findXcode(int *status) +std::optional<QVariantMap> TestBlackboxApple::findXcode(int *status) { QTemporaryDir temp; QbsRunParameters params = QStringList({"-f", testDataDir + "/find/find-xcode.qbs"}); @@ -1161,10 +1179,16 @@ QVariantMap TestBlackboxApple::findXcode(int *status) + "/xcode.json"); if (!file.open(QIODevice::ReadOnly)) return {}; - return QJsonDocument::fromJson(file.readAll()).toVariant().toMap(); + auto result = QJsonDocument::fromJson(file.readAll()).toVariant().toMap(); + if (!result["present"].toBool()) + return {}; + return result; } -qbs::Version TestBlackboxApple::findXcodeVersion() +std::optional<qbs::Version> TestBlackboxApple::findXcodeVersion() { - return qbs::Version::fromString(findXcode().value("version").toString()); + const auto xcode = findXcode(); + if (!xcode) + return {}; + return qbs::Version::fromString(xcode->value("version").toString()); } diff --git a/tests/auto/blackbox/tst_blackboxapple.h b/tests/auto/blackbox/tst_blackboxapple.h index 9c329e961..a51414917 100644 --- a/tests/auto/blackbox/tst_blackboxapple.h +++ b/tests/auto/blackbox/tst_blackboxapple.h @@ -31,6 +31,8 @@ #include "tst_blackboxbase.h" +#include <optional> + namespace qbs { class Version; } // namespace qbs @@ -72,8 +74,8 @@ private slots: void xcode(); private: - QVariantMap findXcode(int *status = nullptr); - qbs::Version findXcodeVersion(); + std::optional<QVariantMap> findXcode(int *status = nullptr); + std::optional<qbs::Version> findXcodeVersion(); }; #endif // TST_BLACKBOXAPPLE_H |