diff options
Diffstat (limited to 'tests/auto/blackbox/tst_blackboxapple.cpp')
-rw-r--r-- | tests/auto/blackbox/tst_blackboxapple.cpp | 135 |
1 files changed, 80 insertions, 55 deletions
diff --git a/tests/auto/blackbox/tst_blackboxapple.cpp b/tests/auto/blackbox/tst_blackboxapple.cpp index 2744f907e..30e20a1c9 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); @@ -359,15 +365,16 @@ void TestBlackboxApple::assetCatalog() { QFETCH(bool, flatten); - const auto xcodeVersion = findXcodeVersion(); QDir::setCurrent(testDataDir + QLatin1String("/ib/assetcatalog")); rmDirR(relativeBuildDir()); + if (!findXcode()) + QSKIP("requires Xcode profile"); + QbsRunParameters params; - const auto v = HostOsInfo::hostOsVersion(); const QString flattens = "modules.ib.flatten:" + QString(flatten ? "true" : "false"); - const QString macosTarget = "modules.cpp.minimumMacosVersion:'" + v.toString() + "'"; + const QString macosTarget = "modules.cpp.minimumMacosVersion:'10.15'"; // Make sure a dry run does not write anything params.arguments = QStringList() << "-f" << "assetcatalogempty.qbs" << "--dry-run" @@ -383,39 +390,12 @@ void TestBlackboxApple::assetCatalog() QCOMPARE(runQbs(params), 0); // empty asset catalogs must still produce output - if (xcodeVersion >= qbs::Version(5)) - QVERIFY((bool)m_qbsStdout.contains("compiling empty.xcassets")); - - // should additionally produce raw assets since deployment target will be < 10.9 - // older versions of ibtool generated either raw assets OR .car files; - // newer versions always generate the .car file regardless of the deployment target - if (v < qbs::Version(10, 9)) { - QVERIFY(regularFileExists(relativeProductBuildDir("assetcatalogempty") - + "/assetcatalogempty.app/Contents/Resources/other.png")); - QVERIFY(regularFileExists(relativeProductBuildDir("assetcatalogempty") - + "/assetcatalogempty.app/Contents/Resources/other@2x.png")); - } - - rmDirR(relativeBuildDir()); - params.arguments.push_back("modules.cpp.minimumMacosVersion:'10.10'"); // force CAR generation - QCOMPARE(runQbs(params), 0); + QVERIFY((bool)m_qbsStdout.contains("compiling empty.xcassets")); // empty asset catalogs must still produce output - if (xcodeVersion >= qbs::Version(5)) { - QVERIFY((bool)m_qbsStdout.contains("compiling empty.xcassets")); - // No matter what, we need a 10.9 host to build CAR files - if (HostOsInfo::hostOsVersion() >= qbs::Version(10, 9)) { - QVERIFY(regularFileExists(relativeProductBuildDir("assetcatalogempty") - + "/assetcatalogempty.app/Contents/Resources/Assets.car")); - } else { - QVERIFY(regularFileExists(relativeProductBuildDir("assetcatalogempty") - + "/assetcatalogempty.app/Contents/Resources/empty.icns")); - QVERIFY(regularFileExists(relativeProductBuildDir("assetcatalogempty") - + "/assetcatalogempty.app/Contents/Resources/other.png")); - QVERIFY(regularFileExists(relativeProductBuildDir("assetcatalogempty") - + "/assetcatalogempty.app/Contents/Resources/other@2x.png")); - } - } + QVERIFY((bool)m_qbsStdout.contains("compiling empty.xcassets")); + QVERIFY(regularFileExists(relativeProductBuildDir("assetcatalogempty") + + "/assetcatalogempty.app/Contents/Resources/Assets.car")); // this asset catalog happens to have an embedded icon set, // but this should NOT be built since it is not in the files list @@ -713,30 +693,53 @@ void TestBlackboxApple::bundleStructure_data() QTest::newRow("G") << "G" << "com.apple.product-type.in-app-purchase-content"; } +void TestBlackboxApple::byteArrayInfoPlist() +{ + QDir::setCurrent(testDataDir + "/byteArrayInfoPlist"); + + QCOMPARE(runQbs(), 0); + + const auto infoPlistPath = getInfoPlistPath( + relativeProductBuildDir("byteArrayInfoPlist") + "/byteArrayInfoPlist.app"); + QVERIFY(QFile::exists(infoPlistPath)); + const auto outFilePath = + relativeProductBuildDir("byteArrayInfoPlist") + "/bytearrayInfoPlist-Info.plist.out"; + QFile file(outFilePath); + QVERIFY(file.exists()); + QVERIFY(file.open(QIODevice::ReadOnly)); + QCOMPARE(file.readAll(), "The data value"); +} + void TestBlackboxApple::codesign() { + QFETCH(int, expectedCount); QFETCH(bool, isBundle); QFETCH(bool, enableSigning); QFETCH(bool, multiArch); + QFETCH(bool, multiVariant); const auto xcodeVersion = findXcodeVersion(); + if (!xcodeVersion) + QSKIP("requires Xcode profile"); + QDir::setCurrent(testDataDir + "/codesign"); QbsRunParameters params(QStringList{"qbs.installPrefix:''"}); - params.arguments - << QStringLiteral("project.isBundle:%1").arg(isBundle ? "true" : "false"); - params.arguments - << QStringLiteral("project.enableSigning:%1").arg(enableSigning ? "true" : "false"); - if (multiArch) - params.arguments << QStringLiteral("project.xcodeVersion:") + xcodeVersion.toString(); + // the test can't use xcode module to determine version itself + params.arguments << QStringLiteral("project.xcodeVersion:") + xcodeVersion->toString(); + params.arguments << QStringLiteral("project.isBundle:%1").arg(isBundle ? "true" : "false"); + params.arguments << QStringLiteral("project.enableSigning:%1") + .arg(enableSigning ? "true" : "false"); + params.arguments << QStringLiteral("project.multiArch:%1").arg(multiArch ? "true" : "false"); + params.arguments << QStringLiteral("project.multiVariant:%1") + .arg(multiVariant ? "true" : "false"); rmDirR(relativeBuildDir()); QCOMPARE(runQbs(params), 0); const int codeSignCount = QString::fromUtf8(m_qbsStdout).count(QStringLiteral("codesign")); - // We have 3 products, we have to sign each exactly once, even in the multiplexed case - QCOMPARE(codeSignCount, enableSigning ? 3 : 0); + QCOMPARE(codeSignCount, expectedCount); const auto appName = isBundle ? QStringLiteral("A.app") : QStringLiteral("A"); const auto appPath = defaultInstallRoot + "/" + appName; @@ -781,16 +784,25 @@ void TestBlackboxApple::codesign() void TestBlackboxApple::codesign_data() { + QTest::addColumn<int>("expectedCount"); QTest::addColumn<bool>("isBundle"); QTest::addColumn<bool>("enableSigning"); QTest::addColumn<bool>("multiArch"); - - QTest::newRow("bundle, unsigned") << true << false << false; - QTest::newRow("standalone, unsigned") << false << false << false; - QTest::newRow("bundle, signed") << true << true << false; - QTest::newRow("standalone, signed") << false << true << false; - QTest::newRow("bundle, signed, multiarch") << true << true << true; - QTest::newRow("standalone, signed, multiarch") << false << true << true; + QTest::addColumn<bool>("multiVariant"); + + QTest::newRow("standalone, unsigned") << 0 << false << false << false << false; + QTest::newRow("bundle, unsigned") << 0 << true << false << false << false; + QTest::newRow("standalone, signed") << 3 << false << true << false << false; + QTest::newRow("bundle, signed") << 3 << true << true << false << false; + // here we only sign the resulting lipo artifact + QTest::newRow("standalone, signed, multiarch") << 3 << false << true << true << false; + QTest::newRow("bundle, signed, multiarch") << 3 << true << true << true << false; + // here we sign all artifacts + QTest::newRow("standalone, signed, multivariant") << 15 << false << true << false << true; + QTest::newRow("bundle, signed, multivariant") << 15 << true << true << false << true; + QTest::newRow("standalone, signed, multiarch, multivariant") + << 15 << false << true << true << true; + QTest::newRow("bundle, signed, multiarch, multivariant") << 15 << true << true << true << true; } void TestBlackboxApple::deploymentTarget() @@ -803,6 +815,9 @@ void TestBlackboxApple::deploymentTarget() QDir::setCurrent(testDataDir + "/deploymentTarget"); + if (!findXcode()) + QSKIP("requires Xcode profile"); + QbsRunParameters params; params.arguments = QStringList() << "--command-echo-mode" @@ -1023,6 +1038,7 @@ void TestBlackboxApple::infoPlist() if (!content.contains(QStringLiteral("SDKROOT"))) { // macOS-specific values QCOMPARE(content.value("LSMinimumSystemVersion"), QStringLiteral("10.7")); QCOMPARE(content.value("NSPrincipalClass"), QStringLiteral("NSApplication")); + QCOMPARE(content.value(QStringLiteral("NSSupportsAutomaticGraphicsSwitching")), true); } else { // QBS-1447: UIDeviceFamily was set to a string instead of an array const auto family = content.value(QStringLiteral("UIDeviceFamily")); @@ -1108,6 +1124,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())); @@ -1124,7 +1143,7 @@ void TestBlackboxApple::xcode() QVERIFY2(xcodebuildShowSdks.exitCode() == 0, qPrintable(xcodebuildShowSdks.readAllStandardError().constData())); const auto lines = QString::fromLocal8Bit(xcodebuildShowSdks.readAllStandardOutput().trimmed()) - .split('\n', QBS_SKIP_EMPTY_PARTS); + .split('\n', Qt::SkipEmptyParts); for (const QString &line : lines) { static const std::regex regexp("^.+\\s+\\-sdk\\s+([a-z]+)([0-9]+\\.[0-9]+)$"); const auto ln = line.toStdString(); @@ -1160,7 +1179,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"}); @@ -1172,10 +1191,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()); } |