diff options
Diffstat (limited to 'tests/auto/blackbox')
362 files changed, 4177 insertions, 1326 deletions
diff --git a/tests/auto/blackbox/CMakeLists.txt b/tests/auto/blackbox/CMakeLists.txt index 0bf79a433..88e19acdf 100644 --- a/tests/auto/blackbox/CMakeLists.txt +++ b/tests/auto/blackbox/CMakeLists.txt @@ -1,6 +1,7 @@ add_qbs_test(blackbox DEFINES ${QBS_UNIT_TESTS_DEFINES} + "QBS_VERSION=\"${QBS_VERSION}\"" SOURCES ../shared.h tst_blackboxbase.cpp @@ -62,6 +63,14 @@ add_qbs_test(blackbox-joblimits tst_blackboxjoblimits.cpp ) +add_qbs_test(blackbox-providers + SOURCES + ../shared.h + tst_blackboxbase.cpp + tst_blackboxbase.h + tst_blackboxproviders.cpp + ) + add_qbs_test(blackbox-qt SOURCES ../shared.h @@ -71,6 +80,15 @@ add_qbs_test(blackbox-qt tst_blackboxqt.h ) +add_qbs_test(blackbox-tutorial + SOURCES + ../shared.h + tst_blackboxbase.cpp + tst_blackboxbase.h + tst_blackboxtutorial.h + tst_blackboxtutorial.cpp + ) + add_qbs_test(blackbox-windows SOURCES ../shared.h diff --git a/tests/auto/blackbox/blackbox-android.pro b/tests/auto/blackbox/blackbox-android.pro deleted file mode 100644 index 7aca99e8d..000000000 --- a/tests/auto/blackbox/blackbox-android.pro +++ /dev/null @@ -1,21 +0,0 @@ -TARGET = tst_blackbox-android - -HEADERS = tst_blackboxandroid.h tst_blackboxbase.h -SOURCES = tst_blackboxandroid.cpp tst_blackboxbase.cpp -OBJECTS_DIR = android -MOC_DIR = $${OBJECTS_DIR}-moc - -include(../auto.pri) - -DATA_DIRS = testdata-android ../find - -for(data_dir, DATA_DIRS) { - files = $$files($$PWD/$$data_dir/*, true) - win32:files ~= s|\\\\|/|g - for(file, files):!exists($$file/*):FILES += $$file -} - -OTHER_FILES += $$FILES - -DISTFILES += \ - testdata/texttemplate/expected-output-one.txt diff --git a/tests/auto/blackbox/blackbox-apple.pro b/tests/auto/blackbox/blackbox-apple.pro deleted file mode 100644 index 1a009e222..000000000 --- a/tests/auto/blackbox/blackbox-apple.pro +++ /dev/null @@ -1,20 +0,0 @@ -TARGET = tst_blackbox-apple - -HEADERS = tst_blackboxapple.h tst_blackboxbase.h -SOURCES = tst_blackboxapple.cpp tst_blackboxbase.cpp -OBJECTS_DIR = apple -MOC_DIR = $${OBJECTS_DIR}-moc - -include(../auto.pri) - -QT += xml - -DATA_DIRS = testdata-apple ../find - -for(data_dir, DATA_DIRS) { - files = $$files($$PWD/$$data_dir/*, true) - win32:files ~= s|\\\\|/|g - for(file, files):!exists($$file/*):FILES += $$file -} - -OTHER_FILES += $$FILES diff --git a/tests/auto/blackbox/blackbox-baremetal.pro b/tests/auto/blackbox/blackbox-baremetal.pro deleted file mode 100644 index 32789346c..000000000 --- a/tests/auto/blackbox/blackbox-baremetal.pro +++ /dev/null @@ -1,18 +0,0 @@ -TARGET = tst_blackbox-baremetal - -HEADERS = tst_blackboxbaremetal.h tst_blackboxbase.h -SOURCES = tst_blackboxbaremetal.cpp tst_blackboxbase.cpp -OBJECTS_DIR = baremetal -MOC_DIR = $${OBJECTS_DIR}-moc - -include(../auto.pri) - -DATA_DIRS = testdata-baremetal ../find - -for(data_dir, DATA_DIRS) { - files = $$files($$PWD/$$data_dir/*, true) - win32:files ~= s|\\\\|/|g - for(file, files):!exists($$file/*):FILES += $$file -} - -OTHER_FILES += $$FILES diff --git a/tests/auto/blackbox/blackbox-clangdb.pro b/tests/auto/blackbox/blackbox-clangdb.pro deleted file mode 100644 index 6e4075175..000000000 --- a/tests/auto/blackbox/blackbox-clangdb.pro +++ /dev/null @@ -1,18 +0,0 @@ -TARGET = tst_blackbox-clangdb - -HEADERS = tst_blackboxbase.h tst_clangdb.h -SOURCES = tst_blackboxbase.cpp tst_clangdb.cpp -OBJECTS_DIR = clangdb -MOC_DIR = $${OBJECTS_DIR}-moc - -include(../auto.pri) - -DATA_DIRS = testdata-clangdb - -for(data_dir, DATA_DIRS) { - files = $$files($$PWD/$$data_dir/*, true) - win32:files ~= s|\\\\|/|g - for(file, files):!exists($$file/*):FILES += $$file -} - -OTHER_FILES += $$FILES diff --git a/tests/auto/blackbox/blackbox-examples.pro b/tests/auto/blackbox/blackbox-examples.pro deleted file mode 100644 index 70d5b6419..000000000 --- a/tests/auto/blackbox/blackbox-examples.pro +++ /dev/null @@ -1,18 +0,0 @@ -TARGET = tst_blackbox-examples - -HEADERS = tst_blackboxexamples.h tst_blackboxbase.h -SOURCES = tst_blackboxexamples.cpp tst_blackboxbase.cpp -OBJECTS_DIR = examples -MOC_DIR = $${OBJECTS_DIR}-moc - -include(../auto.pri) - -DATA_DIRS = ../../../examples - -for(data_dir, DATA_DIRS) { - files = $$files($$PWD/$$data_dir/*, true) - win32:files ~= s|\\\\|/|g - for(file, files):!exists($$file/*):FILES += $$file -} - -OTHER_FILES += $$FILES diff --git a/tests/auto/blackbox/blackbox-java.pro b/tests/auto/blackbox/blackbox-java.pro deleted file mode 100644 index d297d9e09..000000000 --- a/tests/auto/blackbox/blackbox-java.pro +++ /dev/null @@ -1,18 +0,0 @@ -TARGET = tst_blackbox-java - -HEADERS = tst_blackboxjava.h tst_blackboxbase.h -SOURCES = tst_blackboxjava.cpp tst_blackboxbase.cpp -OBJECTS_DIR = java -MOC_DIR = $${OBJECTS_DIR}-moc - -include(../auto.pri) - -DATA_DIRS = testdata-java ../find - -for(data_dir, DATA_DIRS) { - files = $$files($$PWD/$$data_dir/*, true) - win32:files ~= s|\\\\|/|g - for(file, files):!exists($$file/*):FILES += $$file -} - -OTHER_FILES += $$FILES diff --git a/tests/auto/blackbox/blackbox-joblimits.pro b/tests/auto/blackbox/blackbox-joblimits.pro deleted file mode 100644 index 85413473e..000000000 --- a/tests/auto/blackbox/blackbox-joblimits.pro +++ /dev/null @@ -1,18 +0,0 @@ -TARGET = tst_blackbox-joblimits - -HEADERS = tst_blackboxbase.h -SOURCES = tst_blackboxjoblimits.cpp tst_blackboxbase.cpp -OBJECTS_DIR = joblimits -MOC_DIR = $${OBJECTS_DIR}-moc - -include(../auto.pri) - -DATA_DIRS = testdata-joblimits ../find - -for(data_dir, DATA_DIRS) { - files = $$files($$PWD/$$data_dir/*, true) - win32:files ~= s|\\\\|/|g - for(file, files):!exists($$file/*):FILES += $$file -} - -OTHER_FILES += $$FILES diff --git a/tests/auto/blackbox/blackbox-providers.qbs b/tests/auto/blackbox/blackbox-providers.qbs new file mode 100644 index 000000000..95ebaa423 --- /dev/null +++ b/tests/auto/blackbox/blackbox-providers.qbs @@ -0,0 +1,21 @@ +import qbs.Utilities + +QbsAutotest { + testName: "blackbox-providers" + Depends { name: "qbs_app" } + Depends { name: "qbs-setup-toolchains" } + Group { + name: "testdata" + prefix: "testdata-providers/" + files: ["**/*"] + fileTags: [] + } + files: [ + "../shared.h", + "tst_blackboxbase.cpp", + "tst_blackboxbase.h", + "tst_blackboxproviders.cpp", + "tst_blackboxproviders.h", + ] + cpp.defines: base.concat(["SRCDIR=" + Utilities.cStringQuote(path)]) +} diff --git a/tests/auto/blackbox/blackbox-qt.pro b/tests/auto/blackbox/blackbox-qt.pro deleted file mode 100644 index e17a04a7e..000000000 --- a/tests/auto/blackbox/blackbox-qt.pro +++ /dev/null @@ -1,18 +0,0 @@ -TARGET = tst_blackbox-qt - -HEADERS = tst_blackboxqt.h tst_blackboxbase.h -SOURCES = tst_blackboxqt.cpp tst_blackboxbase.cpp -OBJECTS_DIR = qt -MOC_DIR = $${OBJECTS_DIR}-moc - -include(../auto.pri) - -DATA_DIRS = testdata-qt ../find - -for(data_dir, DATA_DIRS) { - files = $$files($$PWD/$$data_dir/*, true) - win32:files ~= s|\\\\|/|g - for(file, files):!exists($$file/*):FILES += $$file -} - -OTHER_FILES += $$FILES diff --git a/tests/auto/blackbox/blackbox-tutorial.qbs b/tests/auto/blackbox/blackbox-tutorial.qbs new file mode 100644 index 000000000..174821ffa --- /dev/null +++ b/tests/auto/blackbox/blackbox-tutorial.qbs @@ -0,0 +1,21 @@ +import qbs.Utilities + +QbsAutotest { + testName: "blackbox-tutorial" + Depends { name: "qbs_app" } + Depends { name: "qbs-setup-toolchains" } + Group { + name: "testdata" + prefix: "../../../tutorial/" + files: ["**/*"] + fileTags: [] + } + files: [ + "../shared.h", + "tst_blackboxtutorial.cpp", + "tst_blackboxtutorial.h", + "tst_blackboxbase.cpp", + "tst_blackboxbase.h", + ] + cpp.defines: base.concat(["SRCDIR=" + Utilities.cStringQuote(path)]) +} diff --git a/tests/auto/blackbox/blackbox-windows.pro b/tests/auto/blackbox/blackbox-windows.pro deleted file mode 100644 index a9e8fdbd2..000000000 --- a/tests/auto/blackbox/blackbox-windows.pro +++ /dev/null @@ -1,18 +0,0 @@ -TARGET = tst_blackbox-windows - -HEADERS = tst_blackboxwindows.h tst_blackboxbase.h -SOURCES = tst_blackboxwindows.cpp tst_blackboxbase.cpp -OBJECTS_DIR = windows -MOC_DIR = $${OBJECTS_DIR}-moc - -include(../auto.pri) - -DATA_DIRS = testdata-windows ../find - -for(data_dir, DATA_DIRS) { - files = $$files($$PWD/$$data_dir/*, true) - win32:files ~= s|\\\\|/|g - for(file, files):!exists($$file/*):FILES += $$file -} - -OTHER_FILES += $$FILES diff --git a/tests/auto/blackbox/blackbox.pro b/tests/auto/blackbox/blackbox.pro deleted file mode 100644 index 42848d077..000000000 --- a/tests/auto/blackbox/blackbox.pro +++ /dev/null @@ -1,21 +0,0 @@ -TARGET = tst_blackbox - -HEADERS = tst_blackbox.h tst_blackboxbase.h -SOURCES = tst_blackbox.cpp tst_blackboxbase.cpp -OBJECTS_DIR = generic -MOC_DIR = $${OBJECTS_DIR}-moc -qbs_enable_unit_tests:DEFINES += QBS_ENABLE_UNIT_TESTS - -include(../auto.pri) - -QT += xml - -DATA_DIRS = testdata ../find - -for(data_dir, DATA_DIRS) { - files = $$files($$PWD/$$data_dir/*, true) - win32:files ~= s|\\\\|/|g - for(file, files):!exists($$file/*):FILES += $$file -} - -OTHER_FILES += $$FILES diff --git a/tests/auto/blackbox/blackbox.qbs b/tests/auto/blackbox/blackbox.qbs index 3f0ff959a..ac6bf750e 100644 --- a/tests/auto/blackbox/blackbox.qbs +++ b/tests/auto/blackbox/blackbox.qbs @@ -25,4 +25,5 @@ QbsAutotest { ] cpp.defines: base.concat(["SRCDIR=" + Utilities.cStringQuote(path)]) .concat(qbsbuildconfig.enableUnitTests ? ["QBS_ENABLE_UNIT_TESTS"] : []) + .concat("QBS_VERSION=" + Utilities.cStringQuote(qbsversion.version)) } 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/testdata-android/minimal-native/minimal-native.qbs b/tests/auto/blackbox/testdata-android/minimal-native/minimal-native.qbs index 570152707..7231f7e62 100644 --- a/tests/auto/blackbox/testdata-android/minimal-native/minimal-native.qbs +++ b/tests/auto/blackbox/testdata-android/minimal-native/minimal-native.qbs @@ -1,7 +1,7 @@ CppApplication { name: "minimalnative" qbs.buildVariant: "release" - Properties { condition: qbs.toolchain.contains("clang"); Android.ndk.appStl: "c++_shared" } + Properties { condition: qbs.toolchain.includes("clang"); Android.ndk.appStl: "c++_shared" } Android.sdk.packageName: "my.minimalnative" Android.sdk.apkBaseName: name Android.ndk.appStl: "stlport_shared" diff --git a/tests/auto/blackbox/testdata-android/multiple-apks-per-project/product1/product1.qbs b/tests/auto/blackbox/testdata-android/multiple-apks-per-project/product1/product1.qbs index c4a78a30b..c7b9b3de2 100644 --- a/tests/auto/blackbox/testdata-android/multiple-apks-per-project/product1/product1.qbs +++ b/tests/auto/blackbox/testdata-android/multiple-apks-per-project/product1/product1.qbs @@ -5,9 +5,12 @@ Project { name: "p1lib1" files: ["src/main/jni/lib1.cpp"] qbs.targetPlatform: "android" - Properties { condition: qbs.toolchain.contains("clang"); Android.ndk.appStl: "c++_shared" } + Properties { condition: qbs.toolchain.includes("clang"); Android.ndk.appStl: "c++_shared" } Android.ndk.appStl: "stlport_shared" - qbs.architectures: !qbs.architecture ? ["armv7a", "x86"] : undefined + Properties { + qbs.architectures: !qbs.architecture ? ["armv7a", "x86"] : undefined + overrideListProperties: true + } cpp.useRPaths: false } @@ -17,7 +20,7 @@ Project { name: "p1lib2" files: ["src/main/jni/lib2.cpp"] qbs.targetPlatform: "android" - Properties { condition: qbs.toolchain.contains("clang"); Android.ndk.appStl: "c++_shared" } + Properties { condition: qbs.toolchain.includes("clang"); Android.ndk.appStl: "c++_shared" } Android.ndk.appStl: "stlport_shared" cpp.useRPaths: false } diff --git a/tests/auto/blackbox/testdata-android/multiple-apks-per-project/product2/product2.qbs b/tests/auto/blackbox/testdata-android/multiple-apks-per-project/product2/product2.qbs index 9be70dcda..f880a576d 100644 --- a/tests/auto/blackbox/testdata-android/multiple-apks-per-project/product2/product2.qbs +++ b/tests/auto/blackbox/testdata-android/multiple-apks-per-project/product2/product2.qbs @@ -13,7 +13,7 @@ Project { name: "p2lib2" files: ["src/main/jni/lib2.cpp"] qbs.targetPlatform: "android" - Properties { condition: qbs.toolchain.contains("clang"); Android.ndk.appStl: "c++_shared" } + Properties { condition: qbs.toolchain.includes("clang"); Android.ndk.appStl: "c++_shared" } Android.ndk.appStl: "stlport_shared" } diff --git a/tests/auto/blackbox/testdata-android/multiple-libs-per-apk/multiple-libs-per-apk.qbs b/tests/auto/blackbox/testdata-android/multiple-libs-per-apk/multiple-libs-per-apk.qbs index 8b9ded211..a5e193905 100644 --- a/tests/auto/blackbox/testdata-android/multiple-libs-per-apk/multiple-libs-per-apk.qbs +++ b/tests/auto/blackbox/testdata-android/multiple-libs-per-apk/multiple-libs-per-apk.qbs @@ -5,7 +5,7 @@ Project { name: "lib1" files: ["src/main/jni/lib1.cpp"] qbs.targetPlatform: "android" - Properties { condition: qbs.toolchain.contains("clang"); Android.ndk.appStl: "c++_shared" } + Properties { condition: qbs.toolchain.includes("clang"); Android.ndk.appStl: "c++_shared" } Android.ndk.appStl: "stlport_shared" cpp.useRPaths: false } @@ -16,7 +16,7 @@ Project { name: "lib2" files: ["src/main/jni/lib2.cpp"] qbs.targetPlatform: "android" - Properties { condition: qbs.toolchain.contains("clang"); Android.ndk.appStl: "c++_shared" } + Properties { condition: qbs.toolchain.includes("clang"); Android.ndk.appStl: "c++_shared" } Android.ndk.appStl: "stlport_shared" cpp.useRPaths: false } diff --git a/tests/auto/blackbox/testdata-android/qml-app/qml-app.qbs b/tests/auto/blackbox/testdata-android/qml-app/qml-app.qbs index e91a14902..5760fa4f0 100644 --- a/tests/auto/blackbox/testdata-android/qml-app/qml-app.qbs +++ b/tests/auto/blackbox/testdata-android/qml-app/qml-app.qbs @@ -3,12 +3,12 @@ QtApplication { Depends { name: "Qt.quick" } Depends { name: "Qt.android_support" } Properties { - condition: qbs.targetOS.contains("android") + condition: qbs.targetOS.includes("android") Qt.android_support.extraPrefixDirs: path } Android.sdk.packageName: "my.qmlapp" Android.sdk.apkBaseName: name - property stringList qmlImportPaths: path + Qt.android_support.qmlImportPaths: path files: [ "main.cpp", "qml.qrc", diff --git a/tests/auto/blackbox/testdata-android/teapot/teapot.qbs b/tests/auto/blackbox/testdata-android/teapot/teapot.qbs index 30cfbb820..0b1dead6e 100644 --- a/tests/auto/blackbox/testdata-android/teapot/teapot.qbs +++ b/tests/auto/blackbox/testdata-android/teapot/teapot.qbs @@ -51,7 +51,7 @@ Project { files: ["*.cpp", "*.h"].concat( !File.exists(ndkHelperProbe.dir + "/gl3stub.cpp") ? ["gl3stub.c"] : []) } - Properties { condition: qbs.toolchain.contains("clang"); Android.ndk.appStl: "c++_shared" } + Properties { condition: qbs.toolchain.includes("clang"); Android.ndk.appStl: "c++_shared" } Android.ndk.appStl: "gnustl_shared" cpp.cxxLanguageVersion: "c++11" @@ -137,7 +137,7 @@ Project { Android.sdk.apkBaseName: name Android.sdk.packageName: "com.sample.teapot" Android.sdk.sourceSetDir: teapotProbe.dir - Properties { condition: qbs.toolchain.contains("clang"); Android.ndk.appStl: "c++_shared" } + Properties { condition: qbs.toolchain.includes("clang"); Android.ndk.appStl: "c++_shared" } Android.ndk.appStl: "gnustl_shared" cpp.cxxLanguageVersion: "c++11" cpp.dynamicLibraries: ["log", "android", "EGL", "GLESv2"] diff --git a/tests/auto/blackbox/testdata-apple/apple-multiconfig/apple-multiconfig.qbs b/tests/auto/blackbox/testdata-apple/apple-multiconfig/apple-multiconfig.qbs index 6b7fab390..5615722d5 100644 --- a/tests/auto/blackbox/testdata-apple/apple-multiconfig/apple-multiconfig.qbs +++ b/tests/auto/blackbox/testdata-apple/apple-multiconfig/apple-multiconfig.qbs @@ -26,6 +26,7 @@ Project { multiplexByQbsProperties: [] install: true + installDebugInformation: false installDir: "" } @@ -45,6 +46,7 @@ Project { qbs.buildVariants: ["release"] install: true + installDebugInformation: false installDir: "" } @@ -54,7 +56,7 @@ Project { name: "singlelib" targetName: "singlelib" files: ["lib.c"] - cpp.sonamePrefix: qbs.targetOS.contains("darwin") ? "@rpath" : undefined + cpp.sonamePrefix: qbs.targetOS.includes("darwin") ? "@rpath" : undefined cpp.defines: ["VARIANT=" + Utilities.cStringQuote(qbs.buildVariant)] // Turn off multiplexing @@ -62,6 +64,7 @@ Project { multiplexByQbsProperties: [] install: true + installDebugInformation: false installDir: "" } @@ -76,6 +79,7 @@ Project { cpp.minimumIosVersion: "8.0" install: true + installDebugInformation: false installDir: "" } @@ -96,6 +100,7 @@ Project { qbs.buildVariants: "debug" install: true + installDebugInformation: false installDir: "" } @@ -112,6 +117,7 @@ Project { qbs.buildVariants: ["debug", "profiling"] install: true + installDebugInformation: false installDir: "" } @@ -122,12 +128,13 @@ Project { targetName: "multilib" files: ["lib.c"] cpp.minimumIosVersion: "8.0" - cpp.sonamePrefix: qbs.targetOS.contains("darwin") ? "@rpath" : undefined + cpp.sonamePrefix: qbs.targetOS.includes("darwin") ? "@rpath" : undefined cpp.defines: ["VARIANT=" + Utilities.cStringQuote(qbs.buildVariant)] qbs.architectures: Helpers.getArchitectures(qbs, project.xcodeVersion) qbs.buildVariants: ["release", "debug", "profiling"] install: true + installDebugInformation: false installDir: "" } @@ -138,12 +145,13 @@ Project { targetName: "multilib-no-release" files: ["lib.c"] cpp.minimumIosVersion: "8.0" - cpp.sonamePrefix: qbs.targetOS.contains("darwin") ? "@rpath" : undefined + cpp.sonamePrefix: qbs.targetOS.includes("darwin") ? "@rpath" : undefined cpp.defines: ["VARIANT=" + Utilities.cStringQuote(qbs.buildVariant)] qbs.architectures: Helpers.getArchitectures(qbs, project.xcodeVersion) qbs.buildVariants: ["debug", "profiling"] install: true + installDebugInformation: false installDir: "" } @@ -159,6 +167,7 @@ Project { qbs.architectures: Helpers.getArchitectures(qbs, project.xcodeVersion) qbs.buildVariants: ["debug", "profiling"] install: true + installDebugInformation: false installDir: "" } DynamicLibrary { @@ -172,6 +181,7 @@ Project { qbs.architectures: Helpers.getArchitectures(qbs, project.xcodeVersion) qbs.buildVariants: ["debug", "profiling"] install: true + installDebugInformation: false installDir: "" } } diff --git a/tests/auto/blackbox/testdata-apple/bundle-structure/bundle-structure.qbs b/tests/auto/blackbox/testdata-apple/bundle-structure/bundle-structure.qbs index 705f054a8..33ac58967 100644 --- a/tests/auto/blackbox/testdata-apple/bundle-structure/bundle-structure.qbs +++ b/tests/auto/blackbox/testdata-apple/bundle-structure/bundle-structure.qbs @@ -17,7 +17,7 @@ Project { Depends { name: "B" } Depends { name: "C" } Depends { name: "D" } - condition: buildableProducts.contains("A") + condition: buildableProducts.includes("A") name: "A" bundle.isBundle: true bundle.publicHeaders: ["dummy.h"] @@ -33,7 +33,7 @@ Project { Depends { name: "B" } Depends { name: "C" } Depends { name: "D" } - condition: buildableProducts.contains("ABadApple") + condition: buildableProducts.includes("ABadApple") name: "ABadApple" bundle._productTypeIdentifier: "com.apple.product-type.will.never.exist.ever.guaranteed" bundle.isBundle: true @@ -50,7 +50,7 @@ Project { Depends { name: "B" } Depends { name: "C" } Depends { name: "D" } - condition: buildableProducts.contains("ABadThirdParty") + condition: buildableProducts.includes("ABadThirdParty") name: "ABadThirdParty" bundle._productTypeIdentifier: "org.special.third.party.non.existent.product.type" bundle.isBundle: true @@ -103,7 +103,7 @@ Project { ApplicationExtension { Depends { name: "cpp" } - condition: buildableProducts.contains("E") + condition: buildableProducts.includes("E") name: "E" bundle.isBundle: true bundle.publicHeaders: ["dummy.h"] @@ -116,7 +116,7 @@ Project { XPCService { Depends { name: "cpp" } - condition: buildableProducts.contains("F") + condition: buildableProducts.includes("F") name: "F" bundle.isBundle: true bundle.publicHeaders: ["dummy.h"] @@ -129,7 +129,7 @@ Project { Product { Depends { name: "bundle" } - condition: buildableProducts.contains("G") + condition: buildableProducts.includes("G") type: ["inapppurchase"] name: "G" bundle.isBundle: true diff --git a/tests/auto/blackbox/testdata-apple/byteArrayInfoPlist/ByteArray-Info.plist b/tests/auto/blackbox/testdata-apple/byteArrayInfoPlist/ByteArray-Info.plist new file mode 100644 index 000000000..df0429f25 --- /dev/null +++ b/tests/auto/blackbox/testdata-apple/byteArrayInfoPlist/ByteArray-Info.plist @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>DataKey</key> + <!--The data value--> + <data>VGhlIGRhdGEgdmFsdWU=</data> + <key>StringKey</key> + <string>The string value</string> +</dict> +</plist> diff --git a/tests/auto/blackbox/testdata-apple/byteArrayInfoPlist/byteArrayInfoPlist.qbs b/tests/auto/blackbox/testdata-apple/byteArrayInfoPlist/byteArrayInfoPlist.qbs new file mode 100644 index 000000000..4df0886ff --- /dev/null +++ b/tests/auto/blackbox/testdata-apple/byteArrayInfoPlist/byteArrayInfoPlist.qbs @@ -0,0 +1,37 @@ +import qbs.BundleTools +import qbs.TextFile + +CppApplication { + Depends { name: "bundle" } + cpp.minimumMacosVersion: "10.7" + files: ["main.c", "ByteArray-Info.plist"] + type: base.concat(["txt_output"]) + + Properties { + condition: qbs.targetOS.includes("darwin") + bundle.isBundle: true + bundle.identifierPrefix: "com.test" + } + + Rule { + inputs: ["aggregate_infoplist"] + Artifact { + filePath: input.fileName + ".out" + fileTags: ["txt_output"] + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "generating" + output.fileName + " from " + input.fileName; + cmd.highlight = "codegen"; + cmd.sourceCode = function() { + var plist = new BundleTools.infoPlistContents(input.filePath); + var content = plist["DataKey"]; + var int8view = new Uint8Array(content); + file = new TextFile(output.filePath, TextFile.WriteOnly); + file.write(String.fromCharCode.apply(null, int8view)); + file.close(); + } + return [cmd]; + } + } +} diff --git a/tests/auto/blackbox/testdata-apple/byteArrayInfoPlist/main.c b/tests/auto/blackbox/testdata-apple/byteArrayInfoPlist/main.c new file mode 100644 index 000000000..76e819701 --- /dev/null +++ b/tests/auto/blackbox/testdata-apple/byteArrayInfoPlist/main.c @@ -0,0 +1 @@ +int main() { return 0; } diff --git a/tests/auto/blackbox/testdata-apple/codesign/codesign.qbs b/tests/auto/blackbox/testdata-apple/codesign/codesign.qbs index 08c8f730b..c1fc0502a 100644 --- a/tests/auto/blackbox/testdata-apple/codesign/codesign.qbs +++ b/tests/auto/blackbox/testdata-apple/codesign/codesign.qbs @@ -2,10 +2,13 @@ import "../multiarch-helpers.js" as Helpers Project { name: "p" + // we do not have the access to xcode version in qbs.architectures so we need to pass it here property string xcodeVersion property bool isBundle: true property bool enableSigning: true + property bool multiArch: false + property bool multiVariant: false CppApplication { name: "A" @@ -18,7 +21,8 @@ Project { installDir: "" qbs.architectures: - project.xcodeVersion ? Helpers.getArchitectures(qbs, project.xcodeVersion) : [] + multiArch ? Helpers.getArchitectures(qbs, project.xcodeVersion) : [] + qbs.buildVariants: project.multiVariant ? ["debug", "release"] : [] } DynamicLibrary { @@ -32,7 +36,8 @@ Project { install: true installDir: "" qbs.architectures: - project.xcodeVersion ? Helpers.getArchitectures(qbs, project.xcodeVersion) : [] + multiArch ? Helpers.getArchitectures(qbs, project.xcodeVersion) : [] + qbs.buildVariants: project.multiVariant ? ["debug", "release"] : [] } LoadableModule { @@ -46,6 +51,7 @@ Project { install: true installDir: "" qbs.architectures: - project.xcodeVersion ? Helpers.getArchitectures(qbs, project.xcodeVersion) : [] + multiArch ? Helpers.getArchitectures(qbs, project.xcodeVersion) : [] + qbs.buildVariants: project.multiVariant ? ["debug", "release"] : [] } } diff --git a/tests/auto/blackbox/testdata-apple/deploymentTarget/deployment.qbs b/tests/auto/blackbox/testdata-apple/deploymentTarget/deployment.qbs index 9eff57b60..2179e9c84 100644 --- a/tests/auto/blackbox/testdata-apple/deploymentTarget/deployment.qbs +++ b/tests/auto/blackbox/testdata-apple/deploymentTarget/deployment.qbs @@ -5,7 +5,7 @@ CppApplication { // - will actually link (as of Xcode 8.1) // - exist for the given architecture(s) cpp.minimumMacosVersion: qbs.architecture === "x86_64h" ? "10.12" : "10.6" - cpp.minimumIosVersion: ["armv7s", "arm64", "x86_64"].contains(qbs.architecture) ? "7.0" : "6.0" + cpp.minimumIosVersion: ["armv7s", "arm64", "x86_64"].includes(qbs.architecture) ? "7.0" : "6.0" cpp.minimumTvosVersion: "9.0" cpp.minimumWatchosVersion: "2.0" diff --git a/tests/auto/blackbox/testdata-apple/ib/assetcatalog/assetcatalogempty.qbs b/tests/auto/blackbox/testdata-apple/ib/assetcatalog/assetcatalogempty.qbs index 6e999adda..d06e24eb3 100644 --- a/tests/auto/blackbox/testdata-apple/ib/assetcatalog/assetcatalogempty.qbs +++ b/tests/auto/blackbox/testdata-apple/ib/assetcatalog/assetcatalogempty.qbs @@ -1,8 +1,9 @@ +import qbs.Host import qbs.Utilities Project { condition: { - var result = qbs.targetOS.contains("macos"); + var result = qbs.targetOS.includes("macos"); if (!result) console.info("Skip this test"); return result; @@ -17,8 +18,8 @@ Project { filez.push("empty.xcassets/empty.iconset"); else if (Utilities.versionCompare(xcode.version, "5") >= 0) filez.push("empty.xcassets"); - if ((qbs.hostOSVersionMajor >= 11 - || qbs.hostOSVersionMinor >= 10) // need macOS 10.10 or higher to build SBs + if ((Host.osVersionMajor() >= 11 + || Host.osVersionMinor() >= 10) // need macOS 10.10 or higher to build SBs && cpp.minimumMacosVersion !== undefined && Utilities.versionCompare(cpp.minimumMacosVersion, "10.10") >= 0) filez.push("Storyboard.storyboard"); diff --git a/tests/auto/blackbox/testdata-apple/infoPlistVariables/infoPlistVariables.qbs b/tests/auto/blackbox/testdata-apple/infoPlistVariables/infoPlistVariables.qbs index 3f083278f..47ca80f07 100644 --- a/tests/auto/blackbox/testdata-apple/infoPlistVariables/infoPlistVariables.qbs +++ b/tests/auto/blackbox/testdata-apple/infoPlistVariables/infoPlistVariables.qbs @@ -4,7 +4,7 @@ CppApplication { files: ["main.c", "Info.plist"] Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: true bundle.identifierPrefix: "com.test" bundle.extraEnv: { diff --git a/tests/auto/blackbox/testdata-apple/multiarch-helpers.js b/tests/auto/blackbox/testdata-apple/multiarch-helpers.js index 5d1c0f273..a8054b63c 100644 --- a/tests/auto/blackbox/testdata-apple/multiarch-helpers.js +++ b/tests/auto/blackbox/testdata-apple/multiarch-helpers.js @@ -34,35 +34,35 @@ var Utilities = require("qbs.Utilities"); // For example: x86 -> x86_64 on macOS, armv7 -> arm64 on iOS function enableOldArch(qbs, xcodeVersion) { - return qbs.targetOS.contains("macos") + return qbs.targetOS.includes("macos") && xcodeVersion && (Utilities.versionCompare(xcodeVersion, "10") < 0 || Utilities.versionCompare(xcodeVersion, "12.2") >= 0) - || qbs.targetOS.contains("ios") + || qbs.targetOS.includes("ios") } function getNewArch(qbs, xcodeVersion) { - if (qbs.targetOS.contains("macos")) + if (qbs.targetOS.includes("macos")) return xcodeVersion && Utilities.versionCompare(xcodeVersion, "12.2") >= 0 ? "arm64" : "x86_64"; - else if (qbs.targetOS.contains("ios-simulator")) + else if (qbs.targetOS.includes("ios-simulator")) return "x86_64" - else if (qbs.targetOS.contains("ios")) + else if (qbs.targetOS.includes("ios")) return "arm64" - else if (qbs.targetOS.contains("tvos")) + else if (qbs.targetOS.includes("tvos")) return "arm64" - else if (qbs.targetOS.contains("watchos")) + else if (qbs.targetOS.includes("watchos")) return "armv7k" throw "unsupported targetOS: " + qbs.targetOS; } function getOldArch(qbs, xcodeVersion) { - if (qbs.targetOS.contains("macos")) + if (qbs.targetOS.includes("macos")) return xcodeVersion && Utilities.versionCompare(xcodeVersion, "12.2") >= 0 ? "x86_64" : "x86"; - else if (qbs.targetOS.contains("ios-simulator")) + else if (qbs.targetOS.includes("ios-simulator")) return "x86" - else if (qbs.targetOS.contains("ios")) + else if (qbs.targetOS.includes("ios")) return "armv7a" throw "unsupported targetOS: " + qbs.targetOS; } diff --git a/tests/auto/blackbox/testdata-apple/objc-arc/objc-arc.qbs b/tests/auto/blackbox/testdata-apple/objc-arc/objc-arc.qbs index 545d5701c..ce128059f 100644 --- a/tests/auto/blackbox/testdata-apple/objc-arc/objc-arc.qbs +++ b/tests/auto/blackbox/testdata-apple/objc-arc/objc-arc.qbs @@ -2,7 +2,7 @@ Product { Depends { name: "cpp" } consoleApplication: true type: ["application"] - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") Group { cpp.automaticReferenceCounting: true diff --git a/tests/auto/blackbox/testdata-apple/overrideInfoPlist/overrideInfoPlist.qbs b/tests/auto/blackbox/testdata-apple/overrideInfoPlist/overrideInfoPlist.qbs index e70584ed8..270a0792c 100644 --- a/tests/auto/blackbox/testdata-apple/overrideInfoPlist/overrideInfoPlist.qbs +++ b/tests/auto/blackbox/testdata-apple/overrideInfoPlist/overrideInfoPlist.qbs @@ -4,7 +4,7 @@ CppApplication { files: ["main.c", "Override-Info.plist"] Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: true bundle.identifierPrefix: "com.test" diff --git a/tests/auto/blackbox/testdata-apple/xcode/xcode-project.qbs b/tests/auto/blackbox/testdata-apple/xcode/xcode-project.qbs index fa4c67b96..e7bf4739a 100644 --- a/tests/auto/blackbox/testdata-apple/xcode/xcode-project.qbs +++ b/tests/auto/blackbox/testdata-apple/xcode/xcode-project.qbs @@ -16,19 +16,19 @@ Project { console.info("Available SDK versions: " + xcode.availableSdkVersions.join(", ")); var targetOsToKey = function(targetOS) { - if (targetOS.contains("ios")) + if (targetOS.includes("ios")) return "iphoneos"; - if (targetOS.contains("ios-simulator")) + if (targetOS.includes("ios-simulator")) return "iphonesimulator"; - if (targetOS.contains("macos")) + if (targetOS.includes("macos")) return "macosx"; - if (targetOS.contains("tvos")) + if (targetOS.includes("tvos")) return "appletvos"; - if (targetOS.contains("tvos-simulator")) + if (targetOS.includes("tvos-simulator")) return "appletvsimulator"; - if (targetOS.contains("watchos")) + if (targetOS.includes("watchos")) return "watchos"; - if (targetOS.contains("watchos-simulator")) + if (targetOS.includes("watchos-simulator")) return "watchossimulator"; throw "Unsupported OS" + targetOS; } diff --git a/tests/auto/blackbox/testdata-baremetal/BareMetalApplication.qbs b/tests/auto/blackbox/testdata-baremetal/BareMetalApplication.qbs index f23cf1a39..7a35e4e13 100644 --- a/tests/auto/blackbox/testdata-baremetal/BareMetalApplication.qbs +++ b/tests/auto/blackbox/testdata-baremetal/BareMetalApplication.qbs @@ -1,8 +1,28 @@ +import qbs.Host + BareMetalProduct { type: "application" + consoleApplication: true + + property bool dummy: { + if (qbs.targetPlatform !== Host.platform() + || qbs.architecture !== Host.architecture()) { + + function supportsCrossRun() { + // We can run 32 bit applications on 64 bit Windows. + if (Host.platform() === "windows" && Host.architecture() === "x86_64" + && qbs.targetPlatform === "windows" && qbs.architecture === "x86") { + return true; + } + } + + if (!supportsCrossRun()) + console.info("targetPlatform differs from hostPlatform") + } + } Group { - condition: qbs.toolchain.contains("cosmic") + condition: qbs.toolchain.includes("cosmic") files: "cosmic.lkf" fileTags: "linkerscript" } diff --git a/tests/auto/blackbox/testdata-baremetal/BareMetalProduct.qbs b/tests/auto/blackbox/testdata-baremetal/BareMetalProduct.qbs index eaddef340..446cfe086 100644 --- a/tests/auto/blackbox/testdata-baremetal/BareMetalProduct.qbs +++ b/tests/auto/blackbox/testdata-baremetal/BareMetalProduct.qbs @@ -2,7 +2,7 @@ Product { Depends { name: "cpp" } cpp.positionIndependentCode: false Properties { - condition: qbs.toolchain.contains("iar") + condition: qbs.toolchain.includes("iar") && qbs.architecture === "stm8" cpp.driverLinkerFlags: [ "--config_def", "_CSTACK_SIZE=0x100", @@ -10,7 +10,7 @@ Product { ] } Properties { - condition: qbs.toolchain.contains("iar") + condition: qbs.toolchain.includes("iar") && qbs.architecture === "rl78" cpp.driverLinkerFlags: [ "--config_def", "_NEAR_HEAP_SIZE=256", @@ -24,7 +24,7 @@ Product { ] } Properties { - condition: qbs.toolchain.contains("iar") + condition: qbs.toolchain.includes("iar") && qbs.architecture === "rh850" cpp.driverLinkerFlags: [ "--config_def", "CSTACK_SIZE=0x1000", @@ -33,7 +33,7 @@ Product { ] } Properties { - condition: qbs.toolchain.contains("iar") + condition: qbs.toolchain.includes("iar") && qbs.architecture === "v850" cpp.driverLinkerFlags: [ "-D_CSTACK_SIZE=1000", @@ -42,7 +42,7 @@ Product { ] } Properties { - condition: qbs.toolchain.contains("iar") + condition: qbs.toolchain.includes("iar") && qbs.architecture === "78k" cpp.commonCompilerFlags: [ "--core", "78k0", @@ -59,7 +59,7 @@ Product { ] } Properties { - condition: qbs.toolchain.contains("iar") + condition: qbs.toolchain.includes("iar") && qbs.architecture === "sh" cpp.driverLinkerFlags: [ "--config_def", "_CSTACK_SIZE=0x800", @@ -69,7 +69,7 @@ Product { ] } Properties { - condition: qbs.toolchain.contains("iar") + condition: qbs.toolchain.includes("iar") && qbs.architecture === "hcs8" cpp.driverLinkerFlags: [ "-D_CSTACK_SIZE=200", @@ -78,7 +78,7 @@ Product { ] } Properties { - condition: qbs.toolchain.contains("iar") + condition: qbs.toolchain.includes("iar") && qbs.architecture === "m32c" cpp.driverLinkerFlags: [ "-D_CSTACK_SIZE=100", @@ -91,7 +91,7 @@ Product { ] } Properties { - condition: qbs.toolchain.contains("iar") + condition: qbs.toolchain.includes("iar") && qbs.architecture === "riscv" cpp.driverLinkerFlags: [ "--config_def", "CSTACK_SIZE=0x1000", @@ -99,7 +99,7 @@ Product { ] } Properties { - condition: qbs.toolchain.contains("iar") + condition: qbs.toolchain.includes("iar") && qbs.architecture === "m68k" cpp.cFlags: [ "--no_div" @@ -117,41 +117,41 @@ Product { ] } Properties { - condition: qbs.toolchain.contains("keil") + condition: qbs.toolchain.includes("keil") && qbs.architecture.startsWith("arm") && cpp.compilerName.startsWith("armcc") cpp.assemblerFlags: ["--cpu", "cortex-m0"] cpp.commonCompilerFlags: ["--cpu", "cortex-m0"] } Properties { - condition: qbs.toolchain.contains("keil") + condition: qbs.toolchain.includes("keil") && qbs.architecture.startsWith("arm") && cpp.compilerName.startsWith("armclang") cpp.assemblerFlags: ["--cpu", "cortex-m0"] cpp.commonCompilerFlags: ["-mcpu=cortex-m0", "--target=arm-arm-none-eabi"] } Properties { - condition: qbs.toolchain.contains("gcc") + condition: qbs.toolchain.includes("gcc") && qbs.architecture.startsWith("arm") cpp.driverFlags: ["-specs=nosys.specs"] } Properties { - condition: qbs.toolchain.contains("gcc") + condition: qbs.toolchain.includes("gcc") && qbs.architecture === "xtensa" cpp.driverFlags: ["-nostdlib"] } Properties { - condition: qbs.toolchain.contains("gcc") + condition: qbs.toolchain.includes("gcc") && qbs.architecture === "msp430" cpp.driverFlags: ["-mmcu=msp430f5529", "-nostdlib"] } Properties { - condition: qbs.toolchain.contains("gcc") + condition: qbs.toolchain.includes("gcc") && qbs.architecture === "m32r" cpp.driverFlags: ["-nostdlib"] } Properties { - condition: qbs.toolchain.contains("gcc") + condition: qbs.toolchain.includes("gcc") && qbs.architecture === "riscv" cpp.driverFlags: ["-nostdlib"] } diff --git a/tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/compiler-defines-by-language.qbs b/tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/compiler-defines-by-language.qbs index bfd10106d..73365ada4 100644 --- a/tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/compiler-defines-by-language.qbs +++ b/tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/compiler-defines-by-language.qbs @@ -2,11 +2,11 @@ import "../BareMetalApplication.qbs" as BareMetalApplication Project { property bool supportsCpp: { - if (qbs.toolchain.contains("cosmic")) + if (qbs.toolchain.includes("cosmic")) return false; - if (qbs.toolchain.contains("sdcc")) + if (qbs.toolchain.includes("sdcc")) return false; - if (qbs.toolchain.contains("keil")) { + if (qbs.toolchain.includes("keil")) { if (qbs.architecture === "mcs51" || qbs.architecture === "mcs251" || qbs.architecture === "c166") { @@ -38,6 +38,7 @@ Project { name: "cpp_language" files: ["app.c", "cpptest.cpp"] cpp.enableCompilerDefinesByLanguage: ["cpp"] + cpp.enableExceptions: false property var foo: { if (!cpp.compilerDefinesByLanguage) throw "ASSERT cpp.compilerDefinesByLanguage: " @@ -56,6 +57,7 @@ Project { name: "c_and_cpp_language" files: ["app.c", "ctest.c", "cpptest.cpp"] cpp.enableCompilerDefinesByLanguage: ["c", "cpp"] + cpp.enableExceptions: false property var foo: { if (!cpp.compilerDefinesByLanguage) throw "ASSERT cpp.compilerDefinesByLanguage: " diff --git a/tests/auto/blackbox/testdata-baremetal/compiler-listing/compiler-listing.qbs b/tests/auto/blackbox/testdata-baremetal/compiler-listing/compiler-listing.qbs index bcf983c88..6bd51e3bd 100644 --- a/tests/auto/blackbox/testdata-baremetal/compiler-listing/compiler-listing.qbs +++ b/tests/auto/blackbox/testdata-baremetal/compiler-listing/compiler-listing.qbs @@ -2,7 +2,7 @@ import "../BareMetalApplication.qbs" as BareMetalApplication BareMetalApplication { condition: { - if (!qbs.toolchain.contains("gcc")) { + if (!qbs.toolchain.includes("gcc")) { console.info("compiler listing suffix: %%" + cpp.compilerListingSuffix + "%%"); return true; } diff --git a/tests/auto/blackbox/testdata-baremetal/external-static-libraries/external-static-libraries.qbs b/tests/auto/blackbox/testdata-baremetal/external-static-libraries/external-static-libraries.qbs index fffb6a03d..7336e3970 100644 --- a/tests/auto/blackbox/testdata-baremetal/external-static-libraries/external-static-libraries.qbs +++ b/tests/auto/blackbox/testdata-baremetal/external-static-libraries/external-static-libraries.qbs @@ -2,13 +2,13 @@ import "../BareMetalApplication.qbs" as BareMetalApplication import "../BareMetalStaticLibrary.qbs" as BareMetalStaticLibrary Project { - property string outputLibrariesDirectory: sourceDirectory + "/libs" + property string outputLibrariesDirectory: buildDirectory + "/libs" BareMetalStaticLibrary { name: "lib-a" destinationDirectory: project.outputLibrariesDirectory Depends { name: "cpp" } Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } files: ["lib-a.c"] @@ -19,7 +19,7 @@ Project { Depends { name: "cpp" } Depends { name: "lib-a" } Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } files: ["lib-b.c"] diff --git a/tests/auto/blackbox/testdata-baremetal/shared-libraries/app.c b/tests/auto/blackbox/testdata-baremetal/shared-libraries/app.c new file mode 100644 index 000000000..f2ecb5f55 --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/shared-libraries/app.c @@ -0,0 +1,12 @@ +#include "../dllexport.h" + +#include <stdio.h> + +DLL_IMPORT void foo(void); + +int main(void) +{ + printf("Hello from app\n"); + foo(); + return 0; +} diff --git a/tests/auto/blackbox/testdata-baremetal/shared-libraries/shared-libraries.qbs b/tests/auto/blackbox/testdata-baremetal/shared-libraries/shared-libraries.qbs new file mode 100644 index 000000000..fded553f6 --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/shared-libraries/shared-libraries.qbs @@ -0,0 +1,32 @@ +import "../BareMetalApplication.qbs" as BareMetalApplication + +Project { + condition: { + if (qbs.targetPlatform === "windows" && qbs.architecture === "x86") { + if (qbs.toolchainType === "watcom") + return true; + if (qbs.toolchainType === "dmc") + return true; + } + + if (qbs.toolchainType === "msvc") + return true; + + console.info("unsupported toolset: %%" + + qbs.toolchainType + "%%, %%" + qbs.architecture + "%%"); + return false; + } + + DynamicLibrary { + Depends { name: "cpp" } + destinationDirectory: "bin" + name: "shared" + files: ["shared.c"] + } + BareMetalApplication { + Depends { name: "shared" } + destinationDirectory: "bin" + name: "app" + files: ["app.c"] + } +} diff --git a/tests/auto/blackbox/testdata-baremetal/shared-libraries/shared.c b/tests/auto/blackbox/testdata-baremetal/shared-libraries/shared.c new file mode 100644 index 000000000..ab0c110fb --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/shared-libraries/shared.c @@ -0,0 +1,19 @@ +#include "../dllexport.h" + +#include <stdio.h> + +#ifdef __DMC__ +#include <windows.h> +#define EXPORT_FUN _export +BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) +{ + return TRUE; +} +#else +#define EXPORT_FUN +#endif // __DMC__ + +DLL_EXPORT void EXPORT_FUN foo(void) +{ + printf("Hello from lib\n"); +} diff --git a/tests/auto/blackbox/testdata-baremetal/toolchain-probe/probes/dmc.qbs b/tests/auto/blackbox/testdata-baremetal/toolchain-probe/probes/dmc.qbs new file mode 100644 index 000000000..13f751669 --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/toolchain-probe/probes/dmc.qbs @@ -0,0 +1,31 @@ +import qbs.Probes + +Product { + id: product + condition: qbs.toolchainType === "dmc" + + Depends { name: "cpp" } + + Probes.DmcProbe { + id: probe + compilerFilePath: cpp.compilerPath + enableDefinesByLanguage: cpp.enableCompilerDefinesByLanguage + _targetPlatform: qbs.targetPlatform + _targetArchitecture: qbs.architecture + _targetExtender: cpp.extenderName + } + + property bool dummy: { + if (!product.condition) + return; + if (!probe.found + || !probe.compilerDefinesByLanguage + || !probe.includePaths + || (probe.includePaths.length === 0) + || (qbs.architecture !== probe.architecture) + || (qbs.targetPlatform !== probe.targetPlatform)) { + console.info("broken probe: %%" + qbs.toolchainType + "%%, %%" + + qbs.architecture + "%%"); + } + } +} diff --git a/tests/auto/blackbox/testdata-baremetal/toolchain-probe/probes/sdcc.qbs b/tests/auto/blackbox/testdata-baremetal/toolchain-probe/probes/sdcc.qbs new file mode 100644 index 000000000..fa5f519a9 --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/toolchain-probe/probes/sdcc.qbs @@ -0,0 +1,29 @@ +import qbs.Probes + +Product { + id: product + condition: qbs.toolchainType === "sdcc" + + Depends { name: "cpp" } + + Probes.SdccProbe { + id: probe + compilerFilePath: cpp.compilerPath + enableDefinesByLanguage: cpp.enableCompilerDefinesByLanguage + preferredArchitecture: qbs.architecture + } + + property bool dummy: { + if (!product.condition) + return; + if (!probe.found + || !probe.endianness + || !probe.compilerDefinesByLanguage + || !probe.includePaths + || (probe.includePaths.length === 0) + || (qbs.architecture !== probe.architecture)) { + console.info("broken probe: %%" + qbs.toolchainType + "%%, %%" + + qbs.architecture + "%%"); + } + } +} diff --git a/tests/auto/blackbox/testdata-baremetal/toolchain-probe/probes/watcom.qbs b/tests/auto/blackbox/testdata-baremetal/toolchain-probe/probes/watcom.qbs new file mode 100644 index 000000000..b7c92dc21 --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/toolchain-probe/probes/watcom.qbs @@ -0,0 +1,34 @@ +import qbs.Probes + +Product { + id: product + condition: qbs.toolchainType === "watcom" + + Depends { name: "cpp" } + + Probes.WatcomProbe { + id: probe + compilerFilePath: cpp.compilerPath + enableDefinesByLanguage: cpp.enableCompilerDefinesByLanguage + _pathListSeparator: qbs.pathListSeparator + _toolchainInstallPath: cpp.toolchainInstallPath + _targetPlatform: qbs.targetPlatform + _targetArchitecture: qbs.architecture + } + + property bool dummy: { + if (!product.condition) + return; + if (!probe.found + || !probe.endianness + || !probe.compilerDefinesByLanguage + || !probe.environment + || !probe.includePaths + || (probe.includePaths.length === 0) + || (qbs.architecture !== probe.architecture) + || (qbs.targetPlatform !== probe.targetPlatform)) { + console.info("broken probe: %%" + qbs.toolchainType + "%%, %%" + + qbs.architecture + "%%"); + } + } +} diff --git a/tests/auto/blackbox/testdata-baremetal/toolchain-probe/toolchain-probe.qbs b/tests/auto/blackbox/testdata-baremetal/toolchain-probe/toolchain-probe.qbs new file mode 100644 index 000000000..36725cfde --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/toolchain-probe/toolchain-probe.qbs @@ -0,0 +1,7 @@ +Project { + references: [ + "probes/dmc.qbs", + "probes/sdcc.qbs", + "probes/watcom.qbs", + ] +} diff --git a/tests/auto/blackbox/testdata-clangdb/project1/project.qbs b/tests/auto/blackbox/testdata-clangdb/project1/project.qbs index ecfc562b0..313f33ead 100644 --- a/tests/auto/blackbox/testdata-clangdb/project1/project.qbs +++ b/tests/auto/blackbox/testdata-clangdb/project1/project.qbs @@ -7,8 +7,8 @@ Project { Application { Probe { id: dummy - property bool isMingw: qbs.toolchain.contains("mingw") - property bool isMsvc: qbs.toolchain.contains("msvc") + property bool isMingw: qbs.toolchain.includes("mingw") + property bool isMsvc: qbs.toolchain.includes("msvc") property var buildEnv: cpp.buildEnv configure: { if (!buildEnv) diff --git a/tests/auto/blackbox/testdata-java/java/vehicles.qbs b/tests/auto/blackbox/testdata-java/java/vehicles.qbs index 633ee5abd..8a4bb732f 100644 --- a/tests/auto/blackbox/testdata-java/java/vehicles.qbs +++ b/tests/auto/blackbox/testdata-java/java/vehicles.qbs @@ -1,4 +1,5 @@ import qbs.FileInfo +import qbs.Host import qbs.Utilities Project { @@ -6,12 +7,12 @@ Project { Depends { name: "cpp" } Depends { name: "car_jar" } Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } property bool _testPlatform: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata-joblimits/job-limits-init/job-limits-init.qbs b/tests/auto/blackbox/testdata-joblimits/job-limits-init/job-limits-init.qbs index 9e387bc7f..3a0075530 100644 --- a/tests/auto/blackbox/testdata-joblimits/job-limits-init/job-limits-init.qbs +++ b/tests/auto/blackbox/testdata-joblimits/job-limits-init/job-limits-init.qbs @@ -1,6 +1,8 @@ +import qbs.Host + Product { property bool _testPlatform: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata-joblimits/job-limits/job-limits.qbs b/tests/auto/blackbox/testdata-joblimits/job-limits/job-limits.qbs index 221105a64..76f54807a 100644 --- a/tests/auto/blackbox/testdata-joblimits/job-limits/job-limits.qbs +++ b/tests/auto/blackbox/testdata-joblimits/job-limits/job-limits.qbs @@ -19,7 +19,7 @@ Project { consoleApplication: true cpp.cxxLanguageVersion: "c++14" Properties { - condition: qbs.targetOS.contains("macos") + condition: qbs.targetOS.includes("macos") cpp.minimumMacosVersion: "10.9" } files: "main.cpp" @@ -37,7 +37,7 @@ Project { var cmd = new Command(explicitlyDependsOn.tool_tag[0].filePath, [output.filePath]); cmd.workingDirectory = product.buildDirectory; - cmd.description = "Running tool"; + cmd.description = "running tool"; cmd.jobPool = "singleton"; return cmd; } diff --git a/tests/auto/blackbox/testdata-providers/allowed-values/allowed-values.qbs b/tests/auto/blackbox/testdata-providers/allowed-values/allowed-values.qbs new file mode 100644 index 000000000..e6dbaddde --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/allowed-values/allowed-values.qbs @@ -0,0 +1,4 @@ +Product { + Depends { name: "qbsmetatestmodule" } + qbsModuleProviders: "provider" +} diff --git a/tests/auto/blackbox/testdata-providers/allowed-values/module-providers/provider.qbs b/tests/auto/blackbox/testdata-providers/allowed-values/module-providers/provider.qbs new file mode 100644 index 000000000..c0e426c96 --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/allowed-values/module-providers/provider.qbs @@ -0,0 +1,14 @@ +import "../../qbs-module-providers-helpers.js" as Helpers + +ModuleProvider { + isEager: false + property stringList aProperty: "zero" + PropertyOptions { + name: "aProperty" + allowedValues: ["one", "two"] + } + relativeSearchPaths: { + Helpers.writeModule(outputBaseDir, moduleName, "from_provider"); + return ""; + } +} diff --git a/tests/auto/blackbox/testdata-providers/broken-provider/broken-provider.qbs b/tests/auto/blackbox/testdata-providers/broken-provider/broken-provider.qbs new file mode 100644 index 000000000..461c7e30e --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/broken-provider/broken-provider.qbs @@ -0,0 +1,13 @@ +Project { + qbsModuleProviders: "provider_a" + name: "project" + Project { + name: "innerProject" + Product { + name: "p1" + Depends { name: "qbsothermodule"; required: false } + Depends { name: "qbsmetatestmodule" } + } + } + +} diff --git a/tests/auto/blackbox/testdata-providers/broken-provider/module-providers/provider_a.qbs b/tests/auto/blackbox/testdata-providers/broken-provider/module-providers/provider_a.qbs new file mode 100644 index 000000000..f446d2d13 --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/broken-provider/module-providers/provider_a.qbs @@ -0,0 +1,5 @@ +ModuleProvider { + relativeSearchPaths: { + throw "This provider is broken"; + } +} diff --git a/tests/auto/blackbox/testdata-providers/conan-provider/conan-module-provider.qbs b/tests/auto/blackbox/testdata-providers/conan-provider/conan-module-provider.qbs new file mode 100644 index 000000000..e8880fc96 --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/conan-provider/conan-module-provider.qbs @@ -0,0 +1,11 @@ +CppApplication { + consoleApplication: true + name: "p" + files: "main.cpp" + qbsModuleProviders: "conan" + qbs.buildVariant: "release" + qbs.installPrefix: "" + install: true + Depends { name: "conanmoduleprovider.testlib" } + Depends { name: "conanmoduleprovider.testlibheader" } +} diff --git a/tests/auto/blackbox/testdata-providers/conan-provider/conanfile.txt b/tests/auto/blackbox/testdata-providers/conan-provider/conanfile.txt new file mode 100644 index 000000000..7c40ff7d6 --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/conan-provider/conanfile.txt @@ -0,0 +1,3 @@ +[requires] +conanmoduleprovider.testlib/1.2.3 +conanmoduleprovider.testlibheader/0.1.0 diff --git a/tests/auto/blackbox/testdata-providers/conan-provider/main.cpp b/tests/auto/blackbox/testdata-providers/conan-provider/main.cpp new file mode 100644 index 000000000..6250927b3 --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/conan-provider/main.cpp @@ -0,0 +1,8 @@ +#include <testlib.h> + +#include <header.h> + +int main() +{ + HelloWorld h(42 + hello()); +} diff --git a/tests/auto/blackbox/testdata-providers/conan-provider/testlib/CMakeLists.txt b/tests/auto/blackbox/testdata-providers/conan-provider/testlib/CMakeLists.txt new file mode 100644 index 000000000..d186d1906 --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/conan-provider/testlib/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.15) +project(conanmoduleprovider.testlib) + +find_package(conanmoduleprovider.testlibdep REQUIRED) + +add_library(${PROJECT_NAME} STATIC testlib.cpp) +set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "testlib.h") +target_link_libraries(${PROJECT_NAME} conanmoduleprovider.testlibdep::conanmoduleprovider.testlibdep) +install(TARGETS ${PROJECT_NAME}) diff --git a/tests/auto/blackbox/testdata-providers/conan-provider/testlib/conanfile.py b/tests/auto/blackbox/testdata-providers/conan-provider/testlib/conanfile.py new file mode 100644 index 000000000..7cb91f9ef --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/conan-provider/testlib/conanfile.py @@ -0,0 +1,36 @@ +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps +from conan.tools.files import collect_libs +import os + +class ConanModuleProviderTestlib(ConanFile): + name = "conanmoduleprovider.testlib" + license = "none" + version = "1.2.3" + + exports_sources = "*.cpp", "*.h", "CMakeLists.txt" + settings = "os", "compiler", "build_type", "arch" + + def requirements(self): + self.requires("conanmoduleprovider.testlibdep/1.2.3") + + def layout(self): + cmake_layout(self) + + def generate(self): + deps = CMakeDeps(self) + deps.generate() + tc = CMakeToolchain(self, generator="Ninja") + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = collect_libs(self) diff --git a/tests/auto/blackbox/testdata-providers/conan-provider/testlib/testlib.cpp b/tests/auto/blackbox/testdata-providers/conan-provider/testlib/testlib.cpp new file mode 100644 index 000000000..7118dfda9 --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/conan-provider/testlib/testlib.cpp @@ -0,0 +1,7 @@ +#include "testlib.h" + +#include <testlibdep.h> + +HelloWorld::HelloWorld(int x) + : m_x(foo(x)) +{} diff --git a/tests/auto/blackbox/testdata-providers/conan-provider/testlib/testlib.h b/tests/auto/blackbox/testdata-providers/conan-provider/testlib/testlib.h new file mode 100644 index 000000000..11a354b70 --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/conan-provider/testlib/testlib.h @@ -0,0 +1,10 @@ +#pragma once + +class HelloWorld +{ +public: + explicit HelloWorld(int x); + +private: + int m_x; +}; diff --git a/tests/auto/blackbox/testdata-providers/conan-provider/testlibdep/CMakeLists.txt b/tests/auto/blackbox/testdata-providers/conan-provider/testlibdep/CMakeLists.txt new file mode 100644 index 000000000..5510a9250 --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/conan-provider/testlibdep/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.15) +project(conanmoduleprovider.testlibdep) + +add_library(${PROJECT_NAME} STATIC testlibdep.cpp) +set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "testlibdep.h") +install(TARGETS ${PROJECT_NAME}) +install(FILES lorem_ipsum.txt DESTINATION share)
\ No newline at end of file diff --git a/tests/auto/blackbox/testdata-providers/conan-provider/testlibdep/conanfile.py b/tests/auto/blackbox/testdata-providers/conan-provider/testlibdep/conanfile.py new file mode 100644 index 000000000..f2c577c5e --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/conan-provider/testlibdep/conanfile.py @@ -0,0 +1,35 @@ +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps +from conan.tools.files import collect_libs, copy +import os + +class ConanModuleProviderTestlib(ConanFile): + name = "conanmoduleprovider.testlibdep" + license = "none" + version = "1.2.3" + + exports_sources = "*.cpp", "*.h", "*.txt" + settings = "os", "compiler", "build_type", "arch" + + def layout(self): + cmake_layout(self) + + def generate(self): + deps = CMakeDeps(self) + deps.generate() + tc = CMakeToolchain(self, generator="Ninja") + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = collect_libs(self) + self.cpp_info.resdirs = ['share'] + diff --git a/tests/auto/blackbox/testdata-providers/conan-provider/testlibdep/lorem_ipsum.txt b/tests/auto/blackbox/testdata-providers/conan-provider/testlibdep/lorem_ipsum.txt new file mode 100644 index 000000000..d8634396c --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/conan-provider/testlibdep/lorem_ipsum.txt @@ -0,0 +1 @@ +Lorem ipsum dolor sit amet, consectetur adipiscing elit.
\ No newline at end of file diff --git a/tests/auto/blackbox/testdata-providers/conan-provider/testlibdep/testlibdep.cpp b/tests/auto/blackbox/testdata-providers/conan-provider/testlibdep/testlibdep.cpp new file mode 100644 index 000000000..893478c82 --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/conan-provider/testlibdep/testlibdep.cpp @@ -0,0 +1,6 @@ +#include "testlibdep.h" + +int foo(int i) +{ + return i * i; +}
\ No newline at end of file diff --git a/tests/auto/blackbox/testdata-providers/conan-provider/testlibdep/testlibdep.h b/tests/auto/blackbox/testdata-providers/conan-provider/testlibdep/testlibdep.h new file mode 100644 index 000000000..ca7bd3cbc --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/conan-provider/testlibdep/testlibdep.h @@ -0,0 +1,3 @@ +#pragma once + +int foo(int i);
\ No newline at end of file diff --git a/tests/auto/blackbox/testdata-providers/conan-provider/testlibheader/conanfile.py b/tests/auto/blackbox/testdata-providers/conan-provider/testlibheader/conanfile.py new file mode 100644 index 000000000..6078b9750 --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/conan-provider/testlibheader/conanfile.py @@ -0,0 +1,15 @@ +from conan import ConanFile +from conan.tools.files import copy + +import os + +class Recipe(ConanFile): + exports_sources = ("header.h") + version = '0.1.0' + name = 'conanmoduleprovider.testlibheader' + + def package(self): + copy(self, + "header.h", + src=self.source_folder, + dst=os.path.join(self.package_folder, "include"))
\ No newline at end of file diff --git a/tests/auto/blackbox/testdata-providers/conan-provider/testlibheader/header.h b/tests/auto/blackbox/testdata-providers/conan-provider/testlibheader/header.h new file mode 100644 index 000000000..66bd50d57 --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/conan-provider/testlibheader/header.h @@ -0,0 +1,6 @@ +#pragma once + +inline int hello() +{ + return 0; +}
\ No newline at end of file diff --git a/tests/auto/blackbox/testdata/fallback-module-provider/fallback-module-provider.qbs b/tests/auto/blackbox/testdata-providers/fallback-module-provider/fallback-module-provider.qbs index a798e15b3..a798e15b3 100644 --- a/tests/auto/blackbox/testdata/fallback-module-provider/fallback-module-provider.qbs +++ b/tests/auto/blackbox/testdata-providers/fallback-module-provider/fallback-module-provider.qbs diff --git a/tests/auto/blackbox/testdata/fallback-module-provider/libdir/qbsmetatestmodule.pc b/tests/auto/blackbox/testdata-providers/fallback-module-provider/libdir/qbsmetatestmodule.pc index ae4daba89..ae4daba89 100644 --- a/tests/auto/blackbox/testdata/fallback-module-provider/libdir/qbsmetatestmodule.pc +++ b/tests/auto/blackbox/testdata-providers/fallback-module-provider/libdir/qbsmetatestmodule.pc diff --git a/tests/auto/blackbox/testdata/fallback-module-provider/main.cpp b/tests/auto/blackbox/testdata-providers/fallback-module-provider/main.cpp index 442b755bf..442b755bf 100644 --- a/tests/auto/blackbox/testdata/fallback-module-provider/main.cpp +++ b/tests/auto/blackbox/testdata-providers/fallback-module-provider/main.cpp diff --git a/tests/auto/blackbox/testdata-providers/module-providers-cache/module-providers-cache.qbs b/tests/auto/blackbox/testdata-providers/module-providers-cache/module-providers-cache.qbs new file mode 100644 index 000000000..508ed84d2 --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/module-providers-cache/module-providers-cache.qbs @@ -0,0 +1,11 @@ +Project { + qbsModuleProviders: ["provider_a"] + name: "project" + property string dummyProp + + Product { + name: "p1" + Depends { name: "qbsothermodule" } + Depends { name: "qbsmetatestmodule" } + } +} diff --git a/tests/auto/blackbox/testdata-providers/module-providers-cache/module-providers/provider_a.qbs b/tests/auto/blackbox/testdata-providers/module-providers-cache/module-providers/provider_a.qbs new file mode 100644 index 000000000..782cf7d25 --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/module-providers-cache/module-providers/provider_a.qbs @@ -0,0 +1,9 @@ +import "../../qbs-module-providers-helpers.js" as Helpers + +ModuleProvider { + relativeSearchPaths: { + Helpers.writeModule(outputBaseDir, "qbsmetatestmodule", "from_provider_a"); + Helpers.writeModule(outputBaseDir, "qbsothermodule", "from_provider_a"); + return ""; + } +} diff --git a/tests/auto/blackbox/testdata/module-providers/main.cpp b/tests/auto/blackbox/testdata-providers/module-providers/main.cpp index 85a4f551c..85a4f551c 100644 --- a/tests/auto/blackbox/testdata/module-providers/main.cpp +++ b/tests/auto/blackbox/testdata-providers/module-providers/main.cpp diff --git a/tests/auto/blackbox/testdata/module-providers/module-providers.qbs b/tests/auto/blackbox/testdata-providers/module-providers/module-providers.qbs index 781a3ca03..89bd1a11d 100644 --- a/tests/auto/blackbox/testdata/module-providers/module-providers.qbs +++ b/tests/auto/blackbox/testdata-providers/module-providers/module-providers.qbs @@ -1,6 +1,8 @@ +import qbs.Host + Project { property bool enabled: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; @@ -8,10 +10,11 @@ Project { readonly property string beginning: "beginning" CppApplication { name: "app1" + property string chooseLettersFrom: project.beginning // This indirection tests QBS-1747. Depends { name: "mygenerator.module1" } Depends { name: "mygenerator.module2" } Depends { name: "othergenerator" } - moduleProviders.mygenerator.chooseLettersFrom: project.beginning + moduleProviders.mygenerator.chooseLettersFrom: chooseLettersFrom moduleProviders.othergenerator.someDefines: name files: "main.cpp" } diff --git a/tests/auto/blackbox/testdata/module-providers/module-providers/mygenerator/provider.qbs b/tests/auto/blackbox/testdata-providers/module-providers/module-providers/mygenerator/provider.qbs index dae02c03a..dae02c03a 100644 --- a/tests/auto/blackbox/testdata/module-providers/module-providers/mygenerator/provider.qbs +++ b/tests/auto/blackbox/testdata-providers/module-providers/module-providers/mygenerator/provider.qbs diff --git a/tests/auto/blackbox/testdata/module-providers/module-providers/othergenerator/provider.qbs b/tests/auto/blackbox/testdata-providers/module-providers/module-providers/othergenerator/provider.qbs index 66557037c..66557037c 100644 --- a/tests/auto/blackbox/testdata/module-providers/module-providers/othergenerator/provider.qbs +++ b/tests/auto/blackbox/testdata-providers/module-providers/module-providers/othergenerator/provider.qbs diff --git a/tests/auto/blackbox/testdata-providers/non-eager-provider/module-providers/provider_a.qbs b/tests/auto/blackbox/testdata-providers/non-eager-provider/module-providers/provider_a.qbs new file mode 100644 index 000000000..6cd9177db --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/non-eager-provider/module-providers/provider_a.qbs @@ -0,0 +1,11 @@ +import "../../qbs-module-providers-helpers.js" as Helpers + +ModuleProvider { + isEager: false + relativeSearchPaths: { + if (moduleName === "nonexistentmodule") + return undefined; + Helpers.writeModule(outputBaseDir, moduleName, "from_provider_a"); + return ""; + } +} diff --git a/tests/auto/blackbox/testdata-providers/non-eager-provider/non-eager-provider.qbs b/tests/auto/blackbox/testdata-providers/non-eager-provider/non-eager-provider.qbs new file mode 100644 index 000000000..bd3662de3 --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/non-eager-provider/non-eager-provider.qbs @@ -0,0 +1,13 @@ +Project { + Product { + name: "p1" + Depends { name: "qbsmetatestmodule" } + Depends { name: "qbsothermodule" } + Depends { name: "nonexistentmodule"; required: false } + property bool dummy: { + console.info("p1.qbsmetatestmodule.prop: " + qbsmetatestmodule.prop); + console.info("p1.qbsothermodule.prop: " + qbsothermodule.prop); + } + qbsModuleProviders: "provider_a" + } +} diff --git a/tests/auto/blackbox/testdata-providers/probe-in-module-provider/module-providers/provider_a.qbs b/tests/auto/blackbox/testdata-providers/probe-in-module-provider/module-providers/provider_a.qbs new file mode 100644 index 000000000..476a83143 --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/probe-in-module-provider/module-providers/provider_a.qbs @@ -0,0 +1,23 @@ +import "../../qbs-module-providers-helpers.js" as Helpers + +ModuleProvider { + property string sysroot: qbs.sysroot + Probe { + id: theProbe + property string theValue: "value" + property string dummy: sysroot + configure: { + console.info("Running probe with irrelevant value '" + dummy + "'"); + found = true; + } + } + isEager: false + property bool found: theProbe.found + property string theValue: theProbe.theValue + relativeSearchPaths: { + Helpers.writeModule(outputBaseDir, "qbsmetatestmodule", theValue, undefined, found); + if (sysroot !== qbs.sysroot) + throw "this is unexpected"; + return ""; + } +} diff --git a/tests/auto/blackbox/testdata-providers/probe-in-module-provider/probe-in-module-provider.qbs b/tests/auto/blackbox/testdata-providers/probe-in-module-provider/probe-in-module-provider.qbs new file mode 100644 index 000000000..1f2b3d387 --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/probe-in-module-provider/probe-in-module-provider.qbs @@ -0,0 +1,9 @@ +Product { + qbsModuleProviders: ["provider_a"] + name: "p" + Depends { name: "qbsmetatestmodule" } + property bool dummy: { + console.info("p.qbsmetatestmodule.boolProp: " + JSON.stringify(qbsmetatestmodule.boolProp)); + console.info("p.qbsmetatestmodule.prop: " + JSON.stringify(qbsmetatestmodule.prop)); + } +} diff --git a/tests/auto/blackbox/testdata/providers-properties/module-providers/provider_a.qbs b/tests/auto/blackbox/testdata-providers/providers-properties/module-providers/provider_a.qbs index ab9d475d8..ab9d475d8 100644 --- a/tests/auto/blackbox/testdata/providers-properties/module-providers/provider_a.qbs +++ b/tests/auto/blackbox/testdata-providers/providers-properties/module-providers/provider_a.qbs diff --git a/tests/auto/blackbox/testdata/providers-properties/module-providers/provider_b.qbs b/tests/auto/blackbox/testdata-providers/providers-properties/module-providers/provider_b.qbs index 1b2a79979..1b2a79979 100644 --- a/tests/auto/blackbox/testdata/providers-properties/module-providers/provider_b.qbs +++ b/tests/auto/blackbox/testdata-providers/providers-properties/module-providers/provider_b.qbs diff --git a/tests/auto/blackbox/testdata/providers-properties/providers-properties.qbs b/tests/auto/blackbox/testdata-providers/providers-properties/providers-properties.qbs index 258a973fa..258a973fa 100644 --- a/tests/auto/blackbox/testdata/providers-properties/providers-properties.qbs +++ b/tests/auto/blackbox/testdata-providers/providers-properties/providers-properties.qbs diff --git a/tests/auto/blackbox/testdata-providers/qbs-module-properties-in-providers/module-providers/provider_a.qbs b/tests/auto/blackbox/testdata-providers/qbs-module-properties-in-providers/module-providers/provider_a.qbs new file mode 100644 index 000000000..95c89cd1c --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/qbs-module-properties-in-providers/module-providers/provider_a.qbs @@ -0,0 +1,9 @@ +import "../../qbs-module-providers-helpers.js" as Helpers + +ModuleProvider { + property string sysroot: qbs.sysroot + relativeSearchPaths: { + Helpers.writeModule(outputBaseDir, "qbsmetatestmodule", sysroot); + return ""; + } +} diff --git a/tests/auto/blackbox/testdata-providers/qbs-module-properties-in-providers/qbs-module-properties-in-providers.qbs b/tests/auto/blackbox/testdata-providers/qbs-module-properties-in-providers/qbs-module-properties-in-providers.qbs new file mode 100644 index 000000000..c2fc58299 --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/qbs-module-properties-in-providers/qbs-module-properties-in-providers.qbs @@ -0,0 +1,34 @@ +Project { + qbsModuleProviders: "provider_a" + name: "project" + + Profile { + name: "profile1" + qbs.sysroot: "/sysroot1" + } + + Profile { + name: "profile2" + qbs.sysroot: "/sysroot2" + } + + Product { + name: "product1" + Depends { name: "qbsmetatestmodule" } + property bool dummy: { + console.info("product1.qbsmetatestmodule.prop: " + qbsmetatestmodule.prop); + } + // multiplex over profiles, sysroot should not be cached + qbs.profiles: ["profile1", "profile2"] + } + + Product { + name: "product2" + Depends { name: "qbsmetatestmodule" } + property bool dummy: { + console.info("product2.qbsmetatestmodule.prop: " + qbsmetatestmodule.prop); + } + // multiplex over profiles, sysroot should not be cached + qbs.profiles: ["profile1", "profile2"] + } +} diff --git a/tests/auto/blackbox/testdata/qbs-module-providers-cli-override/module-providers/provider_a.qbs b/tests/auto/blackbox/testdata-providers/qbs-module-providers-cli-override/module-providers/provider_a.qbs index d34d1cac5..d34d1cac5 100644 --- a/tests/auto/blackbox/testdata/qbs-module-providers-cli-override/module-providers/provider_a.qbs +++ b/tests/auto/blackbox/testdata-providers/qbs-module-providers-cli-override/module-providers/provider_a.qbs diff --git a/tests/auto/blackbox/testdata/qbs-module-providers-cli-override/module-providers/provider_b.qbs b/tests/auto/blackbox/testdata-providers/qbs-module-providers-cli-override/module-providers/provider_b.qbs index 767e30923..767e30923 100644 --- a/tests/auto/blackbox/testdata/qbs-module-providers-cli-override/module-providers/provider_b.qbs +++ b/tests/auto/blackbox/testdata-providers/qbs-module-providers-cli-override/module-providers/provider_b.qbs diff --git a/tests/auto/blackbox/testdata/qbs-module-providers-cli-override/qbs-module-providers-cli-override.qbs b/tests/auto/blackbox/testdata-providers/qbs-module-providers-cli-override/qbs-module-providers-cli-override.qbs index 6f94ab207..6f94ab207 100644 --- a/tests/auto/blackbox/testdata/qbs-module-providers-cli-override/qbs-module-providers-cli-override.qbs +++ b/tests/auto/blackbox/testdata-providers/qbs-module-providers-cli-override/qbs-module-providers-cli-override.qbs diff --git a/tests/auto/blackbox/testdata/qbs-module-providers-compatibility/module-providers/named_provider.qbs b/tests/auto/blackbox/testdata-providers/qbs-module-providers-compatibility/module-providers/named_provider.qbs index 07114b5ef..07114b5ef 100644 --- a/tests/auto/blackbox/testdata/qbs-module-providers-compatibility/module-providers/named_provider.qbs +++ b/tests/auto/blackbox/testdata-providers/qbs-module-providers-compatibility/module-providers/named_provider.qbs diff --git a/tests/auto/blackbox/testdata/qbs-module-providers-compatibility/module-providers/qbsmetatestmodule/provider.qbs b/tests/auto/blackbox/testdata-providers/qbs-module-providers-compatibility/module-providers/qbsmetatestmodule/provider.qbs index b04a52261..b04a52261 100644 --- a/tests/auto/blackbox/testdata/qbs-module-providers-compatibility/module-providers/qbsmetatestmodule/provider.qbs +++ b/tests/auto/blackbox/testdata-providers/qbs-module-providers-compatibility/module-providers/qbsmetatestmodule/provider.qbs diff --git a/tests/auto/blackbox/testdata/qbs-module-providers-compatibility/qbs-module-providers-compatibility.qbs b/tests/auto/blackbox/testdata-providers/qbs-module-providers-compatibility/qbs-module-providers-compatibility.qbs index 7885b540a..7885b540a 100644 --- a/tests/auto/blackbox/testdata/qbs-module-providers-compatibility/qbs-module-providers-compatibility.qbs +++ b/tests/auto/blackbox/testdata-providers/qbs-module-providers-compatibility/qbs-module-providers-compatibility.qbs diff --git a/tests/auto/blackbox/testdata/qbs-module-providers-helpers.js b/tests/auto/blackbox/testdata-providers/qbs-module-providers-helpers.js index b33b87329..8b6d9e275 100644 --- a/tests/auto/blackbox/testdata/qbs-module-providers-helpers.js +++ b/tests/auto/blackbox/testdata-providers/qbs-module-providers-helpers.js @@ -3,7 +3,7 @@ var FileInfo = require("qbs.FileInfo"); var TextFile = require("qbs.TextFile"); var ModUtils = require("qbs.ModUtils"); -function writeModule(outputBaseDir, name, prop, listProp) { +function writeModule(outputBaseDir, name, prop, listProp, boolProp) { console.info("Running setup script for " + name); var moduleDir = FileInfo.joinPaths(outputBaseDir, "modules", name); File.makePath(moduleDir); @@ -14,6 +14,10 @@ function writeModule(outputBaseDir, name, prop, listProp) { module.writeLine(" property stringList listProp: " + ModUtils.toJSLiteral(listProp)); } + if (boolProp) { + module.writeLine(" property bool boolProp: " + + ModUtils.toJSLiteral(boolProp)); + } module.writeLine("}"); module.close(); } diff --git a/tests/auto/blackbox/testdata/qbs-module-providers/module-providers/provider_a.qbs b/tests/auto/blackbox/testdata-providers/qbs-module-providers/module-providers/provider_a.qbs index d34d1cac5..d34d1cac5 100644 --- a/tests/auto/blackbox/testdata/qbs-module-providers/module-providers/provider_a.qbs +++ b/tests/auto/blackbox/testdata-providers/qbs-module-providers/module-providers/provider_a.qbs diff --git a/tests/auto/blackbox/testdata/qbs-module-providers/module-providers/provider_b.qbs b/tests/auto/blackbox/testdata-providers/qbs-module-providers/module-providers/provider_b.qbs index 767e30923..767e30923 100644 --- a/tests/auto/blackbox/testdata/qbs-module-providers/module-providers/provider_b.qbs +++ b/tests/auto/blackbox/testdata-providers/qbs-module-providers/module-providers/provider_b.qbs diff --git a/tests/auto/blackbox/testdata/qbs-module-providers/qbs-module-providers.qbs b/tests/auto/blackbox/testdata-providers/qbs-module-providers/qbs-module-providers.qbs index 00776a62e..00776a62e 100644 --- a/tests/auto/blackbox/testdata/qbs-module-providers/qbs-module-providers.qbs +++ b/tests/auto/blackbox/testdata-providers/qbs-module-providers/qbs-module-providers.qbs diff --git a/tests/auto/blackbox/testdata/qbspkgconfig-module-provider/libs/libA.cpp b/tests/auto/blackbox/testdata-providers/qbspkgconfig-module-provider/libs/libA.cpp index 0c5274415..0c5274415 100644 --- a/tests/auto/blackbox/testdata/qbspkgconfig-module-provider/libs/libA.cpp +++ b/tests/auto/blackbox/testdata-providers/qbspkgconfig-module-provider/libs/libA.cpp diff --git a/tests/auto/blackbox/testdata/qbspkgconfig-module-provider/libs/libA.h b/tests/auto/blackbox/testdata-providers/qbspkgconfig-module-provider/libs/libA.h index ddaaf1609..ddaaf1609 100644 --- a/tests/auto/blackbox/testdata/qbspkgconfig-module-provider/libs/libA.h +++ b/tests/auto/blackbox/testdata-providers/qbspkgconfig-module-provider/libs/libA.h diff --git a/tests/auto/blackbox/testdata/qbspkgconfig-module-provider/libs/libs.qbs b/tests/auto/blackbox/testdata-providers/qbspkgconfig-module-provider/libs/libs.qbs index 9d482415b..b473083c6 100644 --- a/tests/auto/blackbox/testdata/qbspkgconfig-module-provider/libs/libs.qbs +++ b/tests/auto/blackbox/testdata-providers/qbspkgconfig-module-provider/libs/libs.qbs @@ -6,6 +6,8 @@ Project { DynamicLibrary { Depends { name: "cpp" } Depends { name: "bundle" } + Depends { name: "Exporter.pkgconfig" } + Exporter.pkgconfig.versionEntry: "1.0" name: "libA" bundle.isBundle: project.isBundle bundle.publicHeaders: ["libA.h"] @@ -16,7 +18,7 @@ Project { result.push("MYLIB_FRAMEWORK"); return result; } - qbs.installPrefix: "" + qbs.installPrefix: "/usr" install: true installImportLib: true installDir: "lib" @@ -25,5 +27,16 @@ Project { qbs.install: !project.isBundle qbs.installDir: FileInfo.joinPaths("include", product.name) } + Group { + fileTagsFilter: ["Exporter.pkgconfig.pc"] + qbs.install: !project.isBundle + qbs.installDir: FileInfo.joinPaths("share", "pkgconfig") + } + Export { + Depends { name: "cpp" } + cpp.defines: ["THE_MAGIC_DEFINE"] + cpp.includePaths: [FileInfo.joinPaths(exportingProduct.qbs.installPrefix, "include")] + cpp.libraryPaths: [FileInfo.joinPaths(exportingProduct.qbs.installPrefix, "lib")] + } } } diff --git a/tests/auto/blackbox/testdata/qbspkgconfig-module-provider/main.cpp b/tests/auto/blackbox/testdata-providers/qbspkgconfig-module-provider/main.cpp index 5fa0f7eed..5fa0f7eed 100644 --- a/tests/auto/blackbox/testdata/qbspkgconfig-module-provider/main.cpp +++ b/tests/auto/blackbox/testdata-providers/qbspkgconfig-module-provider/main.cpp diff --git a/tests/auto/blackbox/testdata/qbspkgconfig-module-provider/qbspkgconfig-module-provider.qbs b/tests/auto/blackbox/testdata-providers/qbspkgconfig-module-provider/qbspkgconfig-module-provider.qbs index d2b3654ae..d2b3654ae 100644 --- a/tests/auto/blackbox/testdata/qbspkgconfig-module-provider/qbspkgconfig-module-provider.qbs +++ b/tests/auto/blackbox/testdata-providers/qbspkgconfig-module-provider/qbspkgconfig-module-provider.qbs diff --git a/tests/auto/blackbox/testdata-providers/removal-version/module-providers/provider_a.qbs b/tests/auto/blackbox/testdata-providers/removal-version/module-providers/provider_a.qbs new file mode 100644 index 000000000..7f358acbc --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/removal-version/module-providers/provider_a.qbs @@ -0,0 +1,14 @@ +import "../../qbs-module-providers-helpers.js" as Helpers + +ModuleProvider { + isEager: false + property bool deprecated: false + PropertyOptions { + name: "deprecated" + removalVersion: "2.2.0" + } + relativeSearchPaths: { + Helpers.writeModule(outputBaseDir, moduleName, "from_provider_a"); + return ""; + } +} diff --git a/tests/auto/blackbox/testdata-providers/removal-version/removal-version.qbs b/tests/auto/blackbox/testdata-providers/removal-version/removal-version.qbs new file mode 100644 index 000000000..1aa5e2ce9 --- /dev/null +++ b/tests/auto/blackbox/testdata-providers/removal-version/removal-version.qbs @@ -0,0 +1,12 @@ +Project { + qbsModuleProviders: "provider_a" + name: "project" + Project { + name: "innerProject" + Product { + name: "p1" + Depends { name: "qbsmetatestmodule" } + } + } + +} diff --git a/tests/auto/blackbox/testdata-qt/auto-qrc/auto-qrc.qbs b/tests/auto/blackbox/testdata-qt/auto-qrc/auto-qrc.qbs index 92b290719..bdbf8b2a1 100644 --- a/tests/auto/blackbox/testdata-qt/auto-qrc/auto-qrc.qbs +++ b/tests/auto/blackbox/testdata-qt/auto-qrc/auto-qrc.qbs @@ -1,7 +1,9 @@ +import qbs.Host + Project { QtApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata-qt/forced-moc/forced-moc.qbs b/tests/auto/blackbox/testdata-qt/forced-moc/forced-moc.qbs index aab7ed220..064470a79 100644 --- a/tests/auto/blackbox/testdata-qt/forced-moc/forced-moc.qbs +++ b/tests/auto/blackbox/testdata-qt/forced-moc/forced-moc.qbs @@ -1,3 +1,4 @@ +import qbs.Host import qbs.Utilities QtApplication { @@ -6,7 +7,7 @@ QtApplication { console.info("using qt4"); return false; } - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata-qt/linker-variant/qt-linker-variant.qbs b/tests/auto/blackbox/testdata-qt/linker-variant/qt-linker-variant.qbs index ab5889007..c1a77d696 100644 --- a/tests/auto/blackbox/testdata-qt/linker-variant/qt-linker-variant.qbs +++ b/tests/auto/blackbox/testdata-qt/linker-variant/qt-linker-variant.qbs @@ -3,7 +3,7 @@ QtApplication { id: qtConfigProbe property stringList moduleConfig: Qt.core.moduleConfig configure: { - console.info("Qt requires gold: " + moduleConfig.contains("use_gold_linker")); + console.info("Qt requires gold: " + moduleConfig.includes("use_gold_linker")); } } files: "main.cpp" diff --git a/tests/auto/blackbox/testdata-qt/mixed-build-variants/mixed-build-variants.qbs b/tests/auto/blackbox/testdata-qt/mixed-build-variants/mixed-build-variants.qbs index 7d8ab1b90..dea30eef4 100644 --- a/tests/auto/blackbox/testdata-qt/mixed-build-variants/mixed-build-variants.qbs +++ b/tests/auto/blackbox/testdata-qt/mixed-build-variants/mixed-build-variants.qbs @@ -1,6 +1,6 @@ QtApplication { Properties { - condition: qbs.toolchain.contains("msvc") + condition: qbs.toolchain.includes("msvc") Qt.core.qtBuildVariant: "release" } Qt.core.qtBuildVariant: "dummy" diff --git a/tests/auto/blackbox/testdata-qt/no-relink-on-qdebug/lib.cpp b/tests/auto/blackbox/testdata-qt/no-relink-on-qdebug/lib.cpp new file mode 100644 index 000000000..675960f2d --- /dev/null +++ b/tests/auto/blackbox/testdata-qt/no-relink-on-qdebug/lib.cpp @@ -0,0 +1,8 @@ +#include <QtDebug> + +#include "lib.h" + +SymbolsTest::SymbolsTest() +{ + // qDebug() << "hallo"; +} diff --git a/tests/auto/blackbox/testdata-qt/no-relink-on-qdebug/lib.h b/tests/auto/blackbox/testdata-qt/no-relink-on-qdebug/lib.h new file mode 100644 index 000000000..0cb4a23c4 --- /dev/null +++ b/tests/auto/blackbox/testdata-qt/no-relink-on-qdebug/lib.h @@ -0,0 +1,18 @@ +#ifndef SYMBOLSTEST_H +#define SYMBOLSTEST_H + +#include <QtCore/qglobal.h> + +#if defined(SYMBOLSTEST_LIBRARY) +# define SYMBOLSTEST_EXPORT Q_DECL_EXPORT +#else +# define SYMBOLSTEST_EXPORT Q_DECL_IMPORT +#endif + +class SYMBOLSTEST_EXPORT SymbolsTest +{ + public: + SymbolsTest(); +}; + +#endif // SYMBOLSTEST_H diff --git a/tests/auto/blackbox/testdata-qt/no-relink-on-qdebug/main.cpp b/tests/auto/blackbox/testdata-qt/no-relink-on-qdebug/main.cpp new file mode 100644 index 000000000..5047a34e3 --- /dev/null +++ b/tests/auto/blackbox/testdata-qt/no-relink-on-qdebug/main.cpp @@ -0,0 +1,3 @@ +int main() +{ +} diff --git a/tests/auto/blackbox/testdata-qt/no-relink-on-qdebug/symbols-test.qbs b/tests/auto/blackbox/testdata-qt/no-relink-on-qdebug/symbols-test.qbs new file mode 100644 index 000000000..a614d96c4 --- /dev/null +++ b/tests/auto/blackbox/testdata-qt/no-relink-on-qdebug/symbols-test.qbs @@ -0,0 +1,27 @@ +Project { + CppApplication { + name: "app" + Depends { name: "lib" } + property bool dummy: { + console.info("is GCC: " + qbs.toolchain.includes("gcc")); + console.info("is MinGW: " + qbs.toolchain.includes("mingw")); + console.info("is Darwin: " + qbs.targetOS.includes("darwin")); + } + files: "main.cpp" + } + + DynamicLibrary { + name: "lib" + Depends { name: "Qt.core" } + + cpp.cxxLanguageVersion: "c++11" + cpp.defines: "SYMBOLSTEST_LIBRARY" + + files: [ + "lib.cpp", + "lib.h", + ] + + Export { Depends { name: "Qt.core" } } + } +} 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-qt/pkgconfig/pkgconfig.qbs b/tests/auto/blackbox/testdata-qt/pkgconfig/pkgconfig.qbs index 87ec6dc7d..b2d411154 100644 --- a/tests/auto/blackbox/testdata-qt/pkgconfig/pkgconfig.qbs +++ b/tests/auto/blackbox/testdata-qt/pkgconfig/pkgconfig.qbs @@ -1,10 +1,11 @@ +import qbs.Host import qbs.Probes Project { property string name: 'pkgconfig' CppApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata-qt/plugin-meta-data/plugin-meta-data.qbs b/tests/auto/blackbox/testdata-qt/plugin-meta-data/plugin-meta-data.qbs index 7e5f98340..dbe64d5ea 100644 --- a/tests/auto/blackbox/testdata-qt/plugin-meta-data/plugin-meta-data.qbs +++ b/tests/auto/blackbox/testdata-qt/plugin-meta-data/plugin-meta-data.qbs @@ -1,3 +1,4 @@ +import qbs.Host import qbs.Utilities Project { @@ -8,7 +9,7 @@ Project { console.info("using qt4"); return false; } - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; @@ -22,7 +23,7 @@ Project { cpp.cxxLanguageVersion: "c++11" Properties { - condition: qbs.targetOS.contains("unix") + condition: qbs.targetOS.includes("unix") cpp.rpaths: [cpp.rpathOrigin] } @@ -42,12 +43,12 @@ Project { Depends { name: "Qt.core" } Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } cpp.defines: [Qt.core.staticBuild ? "QT_STATICPLUGIN" : "QT_PLUGIN"] cpp.cxxLanguageVersion: "c++11" - cpp.sonamePrefix: qbs.targetOS.contains("darwin") ? "@rpath" : undefined + cpp.sonamePrefix: qbs.targetOS.includes("darwin") ? "@rpath" : undefined cpp.includePaths: ["."] Qt.core.pluginMetaData: ["theKey=theValue"] diff --git a/tests/auto/blackbox/testdata-qt/qdoc/qdoc.qbs b/tests/auto/blackbox/testdata-qt/qdoc/qdoc.qbs new file mode 100644 index 000000000..4b82bc405 --- /dev/null +++ b/tests/auto/blackbox/testdata-qt/qdoc/qdoc.qbs @@ -0,0 +1,22 @@ +import qbs.Utilities + +Product { + condition: { + var ok = Utilities.versionCompare(Qt.core.version, "5.0.0") >= 0; + if (!ok) + console.info("Qt is too old"); + return ok; + } + name: "QDoc Test" + type: ["qdoc-html", "qch"] + + Depends { name: "Qt.core" } + + files: ["qdoc.qdoc"] + + Group { + name: "main qdocconf file" + files: "qdoc.qdocconf" + fileTags: "qdocconf-main" + } +} diff --git a/tests/auto/blackbox/testdata-qt/qdoc/qdoc.qdoc b/tests/auto/blackbox/testdata-qt/qdoc/qdoc.qdoc new file mode 100644 index 000000000..9e44e0948 --- /dev/null +++ b/tests/auto/blackbox/testdata-qt/qdoc/qdoc.qdoc @@ -0,0 +1,7 @@ +/*! + \page index.html + + \title QDoc Test + + QDoc Test is a test for QDoc. +*/
\ No newline at end of file diff --git a/tests/auto/blackbox/testdata-qt/qdoc/qdoc.qdocconf b/tests/auto/blackbox/testdata-qt/qdoc/qdoc.qdocconf new file mode 100644 index 000000000..8c82bb575 --- /dev/null +++ b/tests/auto/blackbox/testdata-qt/qdoc/qdoc.qdocconf @@ -0,0 +1,13 @@ +project = QDoc Test +description = QDoc Test + +headerdirs = . +sourcedirs = . +exampledirs = . + +outputdir = doc/html + +qhp.projects = QDocTest +qhp.QDocTest.file = qdoctest.qhp +qhp.QDocTest.namespace = org.qt-project.QDocTest +qhp.QDocTest.virtualFolder = doc diff --git a/tests/auto/blackbox/testdata-qt/qml-debugging/qml-debugging.qbs b/tests/auto/blackbox/testdata-qt/qml-debugging/qml-debugging.qbs index 8176a7c3e..0885e6b0b 100644 --- a/tests/auto/blackbox/testdata-qt/qml-debugging/qml-debugging.qbs +++ b/tests/auto/blackbox/testdata-qt/qml-debugging/qml-debugging.qbs @@ -4,4 +4,9 @@ QtApplication { Depends { name: "Qt.quick" } Qt.quick.qmlDebugging: true files: "main.cpp" + Probe { + id: checker + property bool isGcc: qbs.toolchain.contains("gcc") + configure: { console.info("is gcc: " + isGcc); } + } } diff --git a/tests/auto/blackbox/testdata-qt/qrc/i.qbs b/tests/auto/blackbox/testdata-qt/qrc/i.qbs index e98c069b5..45275106d 100644 --- a/tests/auto/blackbox/testdata-qt/qrc/i.qbs +++ b/tests/auto/blackbox/testdata-qt/qrc/i.qbs @@ -1,3 +1,4 @@ +import qbs.Host import qbs.Utilities Project { @@ -7,7 +8,7 @@ Project { console.info("using qt4"); return false; } - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata-qt/qtscxml/qtscxml.qbs b/tests/auto/blackbox/testdata-qt/qtscxml/qtscxml.qbs index 90b968ec9..6fee91479 100644 --- a/tests/auto/blackbox/testdata-qt/qtscxml/qtscxml.qbs +++ b/tests/auto/blackbox/testdata-qt/qtscxml/qtscxml.qbs @@ -1,5 +1,6 @@ import qbs.Environment import qbs.FileInfo +import qbs.Host import qbs.Utilities Project { @@ -25,7 +26,7 @@ Project { Product { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; @@ -41,9 +42,9 @@ Project { cmd.description = "running " + input.filePath; var envVars = {}; - if (product.qbs.hostOS.contains("windows")) { + if (Host.os().includes("windows")) { envVars["PATH"] = FileInfo.toWindowsSeparators(input["Qt.core"].binPath); - } else if (product.qbs.hostOS.contains("macos")) { + } else if (Host.os().includes("macos")) { envVars["DYLD_LIBRARY_PATH"] = input["Qt.core"].libPath; envVars["DYLD_FRAMEWORK_PATH"] = input["Qt.core"].libPath; } else { @@ -51,7 +52,7 @@ Project { } for (var varName in envVars) { var oldValue = Environment.getEnv(varName) || ""; - var newValue = envVars[varName] + product.qbs.pathListSeparator + oldValue; + var newValue = envVars[varName] + FileInfo.pathListSeparator() + oldValue; cmd.environment.push(varName + '=' + newValue); } diff --git a/tests/auto/blackbox/testdata-qt/static-qt-plugin-linking/static-qt-plugin-linking.qbs b/tests/auto/blackbox/testdata-qt/static-qt-plugin-linking/static-qt-plugin-linking.qbs index a9608c001..e4e56bb4b 100644 --- a/tests/auto/blackbox/testdata-qt/static-qt-plugin-linking/static-qt-plugin-linking.qbs +++ b/tests/auto/blackbox/testdata-qt/static-qt-plugin-linking/static-qt-plugin-linking.qbs @@ -11,12 +11,12 @@ Product { } Group { - condition: type.contains("application") + condition: type.includes("application") files: "main.cpp" } Group { - condition: type.contains("staticlibrary") + condition: type.includes("staticlibrary") files: "lib.cpp" } diff --git a/tests/auto/blackbox/testdata-windows/codesign/codesign.qbs b/tests/auto/blackbox/testdata-windows/codesign/codesign.qbs index f9f49e636..1963f6926 100644 --- a/tests/auto/blackbox/testdata-windows/codesign/codesign.qbs +++ b/tests/auto/blackbox/testdata-windows/codesign/codesign.qbs @@ -9,7 +9,7 @@ Project { CppApplication { name: "A" files: "app.cpp" - condition: qbs.toolchain.contains("msvc") + condition: qbs.toolchain.includes("msvc") codesign.enableCodeSigning: project.enableSigning codesign.hashAlgorithm: project.hashAlgorithm codesign.subjectName: project.subjectName @@ -27,7 +27,7 @@ Project { Depends { name: "cpp" } name: "B" files: "app.cpp" - condition: qbs.toolchain.contains("msvc") + condition: qbs.toolchain.includes("msvc") codesign.enableCodeSigning: project.enableSigning codesign.hashAlgorithm: project.hashAlgorithm codesign.subjectName: project.subjectName diff --git a/tests/auto/blackbox/testdata-windows/innosetup/innosetup.qbs b/tests/auto/blackbox/testdata-windows/innosetup/innosetup.qbs index 718dec6f5..fd8868900 100644 --- a/tests/auto/blackbox/testdata-windows/innosetup/innosetup.qbs +++ b/tests/auto/blackbox/testdata-windows/innosetup/innosetup.qbs @@ -3,7 +3,7 @@ import qbs.FileInfo Project { InnoSetup { property bool _test: { - var present = qbs.targetOS.contains("windows") && innosetup.present; + var present = qbs.targetOS.includes("windows") && innosetup.present; console.info("has innosetup: " + present); } diff --git a/tests/auto/blackbox/testdata-windows/innosetupDependencies/innosetupDependencies.qbs b/tests/auto/blackbox/testdata-windows/innosetupDependencies/innosetupDependencies.qbs index ab68d3011..3ef8c30e7 100644 --- a/tests/auto/blackbox/testdata-windows/innosetupDependencies/innosetupDependencies.qbs +++ b/tests/auto/blackbox/testdata-windows/innosetupDependencies/innosetupDependencies.qbs @@ -3,7 +3,7 @@ import qbs.TextFile Project { InnoSetup { property bool _test: { - var present = qbs.targetOS.contains("windows") && innosetup.present; + var present = qbs.targetOS.includes("windows") && innosetup.present; console.info("has innosetup: " + present); } Depends { name: "app" } diff --git a/tests/auto/blackbox/testdata-windows/wix/WiXInstallers.qbs b/tests/auto/blackbox/testdata-windows/wix/WiXInstallers.qbs index 7e1dbf5e3..acc7cf7b3 100644 --- a/tests/auto/blackbox/testdata-windows/wix/WiXInstallers.qbs +++ b/tests/auto/blackbox/testdata-windows/wix/WiXInstallers.qbs @@ -1,4 +1,5 @@ import qbs.FileInfo +import qbs.Host Project { WindowsInstallerPackage { @@ -19,7 +20,7 @@ Project { WindowsSetupPackage { Depends { name: "QbsSetup" } - condition: qbs.hostOS.contains("windows") // currently does not work in Wine with WiX 3.9 + condition: Host.os().includes("windows") // currently does not work in Wine with WiX 3.9 name: "QbsBootstrapper" targetName: "qbs-setup-" + qbs.architecture files: ["QbsBootstrapper.wxs"] diff --git a/tests/auto/blackbox/testdata/assembly/assembly.qbs b/tests/auto/blackbox/testdata/assembly/assembly.qbs index f7bd4ecad..9d5584af5 100644 --- a/tests/auto/blackbox/testdata/assembly/assembly.qbs +++ b/tests/auto/blackbox/testdata/assembly/assembly.qbs @@ -30,9 +30,9 @@ Project { name : "testa" files : [ "testa.s" ] Depends { name: "cpp" } - condition: qbs.toolchain.contains("gcc") + condition: qbs.toolchain.includes("gcc") Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } } @@ -40,9 +40,9 @@ Project { name : "testb" files : [ "testb.S" ] Depends { name: "cpp" } - condition: qbs.toolchain.contains("gcc") + condition: qbs.toolchain.includes("gcc") Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } } @@ -50,9 +50,9 @@ Project { name : "testc" files : [ "testc.sx" ] Depends { name: "cpp" } - condition: qbs.toolchain.contains("gcc") + condition: qbs.toolchain.includes("gcc") Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } } @@ -63,10 +63,10 @@ Project { files: ["testd_" + qbs.architecture + ".asm"] } Depends { name: "cpp" } - condition: qbs.toolchain.contains("msvc") + condition: qbs.toolchain.includes("msvc") && (qbs.architecture === "x86" || qbs.architecture === "x86_64") Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } } diff --git a/tests/auto/blackbox/testdata/autotest-timeout/autotests-timeout.qbs b/tests/auto/blackbox/testdata/autotest-timeout/autotests-timeout.qbs index 8ae4f3ceb..b6094ed22 100644 --- a/tests/auto/blackbox/testdata/autotest-timeout/autotests-timeout.qbs +++ b/tests/auto/blackbox/testdata/autotest-timeout/autotests-timeout.qbs @@ -1,7 +1,9 @@ +import qbs.Host + Project { CppApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; @@ -12,7 +14,7 @@ Project { cpp.cxxLanguageVersion: "c++11" cpp.minimumOsxVersion: "10.8" // For <chrono> Properties { - condition: qbs.toolchain.contains("gcc") + condition: qbs.toolchain.includes("gcc") cpp.driverFlags: "-pthread" } files: "test-main.cpp" @@ -20,7 +22,7 @@ Project { AutotestRunner { Depends { name: "cpp" // Make sure build environment is set up properly. - condition: qbs.hostOS.contains("windows") && qbs.toolchain.contains("gcc") + condition: Host.os().includes("windows") && qbs.toolchain.includes("gcc") } } } diff --git a/tests/auto/blackbox/testdata/autotest-with-dependencies/autotest-with-dependencies.qbs b/tests/auto/blackbox/testdata/autotest-with-dependencies/autotest-with-dependencies.qbs index b64473526..bea74796a 100644 --- a/tests/auto/blackbox/testdata/autotest-with-dependencies/autotest-with-dependencies.qbs +++ b/tests/auto/blackbox/testdata/autotest-with-dependencies/autotest-with-dependencies.qbs @@ -1,9 +1,10 @@ import qbs.FileInfo +import qbs.Host Project { CppApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; @@ -29,7 +30,7 @@ Project { AutotestRunner { Depends { name: "cpp" // Make sure build environment is set up properly. - condition: qbs.hostOS.contains("windows") && qbs.toolchain.contains("gcc") + condition: Host.os().includes("windows") && qbs.toolchain.includes("gcc") } arguments: FileInfo.joinPaths(qbs.installRoot, qbs.installPrefix, "bin") auxiliaryInputs: "test-helper" diff --git a/tests/auto/blackbox/testdata/autotests/autotests.qbs b/tests/auto/blackbox/testdata/autotests/autotests.qbs index 4927a8869..cfb7fc560 100644 --- a/tests/auto/blackbox/testdata/autotests/autotests.qbs +++ b/tests/auto/blackbox/testdata/autotests/autotests.qbs @@ -1,15 +1,17 @@ +import qbs.Host + Project { references: ["test1", "test2", "test3"] AutotestRunner { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; } Depends { name: "cpp" // Make sure build environment is set up properly. - condition: qbs.hostOS.contains("windows") && qbs.toolchain.contains("gcc") + condition: Host.os().includes("windows") && qbs.toolchain.includes("gcc") } } } diff --git a/tests/auto/blackbox/testdata/badInterpreter/badInterpreter.qbs b/tests/auto/blackbox/testdata/badInterpreter/badInterpreter.qbs index 2317e6edf..3c8f64c6c 100644 --- a/tests/auto/blackbox/testdata/badInterpreter/badInterpreter.qbs +++ b/tests/auto/blackbox/testdata/badInterpreter/badInterpreter.qbs @@ -1,6 +1,8 @@ +import qbs.Host + Project { property bool enabled: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata/buildenv-change/buildenv-change.qbs b/tests/auto/blackbox/testdata/buildenv-change/buildenv-change.qbs index 6c0bcc73e..54005e76a 100644 --- a/tests/auto/blackbox/testdata/buildenv-change/buildenv-change.qbs +++ b/tests/auto/blackbox/testdata/buildenv-change/buildenv-change.qbs @@ -3,7 +3,7 @@ CppApplication { id: dummy property stringList toolchain: qbs.toolchain configure: { - if (toolchain.contains("msvc")) + if (toolchain.includes("msvc")) console.info("msvc"); } } diff --git a/tests/auto/blackbox/testdata/capnproto/capnproto_absolute_import.qbs b/tests/auto/blackbox/testdata/capnproto/capnproto_absolute_import.qbs index ee0903f73..4674d6a6a 100644 --- a/tests/auto/blackbox/testdata/capnproto/capnproto_absolute_import.qbs +++ b/tests/auto/blackbox/testdata/capnproto/capnproto_absolute_import.qbs @@ -1,7 +1,9 @@ +import qbs.Host + CppApplication { Depends { name: "capnproto.cpp"; required: false } condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); if (!capnproto.cpp.present) @@ -15,4 +17,5 @@ CppApplication { "capnproto_absolute_import.cpp", "imports/foo.capnp", ] + qbs.buildVariant: "release" } diff --git a/tests/auto/blackbox/testdata/capnproto/capnproto_cpp.qbs b/tests/auto/blackbox/testdata/capnproto/capnproto_cpp.qbs index d7ee1b4c9..9f287e906 100644 --- a/tests/auto/blackbox/testdata/capnproto/capnproto_cpp.qbs +++ b/tests/auto/blackbox/testdata/capnproto/capnproto_cpp.qbs @@ -1,7 +1,9 @@ +import qbs.Host + CppApplication { Depends { name: "capnproto.cpp"; required: false } condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); if (!capnproto.cpp.present) @@ -13,4 +15,5 @@ CppApplication { "capnproto_cpp.cpp", "foo.capnp" ] + qbs.buildVariant: "release" } diff --git a/tests/auto/blackbox/testdata/capnproto/capnproto_cpp_pkgconfig.qbs b/tests/auto/blackbox/testdata/capnproto/capnproto_cpp_pkgconfig.qbs deleted file mode 100644 index 58c7d568d..000000000 --- a/tests/auto/blackbox/testdata/capnproto/capnproto_cpp_pkgconfig.qbs +++ /dev/null @@ -1,17 +0,0 @@ -CppApplication { - Depends { name: "capnproto.cpp"; required: false } - condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; - if (!result) - console.info("targetPlatform differs from hostPlatform"); - if (!capnproto.cpp.present) - console.info("capnproto is not present"); - return result && capnproto.cpp.present; - } - cpp.minimumMacosVersion: "10.8" - files: [ - "capnproto_cpp.cpp", - "foo.capnp" - ] - qbsModuleProviders: "qbspkgconfig" -}
\ No newline at end of file diff --git a/tests/auto/blackbox/testdata/capnproto/capnproto_relative_import.qbs b/tests/auto/blackbox/testdata/capnproto/capnproto_relative_import.qbs index 7c1991d8f..333a3cdb9 100644 --- a/tests/auto/blackbox/testdata/capnproto/capnproto_relative_import.qbs +++ b/tests/auto/blackbox/testdata/capnproto/capnproto_relative_import.qbs @@ -1,7 +1,9 @@ +import qbs.Host + CppApplication { Depends { name: "capnproto.cpp"; required: false } condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); if (!capnproto.cpp.present) diff --git a/tests/auto/blackbox/testdata/capnproto/conanfile.txt b/tests/auto/blackbox/testdata/capnproto/conanfile.txt new file mode 100644 index 000000000..7313bb82e --- /dev/null +++ b/tests/auto/blackbox/testdata/capnproto/conanfile.txt @@ -0,0 +1,6 @@ +[requires] +capnproto/1.0.2 +[tool_requires] +capnproto/1.0.2 +[generators] +QbsDeps diff --git a/tests/auto/blackbox/testdata/capnproto/greeter_cpp.qbs b/tests/auto/blackbox/testdata/capnproto/greeter_cpp.qbs index cf95b968b..5fc5464b1 100644 --- a/tests/auto/blackbox/testdata/capnproto/greeter_cpp.qbs +++ b/tests/auto/blackbox/testdata/capnproto/greeter_cpp.qbs @@ -1,8 +1,10 @@ +import qbs.Host + Project { CppApplication { Depends { name: "capnproto.cpp"; required: false } condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); if (!capnproto.cpp.present) @@ -12,11 +14,14 @@ Project { name: "server" consoleApplication: true cpp.minimumMacosVersion: "10.8" + // workaround for broken capnproto + cpp.staticLibraries: qbs.targetOS.contains("windows") ? "Advapi32" : [] capnproto.cpp.useRpc: true files: [ "greeter.capnp", "greeter-server.cpp" ] + qbs.buildVariant: "release" } CppApplication { Depends { name: "capnproto.cpp"; required: false } @@ -24,9 +29,11 @@ Project { consoleApplication: true capnproto.cpp.useRpc: true cpp.minimumMacosVersion: "10.8" + cpp.staticLibraries: qbs.targetOS.contains("windows") ? "Advapi32" : [] files: [ "greeter.capnp", "greeter-client.cpp" ] + qbs.buildVariant: "release" } } diff --git a/tests/auto/blackbox/testdata/change-in-imported-file/change-in-imported-file.qbs b/tests/auto/blackbox/testdata/change-in-imported-file/change-in-imported-file.qbs index cf5354268..011eedc91 100644 --- a/tests/auto/blackbox/testdata/change-in-imported-file/change-in-imported-file.qbs +++ b/tests/auto/blackbox/testdata/change-in-imported-file/change-in-imported-file.qbs @@ -15,7 +15,7 @@ Product { prepare: { var cmd = new JavaScriptCommand(); PrepareHelper.prepare(cmd); - cmd.description = "Creating output"; + cmd.description = "creating output"; return [cmd]; } } diff --git a/tests/auto/blackbox/testdata/change-tracking-and-multiplexing/change-tracking-and-multiplexing.qbs b/tests/auto/blackbox/testdata/change-tracking-and-multiplexing/change-tracking-and-multiplexing.qbs index d1215355c..096778cd3 100644 --- a/tests/auto/blackbox/testdata/change-tracking-and-multiplexing/change-tracking-and-multiplexing.qbs +++ b/tests/auto/blackbox/testdata/change-tracking-and-multiplexing/change-tracking-and-multiplexing.qbs @@ -1,8 +1,8 @@ StaticLibrary { name: "l" - Depends { condition: qbs.targetOS.contains("darwin"); name: "bundle" } - Properties { condition: qbs.targetOS.contains("darwin"); bundle.isBundle: false } + Depends { condition: qbs.targetOS.includes("darwin"); name: "bundle" } + Properties { condition: qbs.targetOS.includes("darwin"); bundle.isBundle: false } multiplexByQbsProperties: ["buildVariants"] qbs.buildVariants: ["debug", "release"] diff --git a/tests/auto/blackbox/testdata/choose-module-instance/other-searchpath/modules/limerick/generic.qbs b/tests/auto/blackbox/testdata/choose-module-instance/other-searchpath/modules/limerick/generic.qbs index 2ebaaac11..bd8e901c7 100644 --- a/tests/auto/blackbox/testdata/choose-module-instance/other-searchpath/modules/limerick/generic.qbs +++ b/tests/auto/blackbox/testdata/choose-module-instance/other-searchpath/modules/limerick/generic.qbs @@ -1,3 +1,3 @@ Module { - condition: !qbs.targetOS.contains("Beatles") + condition: !qbs.targetOS.includes("Beatles") } diff --git a/tests/auto/blackbox/testdata/clean/clean.qbs b/tests/auto/blackbox/testdata/clean/clean.qbs index ce3a8eb12..10eca2d41 100644 --- a/tests/auto/blackbox/testdata/clean/clean.qbs +++ b/tests/auto/blackbox/testdata/clean/clean.qbs @@ -5,7 +5,7 @@ Project { name: "dep" files: "dep.cpp" Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } } diff --git a/tests/auto/blackbox/testdata/cli/dotnettest.qbs b/tests/auto/blackbox/testdata/cli/dotnettest.qbs index 9a10b8068..5685be8c4 100644 --- a/tests/auto/blackbox/testdata/cli/dotnettest.qbs +++ b/tests/auto/blackbox/testdata/cli/dotnettest.qbs @@ -1,7 +1,7 @@ Project { Application { Depends { name: "cli" } - Depends { name: "HelloWorldModule"; condition: !qbs.toolchain.contains("mono") } + Depends { name: "HelloWorldModule"; condition: !qbs.toolchain.includes("mono") } Depends { name: "NetLib" } type: "application" @@ -16,7 +16,7 @@ Project { // Mono's VB compiler doesn't support modules yet, and if we try with C#, it crashes anyways NetModule { - condition: !qbs.toolchain.contains("mono") + condition: !qbs.toolchain.includes("mono") Depends { name: "cli" } name: "HelloWorldModule" @@ -37,7 +37,7 @@ Project { // fill-in for missing NetModule Group { - condition: qbs.toolchain.contains("mono") + condition: qbs.toolchain.includes("mono") files: ["Module.cs"] } diff --git a/tests/auto/blackbox/testdata/command-file/command-file.qbs b/tests/auto/blackbox/testdata/command-file/command-file.qbs index 8e25221c5..87dd0e054 100644 --- a/tests/auto/blackbox/testdata/command-file/command-file.qbs +++ b/tests/auto/blackbox/testdata/command-file/command-file.qbs @@ -4,7 +4,7 @@ Project { destinationDirectory: project.buildDirectory Depends { name: "cpp" } Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } files: ["lib.cpp"] @@ -14,6 +14,6 @@ Project { cpp.libraryPaths: project.buildDirectory files: ["main.cpp"] cpp.staticLibraries: ['@' + sourceDirectory + '/' - + (qbs.toolchain.contains("msvc") ? "list.msvc" : "list.gcc")] + + (qbs.toolchain.includes("msvc") ? "list.msvc" : "list.gcc")] } } diff --git a/tests/auto/blackbox/testdata/compilerDefinesByLanguage/CppDefinesApp.qbs b/tests/auto/blackbox/testdata/compilerDefinesByLanguage/CppDefinesApp.qbs index b205ef2a7..f2da212f6 100644 --- a/tests/auto/blackbox/testdata/compilerDefinesByLanguage/CppDefinesApp.qbs +++ b/tests/auto/blackbox/testdata/compilerDefinesByLanguage/CppDefinesApp.qbs @@ -1,7 +1,7 @@ CppApplication { files: ["app.c"] - property bool enableObjectiveC: qbs.targetOS.contains("darwin") + property bool enableObjectiveC: qbs.targetOS.includes("darwin") Group { name: "C/C++" 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/concurrent-executor/concurrent-executor.qbs b/tests/auto/blackbox/testdata/concurrent-executor/concurrent-executor.qbs deleted file mode 100644 index 802aa1450..000000000 --- a/tests/auto/blackbox/testdata/concurrent-executor/concurrent-executor.qbs +++ /dev/null @@ -1,67 +0,0 @@ -import qbs.File -import qbs.TextFile -import "util.js" as Utils - -Product { - type: ["final1", "final2"] - Group { - files: ["dummy1.input"] - fileTags: ["input1"] - } - Group { - files: ["dummy2.input"] - fileTags: ["input2"] - } - Rule { - inputs: ["input1"] - Artifact { - filePath: project.buildDirectory + "/dummy1.final" - fileTags: ["final1"] - } - prepare: { - var cmds = []; - for (var i = 0; i < 10; ++i) { - var cmd = new JavaScriptCommand(); - cmd.silent = true; - cmd.createFile = i == 9; - cmd.sourceCode = function() { - if (createFile) { - console.info("Creating file"); - var file = new TextFile(output.filePath, TextFile.WriteOnly); - file.close(); - } - }; - cmds.push(cmd); - } - return cmds; - } - } - Rule { - inputs: ["input2"] - Artifact { - filePath: "dummy.intermediate" - fileTags: ["intermediate"] - } - prepare: { - var cmd = new JavaScriptCommand(); - cmd.silent = true; - cmd.sourceCode = function() { }; - return [cmd]; - } - } - Rule { - inputs: ["intermediate"] - outputFileTags: "final2" - prepare: { - do - Utils.sleep(6000); - while (!File.exists(project.buildDirectory + "/dummy1.final")); - var cmd = new JavaScriptCommand(); - cmd.silent = true; - cmd.sourceCode = function() { }; - return [cmd]; - } - } -} - - diff --git a/tests/auto/blackbox/testdata/concurrent-executor/util.js b/tests/auto/blackbox/testdata/concurrent-executor/util.js deleted file mode 100644 index a37a8cbb1..000000000 --- a/tests/auto/blackbox/testdata/concurrent-executor/util.js +++ /dev/null @@ -1,8 +0,0 @@ -function sleep(timeInMs) -{ - var referenceTime = new Date(); - var time = null; - do { - time = new Date(); - } while (time - referenceTime < timeInMs); -} diff --git a/tests/auto/blackbox/testdata/configure/configure.qbs b/tests/auto/blackbox/testdata/configure/configure.qbs index 62dfa4ce4..be0e65247 100644 --- a/tests/auto/blackbox/testdata/configure/configure.qbs +++ b/tests/auto/blackbox/testdata/configure/configure.qbs @@ -1,8 +1,9 @@ import qbs.FileInfo +import qbs.Host Project { property bool enabled: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata/configure/modules/definition/module.qbs b/tests/auto/blackbox/testdata/configure/modules/definition/module.qbs index 1d647faa2..6a1dbe67d 100644 --- a/tests/auto/blackbox/testdata/configure/modules/definition/module.qbs +++ b/tests/auto/blackbox/testdata/configure/modules/definition/module.qbs @@ -12,7 +12,7 @@ Module { var cmd; var args; var p = path; - if (targetOS.contains("windows")) { + if (targetOS.includes("windows")) { cmd = windowsShellPath; args = ["/c", "date", "/t"]; } else { diff --git a/tests/auto/blackbox/testdata/conflicting-property-values/conflicting-property-values.qbs b/tests/auto/blackbox/testdata/conflicting-property-values/conflicting-property-values.qbs new file mode 100644 index 000000000..23b6ee5a3 --- /dev/null +++ b/tests/auto/blackbox/testdata/conflicting-property-values/conflicting-property-values.qbs @@ -0,0 +1,41 @@ +Project { + Product { + name: "low" + Export { property string prop: "low"; property string prop2: "low" } + } + Product { + name: "higher1" + Export { Depends { name: "low" } low.prop: "higher1" } + } + Product { + name: "higher2" + Export { Depends { name: "low" } low.prop: "higher2" } + } + Product { + name: "highest1" + Export { + Depends { name: "low" } + Depends { name: "higher1" } + Depends { name: "higher2" } + low.prop: "highest1" + low.prop2: "highest" + } + } + Product { + name: "highest2" + Export { + Depends { name: "low" } + Depends { name: "higher1" } + Depends { name: "higher2" } + low.prop: "highest2" + low.prop2: "highest" + } + } + Product { + name: "toplevel" + Depends { name: "highest1" } + Depends { name: "highest2" } + low.prop: name + property bool dummy: { console.info("final prop value: " + low.prop); } + } +} diff --git a/tests/auto/blackbox/testdata/cpu-features/cpu-features.qbs b/tests/auto/blackbox/testdata/cpu-features/cpu-features.qbs index 0bfdaceba..36e805516 100644 --- a/tests/auto/blackbox/testdata/cpu-features/cpu-features.qbs +++ b/tests/auto/blackbox/testdata/cpu-features/cpu-features.qbs @@ -8,7 +8,7 @@ CppApplication { property bool dummy: { console.info("is x86: " + (qbs.architecture === "x86")); console.info("is x64: " + (qbs.architecture === "x86_64")); - console.info("is gcc: " + qbs.toolchain.contains("gcc")); - console.info("is msvc: " + qbs.toolchain.contains("msvc")); + console.info("is gcc: " + qbs.toolchain.includes("gcc")); + console.info("is msvc: " + qbs.toolchain.includes("msvc")); } } diff --git a/tests/auto/blackbox/testdata/cxx-language-version/cxx-language-version.qbs b/tests/auto/blackbox/testdata/cxx-language-version/cxx-language-version.qbs index 322ded85c..24c37951c 100644 --- a/tests/auto/blackbox/testdata/cxx-language-version/cxx-language-version.qbs +++ b/tests/auto/blackbox/testdata/cxx-language-version/cxx-language-version.qbs @@ -13,10 +13,10 @@ CppApplication { var isEvenNewerMsvc; var isOlderMsvc; var isGcc; - if (toolchain.contains("clang-cl")) { + if (toolchain.includes("clang-cl")) { isEvenNewerMsvc = true; isNewerMsvc = true; - } else if (toolchain.contains("msvc")) { + } else if (toolchain.includes("msvc")) { if (compilerVersion >= "19.12.25831") isEvenNewerMsvc = true; if (compilerVersion >= "18.00.30723") diff --git a/tests/auto/blackbox/testdata/date-property/date-property.qbs b/tests/auto/blackbox/testdata/date-property/date-property.qbs new file mode 100644 index 000000000..ffd584802 --- /dev/null +++ b/tests/auto/blackbox/testdata/date-property/date-property.qbs @@ -0,0 +1,18 @@ +Product { + type: "date" + property var theDate: new Date(1999, 11, 31); + Rule { + multiplex: true + Artifact { filePath: "dummy"; fileTags: "date" } + prepare: { + var cmd = new JavaScriptCommand; + cmd.silent = true; + cmd.sourceCode = function() { + var d = product.theDate; + console.info("The stored date was " + d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + + d.getDate()); + }; + return cmd; + } + } +} diff --git a/tests/auto/blackbox/testdata/dependenciesProperty/dependenciesProperty.qbs b/tests/auto/blackbox/testdata/dependenciesProperty/dependenciesProperty.qbs index 735bfffbc..681ffeab0 100644 --- a/tests/auto/blackbox/testdata/dependenciesProperty/dependenciesProperty.qbs +++ b/tests/auto/blackbox/testdata/dependenciesProperty/dependenciesProperty.qbs @@ -18,7 +18,7 @@ Project { } prepare: { var cmd = new JavaScriptCommand(); - cmd.description = 'generate ' + FileInfo.fileName(output.filePath); + cmd.description = 'generating ' + FileInfo.fileName(output.filePath); cmd.highlight = 'codegen'; cmd.sourceCode = function() { file = new TextFile(output.filePath, TextFile.WriteOnly); diff --git a/tests/auto/blackbox/testdata/deprecated-property/deprecated-property.qbs b/tests/auto/blackbox/testdata/deprecated-property/deprecated-property.qbs index e3dacffea..7d1550312 100644 --- a/tests/auto/blackbox/testdata/deprecated-property/deprecated-property.qbs +++ b/tests/auto/blackbox/testdata/deprecated-property/deprecated-property.qbs @@ -1,8 +1,6 @@ -import qbs // FIXME: Don't remove this import because then the test fails! - Product { Depends { name: "themodule" } themodule.newProp: true - themodule.oldProp: false + themodule.expiringProp: false themodule.veryOldProp: false } diff --git a/tests/auto/blackbox/testdata/deprecated-property/modules/themodule/m.qbs b/tests/auto/blackbox/testdata/deprecated-property/modules/themodule/m.qbs index cd6b0b70c..58164e918 100644 --- a/tests/auto/blackbox/testdata/deprecated-property/modules/themodule/m.qbs +++ b/tests/auto/blackbox/testdata/deprecated-property/modules/themodule/m.qbs @@ -1,8 +1,8 @@ -import qbs // FIXME: Don't remove this import because then the test fails! +import qbs.Environment Module { property bool newProp - property bool oldProp + property bool expiringProp property bool forgottenProp PropertyOptions { @@ -10,9 +10,9 @@ Module { description: "Use this, it's good!" } PropertyOptions { - name: "oldProp" + name: "expiringProp" description: "Use newProp instead." - removalVersion: "99.9" + removalVersion: Environment.getEnv("REMOVAL_VERSION") } PropertyOptions { name: "veryOldProp" diff --git a/tests/auto/blackbox/testdata/disappeared-profile/modules-dir/modules/m/m.qbs b/tests/auto/blackbox/testdata/disappeared-profile/modules-dir/modules/m/m.qbs index 3e1747ade..fd755ce86 100644 --- a/tests/auto/blackbox/testdata/disappeared-profile/modules-dir/modules/m/m.qbs +++ b/tests/auto/blackbox/testdata/disappeared-profile/modules-dir/modules/m/m.qbs @@ -10,7 +10,7 @@ Module { } prepare: { var cmd = new JavaScriptCommand(); - cmd.description = "Creating " + output.fileName + " with " + product.m.p1; + cmd.description = "creating " + output.fileName + " with " + product.m.p1; cmd.sourceCode = function() {}; return [cmd]; } @@ -24,7 +24,7 @@ Module { } prepare: { var cmd = new JavaScriptCommand(); - cmd.description = "Creating " + output.fileName + " with " + product.m.p2; + cmd.description = "creating " + output.fileName + " with " + product.m.p2; cmd.sourceCode = function() {}; return [cmd]; } diff --git a/tests/auto/blackbox/testdata/discard-unused-data/discard-unused-data.qbs b/tests/auto/blackbox/testdata/discard-unused-data/discard-unused-data.qbs index fdd3aa1f7..367bb665c 100644 --- a/tests/auto/blackbox/testdata/discard-unused-data/discard-unused-data.qbs +++ b/tests/auto/blackbox/testdata/discard-unused-data/discard-unused-data.qbs @@ -4,9 +4,9 @@ CppApplication { files: "main.cpp" - Depends { name: "bundle"; condition: qbs.targetOS.contains("darwin") } + Depends { name: "bundle"; condition: qbs.targetOS.includes("darwin") } Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } @@ -17,7 +17,7 @@ CppApplication { var cmd = new JavaScriptCommand(); cmd.silent = true; cmd.sourceCode = function() { - console.info("is Darwin: " + product.qbs.targetOS.contains("darwin")); + console.info("is Darwin: " + product.qbs.targetOS.includes("darwin")); console.info("---" + product.cpp.nmPath + "---"); } return [cmd]; diff --git a/tests/auto/blackbox/testdata/distribution-include-paths/main.cpp b/tests/auto/blackbox/testdata/distribution-include-paths/main.cpp index e449173d3..10d376a31 100644 --- a/tests/auto/blackbox/testdata/distribution-include-paths/main.cpp +++ b/tests/auto/blackbox/testdata/distribution-include-paths/main.cpp @@ -1,4 +1,4 @@ -#include <stdio.h> +#include <cstdio> #include <gagagugu.h> int main() diff --git a/tests/auto/blackbox/testdata/dot-dot-pc-file/dot-dot-pc-file.qbs b/tests/auto/blackbox/testdata/dot-dot-pc-file/dot-dot-pc-file.qbs new file mode 100644 index 000000000..60c4ea2bc --- /dev/null +++ b/tests/auto/blackbox/testdata/dot-dot-pc-file/dot-dot-pc-file.qbs @@ -0,0 +1,7 @@ +CppApplication { + name: "p" + Depends { name: "qbs-metatest-module"; } + files: "main.cpp" + moduleProviders.qbspkgconfig.libDirs: "libdir" + qbsModuleProviders: "qbspkgconfig" +} diff --git a/tests/auto/blackbox/testdata/dot-dot-pc-file/libdir/qbs.metatest.module.pc b/tests/auto/blackbox/testdata/dot-dot-pc-file/libdir/qbs.metatest.module.pc new file mode 100644 index 000000000..c00fd26d6 --- /dev/null +++ b/tests/auto/blackbox/testdata/dot-dot-pc-file/libdir/qbs.metatest.module.pc @@ -0,0 +1,5 @@ +Name: qbs.metatest.module +Description: just a test +Version: 0.0.1 + +Cflags: -DTHE_MAGIC_DEFINE diff --git a/tests/auto/blackbox/testdata/dot-dot-pc-file/main.cpp b/tests/auto/blackbox/testdata/dot-dot-pc-file/main.cpp new file mode 100644 index 000000000..442b755bf --- /dev/null +++ b/tests/auto/blackbox/testdata/dot-dot-pc-file/main.cpp @@ -0,0 +1,5 @@ +#ifndef THE_MAGIC_DEFINE +#error "missing the magic define" +#endif + +int main() {} diff --git a/tests/auto/blackbox/testdata/driver-linker-flags/driver-linker-flags.qbs b/tests/auto/blackbox/testdata/driver-linker-flags/driver-linker-flags.qbs index 5de0fe053..57f096494 100644 --- a/tests/auto/blackbox/testdata/driver-linker-flags/driver-linker-flags.qbs +++ b/tests/auto/blackbox/testdata/driver-linker-flags/driver-linker-flags.qbs @@ -8,7 +8,7 @@ CppApplication { Probe { id: toolchainProbe - condition: qbs.toolchain.contains("gcc") + condition: qbs.toolchain.includes("gcc") configure: { console.info("toolchain is GCC-like"); found = true; diff --git a/tests/auto/blackbox/testdata/dynamic-library-in-module/Dll.qbs b/tests/auto/blackbox/testdata/dynamic-library-in-module/Dll.qbs index 1acf606dc..c95d88052 100644 --- a/tests/auto/blackbox/testdata/dynamic-library-in-module/Dll.qbs +++ b/tests/auto/blackbox/testdata/dynamic-library-in-module/Dll.qbs @@ -1,8 +1,8 @@ DynamicLibrary { Depends { name: "cpp" } - Depends { name: "bundle"; condition: qbs.targetOS.contains("darwin") } + Depends { name: "bundle"; condition: qbs.targetOS.includes("darwin") } Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false cpp.minimumMacosVersion: "10.7" // For -rpath } diff --git a/tests/auto/blackbox/testdata/dynamic-library-in-module/modules/thelib/thelib.qbs b/tests/auto/blackbox/testdata/dynamic-library-in-module/modules/thelib/thelib.qbs index 30f87337d..3059fa5e9 100644 --- a/tests/auto/blackbox/testdata/dynamic-library-in-module/modules/thelib/thelib.qbs +++ b/tests/auto/blackbox/testdata/dynamic-library-in-module/modules/thelib/thelib.qbs @@ -13,7 +13,7 @@ Module { } Group { name: "thelib dll import" - condition: qbs.targetOS.contains("windows") + condition: qbs.targetOS.includes("windows") files: FileInfo.joinPaths(product.thelib.baseDir, "thelib.lib") fileTags: ["dynamiclibrary_import"] filesAreTargets: true diff --git a/tests/auto/blackbox/testdata/dynamic-library-in-module/modules/theotherlib/theotherlib.qbs b/tests/auto/blackbox/testdata/dynamic-library-in-module/modules/theotherlib/theotherlib.qbs index 1eb1e01a5..f387feb80 100644 --- a/tests/auto/blackbox/testdata/dynamic-library-in-module/modules/theotherlib/theotherlib.qbs +++ b/tests/auto/blackbox/testdata/dynamic-library-in-module/modules/theotherlib/theotherlib.qbs @@ -13,7 +13,7 @@ Module { } Group { name: "theotherlib dll import" - condition: qbs.targetOS.contains("windows") + condition: qbs.targetOS.includes("windows") files: FileInfo.joinPaths(product.theotherlib.baseDir, "theotherlib.lib") fileTags: ["dynamiclibrary_import"] filesAreTargets: true diff --git a/tests/auto/blackbox/testdata/dynamic-library-in-module/theapp.qbs b/tests/auto/blackbox/testdata/dynamic-library-in-module/theapp.qbs index 26b3f2cab..5ea8cef23 100644 --- a/tests/auto/blackbox/testdata/dynamic-library-in-module/theapp.qbs +++ b/tests/auto/blackbox/testdata/dynamic-library-in-module/theapp.qbs @@ -1,7 +1,9 @@ +import qbs.Host + Project { CppApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata/enableExceptions/exceptions.qbs b/tests/auto/blackbox/testdata/enableExceptions/exceptions.qbs index 9a75043a8..e1d09f7e0 100644 --- a/tests/auto/blackbox/testdata/enableExceptions/exceptions.qbs +++ b/tests/auto/blackbox/testdata/enableExceptions/exceptions.qbs @@ -1,5 +1,5 @@ CppApplication { files: ["main.cpp"] cpp.treatWarningsAsErrors: true - cpp.defines: qbs.toolchain.contains("msvc") && !cpp.enableExceptions ? ["FORCE_FAIL_VS"] : [] + cpp.defines: qbs.toolchain.includes("msvc") && !cpp.enableExceptions ? ["FORCE_FAIL_VS"] : [] } diff --git a/tests/auto/blackbox/testdata/enableExceptions/none.qbs b/tests/auto/blackbox/testdata/enableExceptions/none.qbs index 8fb052476..439ea3037 100644 --- a/tests/auto/blackbox/testdata/enableExceptions/none.qbs +++ b/tests/auto/blackbox/testdata/enableExceptions/none.qbs @@ -2,7 +2,7 @@ CppApplication { files: ["emptymain.cpp"] Group { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") files: ["empty.m", "empty.mm"] } } diff --git a/tests/auto/blackbox/testdata/env-merging/env-merging.qbs b/tests/auto/blackbox/testdata/env-merging/env-merging.qbs index b927003eb..eb681f36b 100644 --- a/tests/auto/blackbox/testdata/env-merging/env-merging.qbs +++ b/tests/auto/blackbox/testdata/env-merging/env-merging.qbs @@ -1,3 +1,5 @@ +import qbs.Host + Project { CppApplication { name: "tool" @@ -6,7 +8,7 @@ Project { Product { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata/escaped-linker-flags/escaped-linker-flags.qbs b/tests/auto/blackbox/testdata/escaped-linker-flags/escaped-linker-flags.qbs index f48bf8d1f..b4fb0df4d 100644 --- a/tests/auto/blackbox/testdata/escaped-linker-flags/escaped-linker-flags.qbs +++ b/tests/auto/blackbox/testdata/escaped-linker-flags/escaped-linker-flags.qbs @@ -10,4 +10,9 @@ CppApplication { cpp.linkerFlags: ["-s"] } files: ["main.cpp"] + Probe { + id: checker + property bool isUnixGcc: qbs.toolchain.contains("gcc") && !qbs.targetOS.contains("macos") + configure: { console.info("is gcc: " + isUnixGcc); } + } } diff --git a/tests/auto/blackbox/testdata/export-rule/export-rule.qbs b/tests/auto/blackbox/testdata/export-rule/export-rule.qbs index 29899e728..455ccba0d 100644 --- a/tests/auto/blackbox/testdata/export-rule/export-rule.qbs +++ b/tests/auto/blackbox/testdata/export-rule/export-rule.qbs @@ -13,7 +13,7 @@ Project { Export { Depends { name: "cpp" } property bool enableTagger - property string description: "Creating C++ source file."; + property string description: "creating C++ source file."; FileTagger { condition: enableTagger patterns: ["*.blubb"] diff --git a/tests/auto/blackbox/testdata/exports-cmake/Foo.cpp b/tests/auto/blackbox/testdata/exports-cmake/Foo.cpp new file mode 100644 index 000000000..ea334f9af --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-cmake/Foo.cpp @@ -0,0 +1,5 @@ +#include "Foo.h" +int someFooWork() +{ + return 42; +} diff --git a/tests/auto/blackbox/testdata/exports-cmake/Foo.h b/tests/auto/blackbox/testdata/exports-cmake/Foo.h new file mode 100644 index 000000000..2f279f577 --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-cmake/Foo.h @@ -0,0 +1,16 @@ +#ifndef FOO_H +#define FOO_H +#include <dllexport.h> + +#ifdef FOO_LIB_STATIC +#define FOO_LIB_EXPORT +#else +#ifdef FOO_LIB +#define FOO_LIB_EXPORT DLL_EXPORT +#else +#define FOO_LIB_EXPORT DLL_IMPORT +#endif +#endif + +FOO_LIB_EXPORT int someFooWork(); +#endif // FOO_H diff --git a/tests/auto/blackbox/testdata/exports-cmake/cmake/CMakeLists.txt b/tests/auto/blackbox/testdata/exports-cmake/cmake/CMakeLists.txt new file mode 100644 index 000000000..d874e0e92 --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-cmake/cmake/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.10) + +project(qbs_import) + +find_package(Bar PATHS REQUIRED) +add_executable(Consumer main.cpp) +target_link_libraries(Consumer Bar) diff --git a/tests/auto/blackbox/testdata/exports-cmake/cmake/main.cpp b/tests/auto/blackbox/testdata/exports-cmake/cmake/main.cpp new file mode 100644 index 000000000..1a1fa90ec --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-cmake/cmake/main.cpp @@ -0,0 +1,6 @@ +#include <Foo.h> + +int main() +{ + return someFooWork(); +} diff --git a/tests/auto/blackbox/testdata/exports-cmake/exports-cmake.qbs b/tests/auto/blackbox/testdata/exports-cmake/exports-cmake.qbs new file mode 100644 index 000000000..6464af705 --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-cmake/exports-cmake.qbs @@ -0,0 +1,70 @@ +import qbs.FileInfo + +Project { + property bool isStatic: false + property bool isBundle: false + + property string headersInstallDir: "include" + + Product { + name: "DllExport" + Depends { name: "Exporter.cmake" } + Group { + name: "API headers" + files: ["../dllexport.h"] + qbs.install: true + qbs.installDir: project.headersInstallDir + } + Group { + fileTagsFilter: ["Exporter.cmake.package"] + qbs.install: true + qbs.installDir: "/lib/cmake/DllExport" + } + Export { + Depends { name: "cpp" } + cpp.includePaths: FileInfo.joinPaths( + exportingProduct.qbs.installRoot, + exportingProduct.qbs.installPrefix, + project.headersInstallDir) + } + } + + Library { + type: project.isStatic ? "staticlibrary" : "dynamiclibrary" + Depends { name: "cpp" } + Depends { name: "DllExport" } + Depends { name: "Exporter.cmake" } + Exporter.cmake.packageName: "Bar" + name: "Foo" + files: ["Foo.cpp"] + version: "1.2.3" + cpp.includePaths: "." + cpp.defines: "FOO_LIB" + Group { + name: "API headers" + files: ["Foo.h"] + qbs.install: true + qbs.installDir: project.headersInstallDir + } + install: true + installImportLib: true + Group { + fileTagsFilter: ["Exporter.cmake.package"] + qbs.install: true + qbs.installDir: "/lib/cmake/Bar" + } + Export { + Depends { name: "cpp" } + cpp.includePaths: FileInfo.joinPaths( + exportingProduct.qbs.installRoot, + exportingProduct.qbs.installPrefix, + project.headersInstallDir) + cpp.defines: ["FOO=1"].concat(project.isStatic ? ["FOO_LIB_STATIC"] : []) + cpp.commonCompilerFlags: "-DOTHER_DEF=1" + cpp.linkerFlags: exportingProduct.qbs.toolchain.contains("gcc") ? ["-s"] : [] + } + + Depends { name: 'bundle' } + bundle.isBundle: qbs.targetOS.includes("darwin") && project.isBundle + } +} diff --git a/tests/auto/blackbox/testdata/exports-cmake/find-cmake.qbs b/tests/auto/blackbox/testdata/exports-cmake/find-cmake.qbs new file mode 100644 index 000000000..52f388966 --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-cmake/find-cmake.qbs @@ -0,0 +1,46 @@ +import qbs.Probes + +Product { + Depends { name: "cpp" } + + Probes.BinaryProbe { + id: cmakeProbe + names: "cmake" + } + + Probes.BinaryProbe { + id: ninjaProbe + names: ["ninja"] + } + + property bool test: { + var data = { + cmakeFound: cmakeProbe.found, + cmakeFilePath: cmakeProbe.filePath, + crossCompiling: qbs.targetPlatform !== qbs.hostPlatform, + installPrefix: qbs.installPrefix + }; + data.buildEnv = {} + Object.assign(data.buildEnv, cpp.buildEnv); // deep copy buildEnv from a probe + if (qbs.toolchain.includes("gcc")) { + data.buildEnv["CC"] = cpp.cCompilerName; + data.buildEnv["CXX"] = cpp.cxxCompilerName; + } else { + data.buildEnv["CC"] = cpp.compilerName; + data.buildEnv["CXX"] = cpp.compilerName; + } + + if (ninjaProbe.found) { + data.generator = "Ninja"; + } else { + if (qbs.toolchain.includes("msvc")) { + data.generator = "NMake Makefiles" + } else if (qbs.toolchain.includes("mingw")) { + data.generator = "MinGW Makefiles"; + } else if (qbs.toolchain.includes("gcc")) { + data.generator = "Unix Makefiles"; + } + } + console.info("---" + JSON.stringify(data) + "---"); + } +} diff --git a/tests/auto/blackbox/testdata/exports-pkgconfig/exports-pkgconfig.qbs b/tests/auto/blackbox/testdata/exports-pkgconfig/exports-pkgconfig.qbs index b855a6149..23331f93f 100644 --- a/tests/auto/blackbox/testdata/exports-pkgconfig/exports-pkgconfig.qbs +++ b/tests/auto/blackbox/testdata/exports-pkgconfig/exports-pkgconfig.qbs @@ -1,4 +1,5 @@ import qbs.FileInfo +import qbs.Host Project { Product { @@ -42,7 +43,7 @@ Project { Depends { name: "Qt.core"; required: false } Depends { name: "helper1" } Depends { name: "helper3" } - property bool someCondition: qbs.hostOS.contains("windows") // hostOS for easier testing + property bool someCondition: Host.os().includes("windows") // hostOS for easier testing property bool someOtherCondition: someCondition Properties { condition: !someOtherCondition diff --git a/tests/auto/blackbox/testdata/exports-qbs/consumer.qbs b/tests/auto/blackbox/testdata/exports-qbs/consumer.qbs index 79ac50e0b..073504400 100644 --- a/tests/auto/blackbox/testdata/exports-qbs/consumer.qbs +++ b/tests/auto/blackbox/testdata/exports-qbs/consumer.qbs @@ -1,6 +1,8 @@ +import qbs.Host + CppApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata/exports-qbs/lib.qbs b/tests/auto/blackbox/testdata/exports-qbs/lib.qbs index 453dac562..01f89a221 100644 --- a/tests/auto/blackbox/testdata/exports-qbs/lib.qbs +++ b/tests/auto/blackbox/testdata/exports-qbs/lib.qbs @@ -16,7 +16,7 @@ DynamicLibrary { cpp.defines: ["MYLIB_BUILD"] cpp.variantSuffix: qbs.buildVariant === "debug" ? "d" : "" Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } files: ["mylib.cpp"] @@ -52,7 +52,7 @@ DynamicLibrary { condition: true prefixMapping: [{ prefix: includeDir, - replacement: FileInfo.joinPaths(qbs.installPrefix, exportingProduct.headersInstallDir) + replacement: FileInfo.joinPaths(exportingProduct.qbs.installPrefix, exportingProduct.headersInstallDir) }] } } diff --git a/tests/auto/blackbox/testdata/exports-qbs/tool.qbs b/tests/auto/blackbox/testdata/exports-qbs/tool.qbs index cea46d3fd..d3626bead 100644 --- a/tests/auto/blackbox/testdata/exports-qbs/tool.qbs +++ b/tests/auto/blackbox/testdata/exports-qbs/tool.qbs @@ -49,7 +49,7 @@ CppApplication { prepare: { var cmd = new Command(explicitlyDependsOn["MyTool.tool"][0].filePath, [input.filePath, output.filePath]); - cmd.description = input.fileName + " -> " + output.fileName; + cmd.description = "compiling" + input.fileName + " to " + output.fileName; return [cmd]; } } diff --git a/tests/auto/blackbox/testdata/external-libs/external-libs.qbs b/tests/auto/blackbox/testdata/external-libs/external-libs.qbs index 619f40867..326bf5dae 100644 --- a/tests/auto/blackbox/testdata/external-libs/external-libs.qbs +++ b/tests/auto/blackbox/testdata/external-libs/external-libs.qbs @@ -1,13 +1,13 @@ import qbs.TextFile Project { - property string libDir: sourceDirectory + "/libs" + property string libDir: buildDirectory + "/libs" StaticLibrary { name: "lib1" destinationDirectory: project.libDir Depends { name: "cpp" } Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } files: ["lib1.cpp"] @@ -18,7 +18,7 @@ Project { Depends { name: "cpp" } Depends { name: "lib1" } Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } files: ["lib2.cpp"] diff --git a/tests/auto/blackbox/testdata/flatbuf/bar.fbs b/tests/auto/blackbox/testdata/flatbuf/bar.fbs new file mode 100644 index 000000000..47148f800 --- /dev/null +++ b/tests/auto/blackbox/testdata/flatbuf/bar.fbs @@ -0,0 +1,9 @@ +include "foo.fbs"; + +namespace QbsTest; + +table Bar { + foo:Foo; +} + +root_type Bar; diff --git a/tests/auto/blackbox/testdata/flatbuf/baz.fbs b/tests/auto/blackbox/testdata/flatbuf/baz.fbs new file mode 100644 index 000000000..312183710 --- /dev/null +++ b/tests/auto/blackbox/testdata/flatbuf/baz.fbs @@ -0,0 +1,9 @@ +include "imported_foo/imported_foo.fbs"; + +namespace QbsTest; + +table Baz { + foo:Foo; +} + +root_type Baz; diff --git a/tests/auto/blackbox/testdata/flatbuf/conanfile.txt b/tests/auto/blackbox/testdata/flatbuf/conanfile.txt new file mode 100644 index 000000000..188da5897 --- /dev/null +++ b/tests/auto/blackbox/testdata/flatbuf/conanfile.txt @@ -0,0 +1,6 @@ +[requires] +flatbuffers/24.3.25 +[tool_requires] +flatbuffers/24.3.25 +[generators] +QbsDeps diff --git a/tests/auto/blackbox/testdata/flatbuf/flat.c b/tests/auto/blackbox/testdata/flatbuf/flat.c new file mode 100644 index 000000000..55e25e556 --- /dev/null +++ b/tests/auto/blackbox/testdata/flatbuf/flat.c @@ -0,0 +1,36 @@ +#include "foo_builder.h" + +#include <stdio.h> + +#undef ns +#define ns(x) FLATBUFFERS_WRAP_NAMESPACE(QbsTest, x) // Specified in the schema. + +#define test_assert(x) do { if (!(x)) { assert(0); return -1; }} while (0) + +int main() +{ + void *buffer = NULL; + size_t size = 0; + + flatcc_builder_t builder; + flatcc_builder_init(&builder); + + flatbuffers_string_ref_t name = flatbuffers_string_create_str(&builder, "John Doe"); + + ns(Foo_create_as_root(&builder, name, 42)); + + buffer = flatcc_builder_finalize_aligned_buffer(&builder, &size); + + ns(Foo_table_t) foo = ns(Foo_as_root(buffer)); + + test_assert(strcmp(ns(Foo_name(foo)), "John Doe") == 0); + test_assert(ns(Foo_count(foo)) == 42); + + free(buffer); + + flatcc_builder_clear(&builder); + + printf("The FlatBuffer was successfully created and accessed!\n"); + + return 0; +} diff --git a/tests/auto/blackbox/testdata/flatbuf/flat.cpp b/tests/auto/blackbox/testdata/flatbuf/flat.cpp new file mode 100644 index 000000000..56332bacd --- /dev/null +++ b/tests/auto/blackbox/testdata/flatbuf/flat.cpp @@ -0,0 +1,22 @@ +#include "foo_generated.h" + +#include <iostream> + +using namespace QbsTest; + +int main() +{ + flatbuffers::FlatBufferBuilder builder; + auto name = builder.CreateString("John Doe"); + auto newFoo = QbsTest::CreateFoo(builder, name, 42); + builder.Finish(newFoo); + + auto foo = GetFoo(builder.GetBufferPointer()); + + assert(foo->name()->str() == "John Doe"); + assert(foo->count() == 42); + + std::cout << "The FlatBuffer was successfully created and accessed!" << std::endl; + + return 0; +} diff --git a/tests/auto/blackbox/testdata/flatbuf/flat_absolute_import.cpp b/tests/auto/blackbox/testdata/flatbuf/flat_absolute_import.cpp new file mode 100644 index 000000000..b7c43d8a5 --- /dev/null +++ b/tests/auto/blackbox/testdata/flatbuf/flat_absolute_import.cpp @@ -0,0 +1,25 @@ +#include "baz_generated.h" + +#include <iostream> + +using namespace QbsTest; + +int main() +{ + flatbuffers::FlatBufferBuilder builder; + + auto name = builder.CreateString("John Doe"); + auto newFoo = QbsTest::CreateFoo(builder, name, 42); + + auto newBaz = QbsTest::CreateBaz(builder, newFoo); + builder.Finish(newBaz); + + auto baz = GetBaz(builder.GetBufferPointer()); + + assert(baz->foo()->name()->str() == "John Doe"); + assert(baz->foo()->count() == 42); + + std::cout << "The FlatBuffer was successfully created and accessed!" << std::endl; + + return 0; +} diff --git a/tests/auto/blackbox/testdata/flatbuf/flat_absolute_import.qbs b/tests/auto/blackbox/testdata/flatbuf/flat_absolute_import.qbs new file mode 100644 index 000000000..888bfd4e3 --- /dev/null +++ b/tests/auto/blackbox/testdata/flatbuf/flat_absolute_import.qbs @@ -0,0 +1,24 @@ +CppApplication { + Depends { name: "flatbuf.cpp"; required: false } + + consoleApplication: true + condition: { + var result = qbs.targetPlatform === qbs.hostPlatform; + if (!result) + console.info("targetPlatform differs from hostPlatform"); + return result && hasFlatbuffers; + } + property bool hasFlatbuffers: { + console.info("has flatbuffers: " + flatbuf.cpp.present); + return flatbuf.cpp.present; + } + + flatbuf.cpp.importPaths: "imports/" + + files: [ + "flat_absolute_import.cpp", + "baz.fbs", + "imports/imported_foo/imported_foo.fbs", + ] + qbsModuleProviders: "conan" +} diff --git a/tests/auto/blackbox/testdata/flatbuf/flat_c.qbs b/tests/auto/blackbox/testdata/flatbuf/flat_c.qbs new file mode 100644 index 000000000..6d365252e --- /dev/null +++ b/tests/auto/blackbox/testdata/flatbuf/flat_c.qbs @@ -0,0 +1,21 @@ +CppApplication { + Depends { name: "flatbuffers.c"; required: false } + + consoleApplication: true + condition: { + var result = qbs.targetPlatform === qbs.hostPlatform; + if (!result) + console.info("targetPlatform differs from hostPlatform"); + return result && hasFlatbuffers; + } + property bool hasFlatbuffers: { + console.info("has flatbuffers: " + flatbuffers.c.present); + return flatbuffers.c.present; + } + + files: [ + "flat.c", + "foo.fbs", + ] + qbsModuleProviders: "conan" +} diff --git a/tests/auto/blackbox/testdata/flatbuf/flat_cpp.qbs b/tests/auto/blackbox/testdata/flatbuf/flat_cpp.qbs new file mode 100644 index 000000000..99e89a5fa --- /dev/null +++ b/tests/auto/blackbox/testdata/flatbuf/flat_cpp.qbs @@ -0,0 +1,21 @@ +CppApplication { + Depends { name: "flatbuf.cpp"; required: false } + + consoleApplication: true + condition: { + var result = qbs.targetPlatform === qbs.hostPlatform; + if (!result) + console.info("targetPlatform differs from hostPlatform"); + return result && hasFlatbuffers; + } + property bool hasFlatbuffers: { + console.info("has flatbuffers: " + flatbuf.cpp.present); + return flatbuf.cpp.present; + } + + files: [ + "flat.cpp", + "foo.fbs", + ] + qbsModuleProviders: "conan" +} diff --git a/tests/auto/blackbox/testdata/flatbuf/flat_filename_extension.cpp b/tests/auto/blackbox/testdata/flatbuf/flat_filename_extension.cpp new file mode 100644 index 000000000..77ed64acd --- /dev/null +++ b/tests/auto/blackbox/testdata/flatbuf/flat_filename_extension.cpp @@ -0,0 +1,22 @@ +#include "foo_generated.hpp" + +#include <iostream> + +using namespace QbsTest; + +int main() +{ + flatbuffers::FlatBufferBuilder builder; + auto name = builder.CreateString("John Doe"); + auto newFoo = QbsTest::CreateFoo(builder, name, 42); + builder.Finish(newFoo); + + auto foo = GetFoo(builder.GetBufferPointer()); + + assert(foo->name()->str() == "John Doe"); + assert(foo->count() == 42); + + std::cout << "The FlatBuffer was successfully created and accessed!" << std::endl; + + return 0; +} diff --git a/tests/auto/blackbox/testdata/flatbuf/flat_filename_extension.qbs b/tests/auto/blackbox/testdata/flatbuf/flat_filename_extension.qbs new file mode 100644 index 000000000..31eec7629 --- /dev/null +++ b/tests/auto/blackbox/testdata/flatbuf/flat_filename_extension.qbs @@ -0,0 +1,23 @@ +CppApplication { + Depends { name: "flatbuf.cpp"; required: false } + + consoleApplication: true + condition: { + var result = qbs.targetPlatform === qbs.hostPlatform; + if (!result) + console.info("targetPlatform differs from hostPlatform"); + return result && hasFlatbuffers; + } + property bool hasFlatbuffers: { + console.info("has flatbuffers: " + flatbuf.cpp.present); + return flatbuf.cpp.present; + } + + flatbuf.cpp.filenameExtension: "hpp" + + files: [ + "flat_filename_extension.cpp", + "foo.fbs", + ] + qbsModuleProviders: "conan" +} diff --git a/tests/auto/blackbox/testdata/flatbuf/flat_filename_suffix.cpp b/tests/auto/blackbox/testdata/flatbuf/flat_filename_suffix.cpp new file mode 100644 index 000000000..630e4aaef --- /dev/null +++ b/tests/auto/blackbox/testdata/flatbuf/flat_filename_suffix.cpp @@ -0,0 +1,22 @@ +#include "foo.fbs.h" + +#include <iostream> + +using namespace QbsTest; + +int main() +{ + flatbuffers::FlatBufferBuilder builder; + auto name = builder.CreateString("John Doe"); + auto newFoo = QbsTest::CreateFoo(builder, name, 42); + builder.Finish(newFoo); + + auto foo = GetFoo(builder.GetBufferPointer()); + + assert(foo->name()->str() == "John Doe"); + assert(foo->count() == 42); + + std::cout << "The FlatBuffer was successfully created and accessed!" << std::endl; + + return 0; +} diff --git a/tests/auto/blackbox/testdata/flatbuf/flat_filename_suffix.qbs b/tests/auto/blackbox/testdata/flatbuf/flat_filename_suffix.qbs new file mode 100644 index 000000000..5103b041f --- /dev/null +++ b/tests/auto/blackbox/testdata/flatbuf/flat_filename_suffix.qbs @@ -0,0 +1,23 @@ +CppApplication { + Depends { name: "flatbuf.cpp"; required: false } + + consoleApplication: true + condition: { + var result = qbs.targetPlatform === qbs.hostPlatform; + if (!result) + console.info("targetPlatform differs from hostPlatform"); + return result && hasFlatbuffers; + } + property bool hasFlatbuffers: { + console.info("has flatbuffers: " + flatbuf.cpp.present); + return flatbuf.cpp.present; + } + + flatbuf.cpp.filenameSuffix: ".fbs" + + files: [ + "flat_filename_suffix.cpp", + "foo.fbs", + ] + qbsModuleProviders: "conan" +} diff --git a/tests/auto/blackbox/testdata/flatbuf/flat_keep_prefix.cpp b/tests/auto/blackbox/testdata/flatbuf/flat_keep_prefix.cpp new file mode 100644 index 000000000..5f4b55e96 --- /dev/null +++ b/tests/auto/blackbox/testdata/flatbuf/flat_keep_prefix.cpp @@ -0,0 +1,26 @@ +#include "baz_generated.h" +#include "imported_foo/imported_foo_generated.h" + +#include <iostream> + +using namespace QbsTest; + +int main() +{ + flatbuffers::FlatBufferBuilder builder; + + auto name = builder.CreateString("John Doe"); + auto newFoo = QbsTest::CreateFoo(builder, name, 42); + + auto newBaz = QbsTest::CreateBaz(builder, newFoo); + builder.Finish(newBaz); + + auto baz = GetBaz(builder.GetBufferPointer()); + + assert(baz->foo()->name()->str() == "John Doe"); + assert(baz->foo()->count() == 42); + + std::cout << "The FlatBuffer was successfully created and accessed!" << std::endl; + + return 0; +} diff --git a/tests/auto/blackbox/testdata/flatbuf/flat_keep_prefix.qbs b/tests/auto/blackbox/testdata/flatbuf/flat_keep_prefix.qbs new file mode 100644 index 000000000..0ea0d1dac --- /dev/null +++ b/tests/auto/blackbox/testdata/flatbuf/flat_keep_prefix.qbs @@ -0,0 +1,25 @@ +CppApplication { + Depends { name: "flatbuf.cpp"; required: false } + + consoleApplication: true + condition: { + var result = qbs.targetPlatform === qbs.hostPlatform; + if (!result) + console.info("targetPlatform differs from hostPlatform"); + return result && hasFlatbuffers; + } + property bool hasFlatbuffers: { + console.info("has flatbuffers: " + flatbuf.cpp.present); + return flatbuf.cpp.present; + } + + flatbuf.cpp.importPaths: "imports/" + flatbuf.cpp.keepPrefix: true + + files: [ + "flat_keep_prefix.cpp", + "baz.fbs", + "imports/imported_foo/imported_foo.fbs", + ] + qbsModuleProviders: "conan" +} diff --git a/tests/auto/blackbox/testdata/flatbuf/flat_relative_import.cpp b/tests/auto/blackbox/testdata/flatbuf/flat_relative_import.cpp new file mode 100644 index 000000000..bec6dadfd --- /dev/null +++ b/tests/auto/blackbox/testdata/flatbuf/flat_relative_import.cpp @@ -0,0 +1,25 @@ +#include "bar_generated.h" + +#include <iostream> + +using namespace QbsTest; + +int main() +{ + flatbuffers::FlatBufferBuilder builder; + + auto name = builder.CreateString("John Doe"); + auto newFoo = QbsTest::CreateFoo(builder, name, 42); + + auto newBar = QbsTest::CreateBar(builder, newFoo); + builder.Finish(newBar); + + auto bar = GetBar(builder.GetBufferPointer()); + + assert(bar->foo()->name()->str() == "John Doe"); + assert(bar->foo()->count() == 42); + + std::cout << "The FlatBuffer was successfully created and accessed!" << std::endl; + + return 0; +} diff --git a/tests/auto/blackbox/testdata/flatbuf/flat_relative_import.qbs b/tests/auto/blackbox/testdata/flatbuf/flat_relative_import.qbs new file mode 100644 index 000000000..f5a2c5d0b --- /dev/null +++ b/tests/auto/blackbox/testdata/flatbuf/flat_relative_import.qbs @@ -0,0 +1,22 @@ +CppApplication { + Depends { name: "flatbuf.cpp"; required: false } + + consoleApplication: true + condition: { + var result = qbs.targetPlatform === qbs.hostPlatform; + if (!result) + console.info("targetPlatform differs from hostPlatform"); + return result && hasFlatbuffers; + } + property bool hasFlatbuffers: { + console.info("has flatbuffers: " + flatbuf.cpp.present); + return flatbuf.cpp.present; + } + + files: [ + "flat_relative_import.cpp", + "bar.fbs", + "foo.fbs", + ] + qbsModuleProviders: "conan" +} diff --git a/tests/auto/blackbox/testdata/flatbuf/foo.fbs b/tests/auto/blackbox/testdata/flatbuf/foo.fbs new file mode 100644 index 000000000..dff3b488f --- /dev/null +++ b/tests/auto/blackbox/testdata/flatbuf/foo.fbs @@ -0,0 +1,8 @@ +namespace QbsTest; + +table Foo { + name:string; + count:int; +} + +root_type Foo; diff --git a/tests/auto/blackbox/testdata/flatbuf/imports/imported_foo/imported_foo.fbs b/tests/auto/blackbox/testdata/flatbuf/imports/imported_foo/imported_foo.fbs new file mode 100644 index 000000000..dff3b488f --- /dev/null +++ b/tests/auto/blackbox/testdata/flatbuf/imports/imported_foo/imported_foo.fbs @@ -0,0 +1,8 @@ +namespace QbsTest; + +table Foo { + name:string; + count:int; +} + +root_type Foo; diff --git a/tests/auto/blackbox/testdata/freedesktop/freedesktop.qbs b/tests/auto/blackbox/testdata/freedesktop/freedesktop.qbs index b3519ba4c..1efe5c91c 100644 --- a/tests/auto/blackbox/testdata/freedesktop/freedesktop.qbs +++ b/tests/auto/blackbox/testdata/freedesktop/freedesktop.qbs @@ -10,7 +10,7 @@ Project { Depends { name: "freedesktop" } - freedesktop.name: "My App" + freedesktop.appName: "My App" freedesktop.desktopKeys: ({ 'Icon': "myapp.png" }) diff --git a/tests/auto/blackbox/testdata/generate-linker-map-file/generate-linker-map-file.qbs b/tests/auto/blackbox/testdata/generate-linker-map-file/generate-linker-map-file.qbs index 8c971a747..0d67fa54c 100644 --- a/tests/auto/blackbox/testdata/generate-linker-map-file/generate-linker-map-file.qbs +++ b/tests/auto/blackbox/testdata/generate-linker-map-file/generate-linker-map-file.qbs @@ -3,13 +3,13 @@ Project { name: "app-map" files: ["main.cpp"] // lld-link has different flag for map files, test it by switching to "lld" linkerVariant - Properties { condition: qbs.toolchain.contains("clang-cl"); cpp.linkerVariant: "lld" } + Properties { condition: qbs.toolchain.includes("clang-cl"); cpp.linkerVariant: "lld" } cpp.generateLinkerMapFile: true } CppApplication { name: "app-nomap" files: ["main.cpp"] - Properties { condition: qbs.toolchain.contains("clang-cl"); cpp.linkerVariant: "lld" } + Properties { condition: qbs.toolchain.includes("clang-cl"); cpp.linkerVariant: "lld" } cpp.generateLinkerMapFile: false } CppApplication { @@ -19,8 +19,8 @@ Project { Probe { id: toolchainProbe - property bool isUsed: qbs.toolchain.contains("msvc") - || qbs.toolchain.contains("gcc") + property bool isUsed: qbs.toolchain.includes("msvc") + || qbs.toolchain.includes("gcc") configure: { console.info("use test: " + isUsed); } diff --git a/tests/auto/blackbox/testdata/generator/generator.qbs b/tests/auto/blackbox/testdata/generator/generator.qbs index d0857beb5..9f6d452e7 100644 --- a/tests/auto/blackbox/testdata/generator/generator.qbs +++ b/tests/auto/blackbox/testdata/generator/generator.qbs @@ -18,12 +18,12 @@ CppApplication { var f = new TextFile(input.filePath, TextFile.ReadOnly); var content = f.readAll(); f.close(); - if (content.contains("file1")) { + if (content.includes("file1")) { f = new TextFile(outputs.file1[0].filePath, TextFile.WriteOnly); f.writeLine("void f1() {}"); f.close(); } - if (content.contains("file2")) { + if (content.includes("file2")) { f = new TextFile(outputs.file2[0].filePath, TextFile.WriteOnly); f.writeLine("void f2() {}"); f.close(); diff --git a/tests/auto/blackbox/testdata/groups-in-modules/groups-in-modules.qbs b/tests/auto/blackbox/testdata/groups-in-modules/groups-in-modules.qbs index 0508872db..47275821f 100644 --- a/tests/auto/blackbox/testdata/groups-in-modules/groups-in-modules.qbs +++ b/tests/auto/blackbox/testdata/groups-in-modules/groups-in-modules.qbs @@ -1,7 +1,9 @@ +import qbs.Host + Project { Product { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; @@ -12,6 +14,9 @@ Project { name: "helper3" required: false } + Depends { name: "helper7" } + helper7.fileName: "helper7.c" + type: ["diamond"] files: [ diff --git a/tests/auto/blackbox/testdata/groups-in-modules/imports/Helper7Base.qbs b/tests/auto/blackbox/testdata/groups-in-modules/imports/Helper7Base.qbs new file mode 100644 index 000000000..cc55e6351 --- /dev/null +++ b/tests/auto/blackbox/testdata/groups-in-modules/imports/Helper7Base.qbs @@ -0,0 +1,8 @@ +Module { + property string directory + property string fileName + Group { + prefix: directory + "/" + files: fileName + } +} diff --git a/tests/auto/blackbox/testdata/groups-in-modules/modules/helper/helper.qbs b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper/helper.qbs index cbd30a35d..9dc903411 100644 --- a/tests/auto/blackbox/testdata/groups-in-modules/modules/helper/helper.qbs +++ b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper/helper.qbs @@ -39,7 +39,7 @@ Module { prepare: { var cmd = new Command(FileInfo.joinPaths(product.buildDirectory, product.targetName), [input.filePath, output.filePath]); - cmd.description = "compile " + input.fileName + " => " + output.fileName; + cmd.description = "compiling " + input.fileName + " to " + output.fileName; return [cmd]; } } diff --git a/tests/auto/blackbox/testdata/groups-in-modules/modules/helper7/helper7.c b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper7/helper7.c new file mode 100644 index 000000000..a83f5476e --- /dev/null +++ b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper7/helper7.c @@ -0,0 +1 @@ +void helper7(void) {} diff --git a/tests/auto/blackbox/testdata/groups-in-modules/modules/helper7/helper7.qbs b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper7/helper7.qbs new file mode 100644 index 000000000..90e1f11e2 --- /dev/null +++ b/tests/auto/blackbox/testdata/groups-in-modules/modules/helper7/helper7.qbs @@ -0,0 +1,3 @@ +Helper7Base { + directory: path +} diff --git a/tests/auto/blackbox/testdata/grpc/conanfile.txt b/tests/auto/blackbox/testdata/grpc/conanfile.txt new file mode 100644 index 000000000..f88e6e8d6 --- /dev/null +++ b/tests/auto/blackbox/testdata/grpc/conanfile.txt @@ -0,0 +1,7 @@ +[requires] +grpc/1.54.3 +[tool_requires] +protobuf/3.21.12 +grpc/1.54.3 +[generators] +QbsDeps diff --git a/tests/auto/blackbox/testdata/grpc/grpc_cpp.qbs b/tests/auto/blackbox/testdata/grpc/grpc_cpp.qbs index 4e46da210..d1bdd5d60 100644 --- a/tests/auto/blackbox/testdata/grpc/grpc_cpp.qbs +++ b/tests/auto/blackbox/testdata/grpc/grpc_cpp.qbs @@ -1,24 +1,29 @@ +import qbs.Host + CppApplication { name: "grpc_cpp" consoleApplication: true condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result && hasDependencies; } Depends { name: "cpp" } - cpp.cxxLanguageVersion: "c++11" - cpp.minimumMacosVersion: "10.8" + cpp.cxxLanguageVersion: "c++17" + cpp.minimumMacosVersion: "10.15" cpp.warningLevel: "none" + qbs.buildVariant: "release" Depends { name: "protobuf.cpp"; required: false } + Depends { name: "grpc++"; id: grpcpp; required: false } protobuf.cpp.useGrpc: true property bool hasDependencies: { console.info("has grpc: " + protobuf.cpp.present); - return protobuf.cpp.present; + console.info("has modules: " + grpcpp.present); + return protobuf.cpp.present && grpcpp.present; } files: "grpc.cpp" diff --git a/tests/auto/blackbox/testdata/host-os-properties/host-os-properties.qbs b/tests/auto/blackbox/testdata/host-os-properties/host-os-properties.qbs index e1e722764..9d050e166 100644 --- a/tests/auto/blackbox/testdata/host-os-properties/host-os-properties.qbs +++ b/tests/auto/blackbox/testdata/host-os-properties/host-os-properties.qbs @@ -1,14 +1,16 @@ +import qbs.Host + CppApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; } consoleApplication: true cpp.defines: [ - 'HOST_ARCHITECTURE="' + qbs.hostArchitecture + '"', - 'HOST_PLATFORM="' + qbs.hostPlatform + '"' + 'HOST_ARCHITECTURE="' + Host.architecture() + '"', + 'HOST_PLATFORM="' + Host.platform() + '"' ] files: "main.cpp" } diff --git a/tests/auto/blackbox/testdata/host-os-properties/main.cpp b/tests/auto/blackbox/testdata/host-os-properties/main.cpp index b0c239e20..129c16379 100644 --- a/tests/auto/blackbox/testdata/host-os-properties/main.cpp +++ b/tests/auto/blackbox/testdata/host-os-properties/main.cpp @@ -1,7 +1,7 @@ -#include <stdio.h> +#include <cstdio> int main() { - printf("HOST_ARCHITECTURE = %s\n", HOST_ARCHITECTURE); - printf("HOST_PLATFORM = %s\n", HOST_PLATFORM); + std::printf("HOST_ARCHITECTURE = %s\n", HOST_ARCHITECTURE); + std::printf("HOST_PLATFORM = %s\n", HOST_PLATFORM); return 0; } diff --git a/tests/auto/blackbox/testdata/importing-product/importing-product.qbs b/tests/auto/blackbox/testdata/importing-product/importing-product.qbs index dfc4cd65e..54ad727b7 100644 --- a/tests/auto/blackbox/testdata/importing-product/importing-product.qbs +++ b/tests/auto/blackbox/testdata/importing-product/importing-product.qbs @@ -16,7 +16,7 @@ Project { } prepare: { var cmd = new JavaScriptCommand(); - cmd.description = "Copying file"; + cmd.description = "copying file"; cmd.sourceCode = function() { File.copy(input.filePath, output.filePath); } diff --git a/tests/auto/blackbox/testdata/includeLookup/includeLookup.qbs b/tests/auto/blackbox/testdata/includeLookup/includeLookup.qbs index 5b645fad3..903d170d0 100644 --- a/tests/auto/blackbox/testdata/includeLookup/includeLookup.qbs +++ b/tests/auto/blackbox/testdata/includeLookup/includeLookup.qbs @@ -1,11 +1,12 @@ import qbs.FileInfo +import qbs.Host Project { property string name: 'includeLookup' qbsSearchPaths: '.' Product { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata/input-tags-change-tracking/input-tags-change-tracking.qbs b/tests/auto/blackbox/testdata/input-tags-change-tracking/input-tags-change-tracking.qbs index ef2c5c55b..1e4248009 100644 --- a/tests/auto/blackbox/testdata/input-tags-change-tracking/input-tags-change-tracking.qbs +++ b/tests/auto/blackbox/testdata/input-tags-change-tracking/input-tags-change-tracking.qbs @@ -43,10 +43,10 @@ Product { inputs: "txt" outputFileTags: "p_tag" outputArtifacts: { - if (input.fileTags.contains("empty")) + if (input.fileTags.includes("empty")) return []; return [{ - filePath: input.fileTags.contains("y") ? "y.out" : "x.out", + filePath: input.fileTags.includes("y") ? "y.out" : "x.out", fileTags: "p_tag" }] } diff --git a/tests/auto/blackbox/testdata/inputs-from-dependencies/inputs-from-dependencies.qbs b/tests/auto/blackbox/testdata/inputs-from-dependencies/inputs-from-dependencies.qbs index 919060c73..f9993ecf3 100644 --- a/tests/auto/blackbox/testdata/inputs-from-dependencies/inputs-from-dependencies.qbs +++ b/tests/auto/blackbox/testdata/inputs-from-dependencies/inputs-from-dependencies.qbs @@ -37,7 +37,7 @@ Project { } prepare: { var cmd = new JavaScriptCommand(); - cmd.description = "Gathering text files"; + cmd.description = "gathering text files"; cmd.sourceCode = function() { for (i in inputs.txt) console.info(inputs.txt[i].filePath); diff --git a/tests/auto/blackbox/testdata/install-locations/install-locations.qbs b/tests/auto/blackbox/testdata/install-locations/install-locations.qbs index 994b4b146..ba51c0dc1 100644 --- a/tests/auto/blackbox/testdata/install-locations/install-locations.qbs +++ b/tests/auto/blackbox/testdata/install-locations/install-locations.qbs @@ -1,16 +1,16 @@ Project { property bool dummy: { - if (qbs.targetOS.contains("windows")) { + if (qbs.targetOS.includes("windows")) { console.info("is windows"); - } else if (qbs.targetOS.contains("darwin")) { + } else if (qbs.targetOS.includes("darwin")) { console.info("is darwin"); - if (qbs.targetOS.contains("macos")) + if (qbs.targetOS.includes("macos")) console.info("is mac"); } else { console.info("is unix"); } - if (qbs.toolchain.contains("mingw")) + if (qbs.toolchain.includes("mingw")) console.info("is mingw"); } CppApplication { diff --git a/tests/auto/blackbox/testdata/installable-as-auxiliary-input/installable-as-auxiliary-input.qbs b/tests/auto/blackbox/testdata/installable-as-auxiliary-input/installable-as-auxiliary-input.qbs index c34b0ca74..a445fc35b 100644 --- a/tests/auto/blackbox/testdata/installable-as-auxiliary-input/installable-as-auxiliary-input.qbs +++ b/tests/auto/blackbox/testdata/installable-as-auxiliary-input/installable-as-auxiliary-input.qbs @@ -1,12 +1,13 @@ import qbs.File import qbs.FileInfo +import qbs.Host import qbs.TextFile Project { name: "p" CppApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; @@ -56,7 +57,7 @@ Project { Artifact { filePath: "theheader.h.in"; fileTags: "header.in" } prepare: { var cmd = new JavaScriptCommand(); - cmd.description = "Creating " + output.fileName; + cmd.description = "creating " + output.fileName; cmd.sourceCode = function() { for (var i = 0; i < 1000; ++i) { // Artificial delay. var file = new TextFile(output.filePath, TextFile.WriteOnly); @@ -75,7 +76,7 @@ Project { Artifact { filePath: "theheader.h"; fileTags: "header" } prepare: { var cmd = new JavaScriptCommand(); - cmd.description = "Creating " + output.fileName; + cmd.description = "creating " + output.fileName; cmd.sourceCode = function() { File.copy(input.filePath, output.filePath); }; return [cmd]; } diff --git a/tests/auto/blackbox/testdata/installable/installable.qbs b/tests/auto/blackbox/testdata/installable/installable.qbs index 56feb6ec5..de93cf61f 100644 --- a/tests/auto/blackbox/testdata/installable/installable.qbs +++ b/tests/auto/blackbox/testdata/installable/installable.qbs @@ -11,6 +11,7 @@ Project { } install: true + installDebugInformation: false installDir: "" } @@ -27,7 +28,7 @@ Project { } prepare: { var cmd = new JavaScriptCommand(); - cmd.description = "Creating " + output.fileName; + cmd.description = "creating " + output.fileName; cmd.sourceCode = function() { var file = new TextFile(output.filePath, TextFile.WriteOnly); for (var i = 0; i < inputs.installable.length; ++i) diff --git a/tests/auto/blackbox/testdata/installed-transformer-output/qbs668.qbs b/tests/auto/blackbox/testdata/installed-transformer-output/qbs668.qbs index aa40b7691..6f84206be 100644 --- a/tests/auto/blackbox/testdata/installed-transformer-output/qbs668.qbs +++ b/tests/auto/blackbox/testdata/installed-transformer-output/qbs668.qbs @@ -18,7 +18,7 @@ Product { } prepare: { var cmd = new JavaScriptCommand(); - cmd.description = "Creating file:'" + output.fileName + "'"; + cmd.description = "creating file:'" + output.fileName + "'"; cmd.highlight = "codegen"; cmd.sourceCode = function() { var file = new TextFile(output.filePath, TextFile.WriteOnly); diff --git a/tests/auto/blackbox/testdata/installpackage/installpackage.qbs b/tests/auto/blackbox/testdata/installpackage/installpackage.qbs index a0649a578..3396b79a4 100644 --- a/tests/auto/blackbox/testdata/installpackage/installpackage.qbs +++ b/tests/auto/blackbox/testdata/installpackage/installpackage.qbs @@ -2,7 +2,7 @@ Project { CppApplication { name: "public_tool" Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } Depends { name: "mylib" } @@ -20,7 +20,7 @@ Project { } DynamicLibrary { Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } Depends { name: "cpp" } diff --git a/tests/auto/blackbox/testdata/invalid-artifact-path/invalid-artifact-path.qbs b/tests/auto/blackbox/testdata/invalid-artifact-path/invalid-artifact-path.qbs new file mode 100644 index 000000000..650233d86 --- /dev/null +++ b/tests/auto/blackbox/testdata/invalid-artifact-path/invalid-artifact-path.qbs @@ -0,0 +1,18 @@ +Project { + property string artifactDir + Product { + type: "t" + Rule { + multiplex: true + Artifact { + filePath: project.artifactDir + "/file.out" + fileTags: "t" + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.sourceCode = function() {}; + return cmd; + } + } + } +} diff --git a/tests/auto/blackbox/testdata/invalid-command-property/invalid-command-property.qbs b/tests/auto/blackbox/testdata/invalid-command-property/invalid-command-property.qbs index b08fcd4a3..a07beda57 100644 --- a/tests/auto/blackbox/testdata/invalid-command-property/invalid-command-property.qbs +++ b/tests/auto/blackbox/testdata/invalid-command-property/invalid-command-property.qbs @@ -16,7 +16,7 @@ Product { } prepare: { var cmd = new JavaScriptCommand(); - cmd.description = "Creating output"; + cmd.description = "creating output"; if (product.errorType === "qobject") cmd.dummy = new TextFile(input.filePath, TextFile.ReadOnly); else if (product.errorType === "input") diff --git a/tests/auto/blackbox/testdata/jsextensions-binaryfile/binaryfile.qbs b/tests/auto/blackbox/testdata/jsextensions-binaryfile/binaryfile.qbs index 1e7426744..5824fe518 100644 --- a/tests/auto/blackbox/testdata/jsextensions-binaryfile/binaryfile.qbs +++ b/tests/auto/blackbox/testdata/jsextensions-binaryfile/binaryfile.qbs @@ -36,6 +36,9 @@ Product { destination.write(source.atEof() ? [ 0xFF ] : [ 0x00 ]); source.close(); destination.close(); + source = new BinaryFile("destination.dat", BinaryFile.ReadOnly); + destination = new BinaryFile("destination2.dat", BinaryFile.WriteOnly); + destination.write(source.read(8)); }; commands.push(cmd); return commands; diff --git a/tests/auto/blackbox/testdata/jsextensions-file/file.qbs b/tests/auto/blackbox/testdata/jsextensions-file/file.qbs index 6adf714e2..7a47cf3cd 100644 --- a/tests/auto/blackbox/testdata/jsextensions-file/file.qbs +++ b/tests/auto/blackbox/testdata/jsextensions-file/file.qbs @@ -33,10 +33,10 @@ Product { if (!created || !File.exists(zePath)) throw new Error("zePath was not created."); var entries = File.directoryEntries(product.sourceDirectory, File.AllEntries | File.NoDotAndDotDot); - if (entries.length < 3 || !entries.contains("file.qbs")) + if (entries.length < 3 || !entries.includes("file.qbs")) throw new Error("Directory did not contain file.qbs"); entries = File.directoryEntries(product.sourceDirectory, File.Dirs | File.NoDotAndDotDot); - if (entries.length < 1 || !entries.contains("zePath")) + if (entries.length < 1 || !entries.includes("zePath")) throw new Error("Directory did not contain only zePath"); var moveSource = FileInfo.joinPaths(product.sourceDirectory, "tomove.txt"); var moveTarget = FileInfo.joinPaths(product.sourceDirectory, "moved.txt"); diff --git a/tests/auto/blackbox/testdata/jsextensions-fileinfo/fileinfo.qbs b/tests/auto/blackbox/testdata/jsextensions-fileinfo/fileinfo.qbs index d63ba2962..0e727d04b 100644 --- a/tests/auto/blackbox/testdata/jsextensions-fileinfo/fileinfo.qbs +++ b/tests/auto/blackbox/testdata/jsextensions-fileinfo/fileinfo.qbs @@ -39,6 +39,8 @@ Product { output.writeLine(FileInfo.relativePath("/tmp", "/blubb.tar.gz")); output.writeLine(FileInfo.toWindowsSeparators("/tmp/blubb.tar.gz")); output.writeLine(FileInfo.toWindowsSeparators("c:\\tmp\\blubb.tar.gz")); + output.writeLine(FileInfo.pathListSeparator()); + output.writeLine(FileInfo.pathSeparator()); output.close(); }; return [cmd]; diff --git a/tests/auto/blackbox/testdata/jsextensions-host/host.qbs b/tests/auto/blackbox/testdata/jsextensions-host/host.qbs new file mode 100644 index 000000000..08d13b25d --- /dev/null +++ b/tests/auto/blackbox/testdata/jsextensions-host/host.qbs @@ -0,0 +1,31 @@ +import qbs.FileInfo +import qbs.Host +import qbs.TextFile + +Product { + type: ["dummy"] + Rule { + multiplex: true + outputFileTags: "dummy" + prepare: { + var cmd = new JavaScriptCommand(); + cmd.silent = true; + cmd.sourceCode = function() { + var output = new TextFile(FileInfo.joinPaths(product.sourceDirectory, "output.txt"), + TextFile.WriteOnly); + output.writeLine("architecture: " +Host.architecture()); + output.writeLine("os: " + Host.os()); + output.writeLine("platform: " + Host.platform()); + output.writeLine("osVersion: " + Host.osVersion()); + output.writeLine("osBuildVersion: " + Host.osBuildVersion()); + output.writeLine("osVersionParts: " + Host.osVersionParts()); + output.writeLine("osVersionMajor: " + Host.osVersionMajor()); + output.writeLine("osVersionMinor: " + Host.osVersionMinor()); + output.writeLine("osVersionPatch: " + Host.osVersionPatch()); + output.writeLine("nullDevice: " + Host.nullDevice()); + output.close(); + }; + return [cmd]; + } + } +} diff --git a/tests/auto/blackbox/testdata/jsextensions-process/process.qbs b/tests/auto/blackbox/testdata/jsextensions-process/process.qbs index b634a8056..50f22cdfc 100644 --- a/tests/auto/blackbox/testdata/jsextensions-process/process.qbs +++ b/tests/auto/blackbox/testdata/jsextensions-process/process.qbs @@ -1,12 +1,13 @@ import qbs.Environment import qbs.FileInfo +import qbs.Host import qbs.Process import qbs.TextFile Project { Product { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; @@ -54,7 +55,7 @@ Project { // closeWriteChannel test process = new Process(); - if (product.qbs.hostOS.contains("windows")) + if (Host.os().includes("windows")) process.start(product.qbs.windowsShellPath, ["/C", product.qbs.windowsSystemRoot + "\\system32\\sort.exe"]); else @@ -75,7 +76,7 @@ Project { testReadlineFile.close(); process = new Process(); - if (product.qbs.hostOS.contains("windows")) + if (Host.os().includes("windows")) process.exec(product.qbs.windowsShellPath, ["/C", "type", "123.txt"], true); diff --git a/tests/auto/blackbox/testdata/ld/ld.qbs b/tests/auto/blackbox/testdata/ld/ld.qbs index 25fede1b0..cb04d3d9a 100644 --- a/tests/auto/blackbox/testdata/ld/ld.qbs +++ b/tests/auto/blackbox/testdata/ld/ld.qbs @@ -5,7 +5,7 @@ Project { targetName: "qbs can handle any file paths, even the crazy ones! ;)" files: ["coreutils.cpp", "coreutils.h"] Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false cpp.sonamePrefix: "@rpath" } diff --git a/tests/auto/blackbox/testdata/ld/main.cpp b/tests/auto/blackbox/testdata/ld/main.cpp index fd6b72f3b..bcf293705 100644 --- a/tests/auto/blackbox/testdata/ld/main.cpp +++ b/tests/auto/blackbox/testdata/ld/main.cpp @@ -27,10 +27,11 @@ ****************************************************************************/ #include "coreutils.h" -#include <stdio.h> + +#include <cstdio> int main(int argc, char *argv[]) { - printf("%d\n", foo()); + std::printf("%d\n", foo()); return 0; } diff --git a/tests/auto/blackbox/testdata/lexyacc/modules/bisonhelper/bisonhelper.qbs b/tests/auto/blackbox/testdata/lexyacc/modules/bisonhelper/bisonhelper.qbs index cb93547d4..4cce9a1e3 100644 --- a/tests/auto/blackbox/testdata/lexyacc/modules/bisonhelper/bisonhelper.qbs +++ b/tests/auto/blackbox/testdata/lexyacc/modules/bisonhelper/bisonhelper.qbs @@ -7,7 +7,7 @@ Module { property string yaccBinary: lex_yacc.yaccBinary configure: { var p = Process(); - found = p.exec(yaccBinary, ["-V"]) == 0 && p.readStdOut().contains("bison"); + found = p.exec(yaccBinary, ["-V"]) == 0 && p.readStdOut().includes("bison"); p.close(); } } diff --git a/tests/auto/blackbox/testdata/lexyacc/one-grammar/one-grammar.qbs b/tests/auto/blackbox/testdata/lexyacc/one-grammar/one-grammar.qbs index ec4ede648..faa5d1fac 100644 --- a/tests/auto/blackbox/testdata/lexyacc/one-grammar/one-grammar.qbs +++ b/tests/auto/blackbox/testdata/lexyacc/one-grammar/one-grammar.qbs @@ -1,6 +1,8 @@ +import qbs.Host + CppApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; @@ -17,10 +19,10 @@ CppApplication { Probe { id: pathCheck property string theDir: { - if (qbs.targetOS.contains("windows")) { - if (qbs.toolchain.contains("mingw")) + if (qbs.targetOS.includes("windows")) { + if (qbs.toolchain.includes("mingw")) return cpp.toolchainInstallPath; - if (qbs.toolchain.contains("clang") && qbs.sysroot) + if (qbs.toolchain.includes("clang") && qbs.sysroot) return qbs.sysroot + "/bin"; } } diff --git a/tests/auto/blackbox/testdata/lexyacc/two-grammars/two-grammars.qbs b/tests/auto/blackbox/testdata/lexyacc/two-grammars/two-grammars.qbs index 025b2109e..648860d9c 100644 --- a/tests/auto/blackbox/testdata/lexyacc/two-grammars/two-grammars.qbs +++ b/tests/auto/blackbox/testdata/lexyacc/two-grammars/two-grammars.qbs @@ -1,9 +1,11 @@ +import qbs.Host + CppApplication { Depends { name: "lex_yacc" } consoleApplication: true cpp.includePaths: ".." Properties { - condition: qbs.hostOS.contains("darwin") && qbs.toolchain.contains("clang") + condition: Host.os().includes("darwin") && qbs.toolchain.includes("clang") cpp.cFlags: "-Wno-implicit-function-declaration" } files: [ diff --git a/tests/auto/blackbox/testdata/linker-library-duplicates/setup-run-environment.qbs b/tests/auto/blackbox/testdata/linker-library-duplicates/setup-run-environment.qbs index e69cde064..c41e8f1d7 100644 --- a/tests/auto/blackbox/testdata/linker-library-duplicates/setup-run-environment.qbs +++ b/tests/auto/blackbox/testdata/linker-library-duplicates/setup-run-environment.qbs @@ -6,6 +6,11 @@ Project { files: ["lib1.cpp"] Depends { name: "bundle" } bundle.isBundle: false + Probe { + id: checker + property bool isGcc: qbs.toolchain.contains("gcc") + configure: { console.info("is gcc: " + isGcc); } + } } DynamicLibrary { diff --git a/tests/auto/blackbox/testdata/linker-module-definition/linker-module-definition.qbs b/tests/auto/blackbox/testdata/linker-module-definition/linker-module-definition.qbs index 7425cdca5..cae80e651 100644 --- a/tests/auto/blackbox/testdata/linker-module-definition/linker-module-definition.qbs +++ b/tests/auto/blackbox/testdata/linker-module-definition/linker-module-definition.qbs @@ -1,6 +1,8 @@ +import qbs.Host + Project { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata/linker-variant/linker-variant.qbs b/tests/auto/blackbox/testdata/linker-variant/linker-variant.qbs index 57bd4ccba..9256bf767 100644 --- a/tests/auto/blackbox/testdata/linker-variant/linker-variant.qbs +++ b/tests/auto/blackbox/testdata/linker-variant/linker-variant.qbs @@ -3,7 +3,7 @@ CppApplication { property string linkerVariant Probe { id: gccProbe - property bool isGcc: qbs.toolchain.contains("gcc") + property bool isGcc: qbs.toolchain.includes("gcc") configure: { console.info("is GCC: " + isGcc); if (isGcc) diff --git a/tests/auto/blackbox/testdata/linkerMode/darwin.s b/tests/auto/blackbox/testdata/linkerMode/darwin.s new file mode 100644 index 000000000..fb165114b --- /dev/null +++ b/tests/auto/blackbox/testdata/linkerMode/darwin.s @@ -0,0 +1,6 @@ +.globl _main +.globl main + +_main: +main: + ret diff --git a/tests/auto/blackbox/testdata/linkerMode/linkerMode.qbs b/tests/auto/blackbox/testdata/linkerMode/linkerMode.qbs index 1be50c0aa..176730ce0 100644 --- a/tests/auto/blackbox/testdata/linkerMode/linkerMode.qbs +++ b/tests/auto/blackbox/testdata/linkerMode/linkerMode.qbs @@ -2,7 +2,7 @@ Project { CppApplication { consoleApplication: true name: "LinkedProduct-Assembly" - files: ["main.s"] + files: qbs.targetOS.includes("darwin") ? "darwin.s" : "main.s" cpp.linkerPath: cpp.compilerPathByLanguage["c"] @@ -24,7 +24,7 @@ Project { } CppApplication { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") consoleApplication: true name: "LinkedProduct-Objective-C" @@ -50,7 +50,7 @@ Project { } CppApplication { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") consoleApplication: true name: "LinkedProduct-Objective-C++" diff --git a/tests/auto/blackbox/testdata/linkerscripts/linkerscripts.qbs b/tests/auto/blackbox/testdata/linkerscripts/linkerscripts.qbs index 0b4de0ab9..6d068b6a2 100644 --- a/tests/auto/blackbox/testdata/linkerscripts/linkerscripts.qbs +++ b/tests/auto/blackbox/testdata/linkerscripts/linkerscripts.qbs @@ -55,6 +55,13 @@ DynamicLibrary { } } + Probe { + id: checker + property bool isGcc: qbs.toolchain.contains("gcc") + property bool isLinux: qbs.targetOS.contains("linux") + configure: { console.info("is Linux gcc: " + (isGcc && isLinux)) } + } + qbs.installPrefix: "" install: true installDir: "" diff --git a/tests/auto/blackbox/testdata/loadablemodule/loadablemodule.qbs b/tests/auto/blackbox/testdata/loadablemodule/loadablemodule.qbs index 5749480cc..8023eed36 100644 --- a/tests/auto/blackbox/testdata/loadablemodule/loadablemodule.qbs +++ b/tests/auto/blackbox/testdata/loadablemodule/loadablemodule.qbs @@ -1,8 +1,10 @@ +import qbs.Host + Project { LoadableModule { Depends { name: "cpp" } Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } name: "CoolPlugIn" @@ -16,7 +18,7 @@ Project { CppApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; @@ -28,10 +30,10 @@ Project { files: ["main.cpp"] cpp.cxxLanguageVersion: "c++11" - cpp.dynamicLibraries: [qbs.targetOS.contains("windows") ? "kernel32" : "dl"] + cpp.dynamicLibraries: [qbs.targetOS.includes("windows") ? "kernel32" : "dl"] Properties { - condition: qbs.targetOS.contains("unix") && !qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("unix") && !qbs.targetOS.includes("darwin") cpp.rpaths: [cpp.rpathOrigin] } diff --git a/tests/auto/blackbox/testdata/localDeployment/localDeployment.qbs b/tests/auto/blackbox/testdata/localDeployment/localDeployment.qbs index 856642689..b3fa86d32 100644 --- a/tests/auto/blackbox/testdata/localDeployment/localDeployment.qbs +++ b/tests/auto/blackbox/testdata/localDeployment/localDeployment.qbs @@ -1,7 +1,9 @@ +import qbs.Host + Project { Product { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata/lsp/lsp.qbs b/tests/auto/blackbox/testdata/lsp/lsp.qbs new file mode 100644 index 000000000..24479e0ec --- /dev/null +++ b/tests/auto/blackbox/testdata/lsp/lsp.qbs @@ -0,0 +1,11 @@ +Project { + Product { + name: "dep" + Depends { name: "m" } + Depends { name: "Prefix"; submodules: ["m1", "m2", "m3"] } + + } + Product { + Depends { name: "dep" } + } +} diff --git a/tests/auto/blackbox/testdata/lsp/modules/Prefix/m1/m1.qbs b/tests/auto/blackbox/testdata/lsp/modules/Prefix/m1/m1.qbs new file mode 100644 index 000000000..09bac2dc2 --- /dev/null +++ b/tests/auto/blackbox/testdata/lsp/modules/Prefix/m1/m1.qbs @@ -0,0 +1,5 @@ +Module { + property bool p1 + property string p2 + property bool x +} diff --git a/tests/auto/blackbox/testdata/lsp/modules/Prefix/m2/m2.qbs b/tests/auto/blackbox/testdata/lsp/modules/Prefix/m2/m2.qbs new file mode 100644 index 000000000..84957060c --- /dev/null +++ b/tests/auto/blackbox/testdata/lsp/modules/Prefix/m2/m2.qbs @@ -0,0 +1,2 @@ +Module { +} diff --git a/tests/auto/blackbox/testdata/lsp/modules/Prefix/m3/m3.qbs b/tests/auto/blackbox/testdata/lsp/modules/Prefix/m3/m3.qbs new file mode 100644 index 000000000..84957060c --- /dev/null +++ b/tests/auto/blackbox/testdata/lsp/modules/Prefix/m3/m3.qbs @@ -0,0 +1,2 @@ +Module { +} diff --git a/tests/auto/blackbox/testdata/lsp/modules/m/m.qbs b/tests/auto/blackbox/testdata/lsp/modules/m/m.qbs new file mode 100644 index 000000000..84957060c --- /dev/null +++ b/tests/auto/blackbox/testdata/lsp/modules/m/m.qbs @@ -0,0 +1,2 @@ +Module { +} diff --git a/tests/auto/blackbox/testdata/makefile-generator/app.qbs b/tests/auto/blackbox/testdata/makefile-generator/app.qbs index 2f53c4808..fd3fbb91b 100644 --- a/tests/auto/blackbox/testdata/makefile-generator/app.qbs +++ b/tests/auto/blackbox/testdata/makefile-generator/app.qbs @@ -1,6 +1,8 @@ +import qbs.Host + CppApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; @@ -11,7 +13,7 @@ CppApplication { cpp.cxxLanguageVersion: "c++11" cpp.separateDebugInformation: false Properties { - condition: qbs.targetOS.contains("macos") + condition: qbs.targetOS.includes("macos") bundle.embedInfoPlist: false cpp.minimumMacosVersion: "10.7" } diff --git a/tests/auto/blackbox/testdata/maximum-c-language-version/maximum-c-language-version.qbs b/tests/auto/blackbox/testdata/maximum-c-language-version/maximum-c-language-version.qbs index 320494d00..9f41570f8 100644 --- a/tests/auto/blackbox/testdata/maximum-c-language-version/maximum-c-language-version.qbs +++ b/tests/auto/blackbox/testdata/maximum-c-language-version/maximum-c-language-version.qbs @@ -4,10 +4,13 @@ CppApplication { Probe { id: osProbe - property stringList toolchain: qbs.toolchain + property string toolchainType: qbs.toolchainType + property string compilerVersion: cpp.compilerVersion configure: { - if (toolchain.contains("msvc")) - console.info("is msvc"); + console.info("is msvc: " + (toolchainType === "msvc" || toolchainType === "clang-cl")); + var isOld = (toolchainType === "msvc" && compilerVersion < "19.29.30138") + || (toolchainType === "clang-cl" && compilerVersion < "13"); + console.info("is old msvc: " + isOld); found = true; } } diff --git a/tests/auto/blackbox/testdata/minimumSystemVersion/fakewindows.qbs b/tests/auto/blackbox/testdata/minimumSystemVersion/fakewindows.qbs index 1a56e0b7e..da836e609 100644 --- a/tests/auto/blackbox/testdata/minimumSystemVersion/fakewindows.qbs +++ b/tests/auto/blackbox/testdata/minimumSystemVersion/fakewindows.qbs @@ -4,7 +4,7 @@ import qbs.Utilities // (but will still compile and link since we avoid passing a // bad value to the linker) CppApplication { - condition: qbs.targetOS.contains("windows") + condition: qbs.targetOS.includes("windows") files: ["main.cpp"] consoleApplication: true cpp.minimumWindowsVersion: "5.3" diff --git a/tests/auto/blackbox/testdata/minimumSystemVersion/macappstore.qbs b/tests/auto/blackbox/testdata/minimumSystemVersion/macappstore.qbs index 8ae787b9a..26a94e132 100644 --- a/tests/auto/blackbox/testdata/minimumSystemVersion/macappstore.qbs +++ b/tests/auto/blackbox/testdata/minimumSystemVersion/macappstore.qbs @@ -1,12 +1,14 @@ // just to make sure three-digit minimum versions work on macOS // this only affects the value of __MAC_OS_X_VERSION_MIN_REQUIRED, // not the actual LC_VERSION_MIN_MACOSX command which is limited to two +import qbs.Host + CppApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); - return result && qbs.targetOS.contains("macos"); + return result && qbs.targetOS.includes("macos"); } files: ["main.mm"] consoleApplication: true diff --git a/tests/auto/blackbox/testdata/minimumSystemVersion/specific.qbs b/tests/auto/blackbox/testdata/minimumSystemVersion/specific.qbs index 8099d79b9..b2b67642a 100644 --- a/tests/auto/blackbox/testdata/minimumSystemVersion/specific.qbs +++ b/tests/auto/blackbox/testdata/minimumSystemVersion/specific.qbs @@ -3,27 +3,29 @@ import qbs.Utilities // a specific version of the operating systems is specified // when the application is run its output should confirm // that the given values took effect +import qbs.Host + CppApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); - return result && qbs.targetOS.contains("windows") || qbs.targetOS.contains("macos"); + return result && qbs.targetOS.includes("windows") || qbs.targetOS.includes("macos"); } - files: [qbs.targetOS.contains("darwin") ? "main.mm" : "main.cpp"] + files: [qbs.targetOS.includes("darwin") ? "main.mm" : "main.cpp"] consoleApplication: true Properties { - condition: qbs.targetOS.contains("windows") - cpp.minimumWindowsVersion: "6.0" + condition: qbs.targetOS.includes("windows") + cpp.minimumWindowsVersion: "6.2" cpp.defines: [ - "QBS_WINVER=0x600", + "QBS_WINVER=0x602", "TOOLCHAIN_INSTALL_PATH=" + Utilities.cStringQuote(cpp.toolchainInstallPath) ] } Properties { - condition: qbs.targetOS.contains("macos") + condition: qbs.targetOS.includes("macos") cpp.frameworks: "Foundation" cpp.minimumMacosVersion: "10.7" } diff --git a/tests/auto/blackbox/testdata/minimumSystemVersion/unspecified-forced.qbs b/tests/auto/blackbox/testdata/minimumSystemVersion/unspecified-forced.qbs index c0b70a0b2..adb61a6d8 100644 --- a/tests/auto/blackbox/testdata/minimumSystemVersion/unspecified-forced.qbs +++ b/tests/auto/blackbox/testdata/minimumSystemVersion/unspecified-forced.qbs @@ -2,14 +2,16 @@ import qbs.Utilities // no minimum versions are specified, and explicitly set to undefined in // case the profile has set it +import qbs.Host + CppApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; } - files: [qbs.targetOS.contains("darwin") ? "main.mm" : "main.cpp"] + files: [qbs.targetOS.includes("darwin") ? "main.mm" : "main.cpp"] consoleApplication: true cpp.minimumWindowsVersion: undefined cpp.minimumMacosVersion: undefined @@ -17,12 +19,12 @@ CppApplication { cpp.minimumAndroidVersion: undefined Properties { - condition: qbs.targetOS.contains("windows") + condition: qbs.targetOS.includes("windows") cpp.defines: ["TOOLCHAIN_INSTALL_PATH=" + Utilities.cStringQuote(cpp.toolchainInstallPath)] } Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") cpp.frameworks: "Foundation" } } diff --git a/tests/auto/blackbox/testdata/minimumSystemVersion/unspecified.qbs b/tests/auto/blackbox/testdata/minimumSystemVersion/unspecified.qbs index a27ffcd28..3c6559c39 100644 --- a/tests/auto/blackbox/testdata/minimumSystemVersion/unspecified.qbs +++ b/tests/auto/blackbox/testdata/minimumSystemVersion/unspecified.qbs @@ -1,23 +1,25 @@ import qbs.Utilities // no minimum versions are specified so the profile defaults will be used +import qbs.Host + CppApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; } - files: [qbs.targetOS.contains("darwin") ? "main.mm" : "main.cpp"] + files: [qbs.targetOS.includes("darwin") ? "main.mm" : "main.cpp"] consoleApplication: true Properties { - condition: qbs.targetOS.contains("windows") + condition: qbs.targetOS.includes("windows") cpp.defines: ["TOOLCHAIN_INSTALL_PATH=" + Utilities.cStringQuote(cpp.toolchainInstallPath)] } Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") cpp.frameworks: "Foundation" } } diff --git a/tests/auto/blackbox/testdata/concurrent-executor/dummy1.input b/tests/auto/blackbox/testdata/msvc-asm-flags/include/header.inc index e69de29bb..e69de29bb 100644 --- a/tests/auto/blackbox/testdata/concurrent-executor/dummy1.input +++ b/tests/auto/blackbox/testdata/msvc-asm-flags/include/header.inc diff --git a/tests/auto/blackbox/testdata/msvc-asm-flags/msvc-asm-flags.asm b/tests/auto/blackbox/testdata/msvc-asm-flags/msvc-asm-flags.asm new file mode 100644 index 000000000..eddc49131 --- /dev/null +++ b/tests/auto/blackbox/testdata/msvc-asm-flags/msvc-asm-flags.asm @@ -0,0 +1,8 @@ +include header.inc + +.code +main proc + mov ecx, 16 +main endp + +end
\ No newline at end of file diff --git a/tests/auto/blackbox/testdata/msvc-asm-flags/msvc-asm-flags.qbs b/tests/auto/blackbox/testdata/msvc-asm-flags/msvc-asm-flags.qbs new file mode 100644 index 000000000..d632098c9 --- /dev/null +++ b/tests/auto/blackbox/testdata/msvc-asm-flags/msvc-asm-flags.qbs @@ -0,0 +1,6 @@ +StaticLibrary { + condition: qbs.toolchain.includes("msvc") + Depends { name: "cpp" } + files: "msvc-asm-flags.asm" + cpp.assemblerFlags: ["/I", "include"] +} diff --git a/tests/auto/blackbox/testdata/multiplexed-tool/multiplexed-tool.qbs b/tests/auto/blackbox/testdata/multiplexed-tool/multiplexed-tool.qbs index 7f620f310..1ec51c354 100644 --- a/tests/auto/blackbox/testdata/multiplexed-tool/multiplexed-tool.qbs +++ b/tests/auto/blackbox/testdata/multiplexed-tool/multiplexed-tool.qbs @@ -1,9 +1,11 @@ +import qbs.Host + Project { CppApplication { name: "tool" consoleApplication: true property bool _testPlatform: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata/nested-properties/modules/lowerlevel/lower-level.qbs b/tests/auto/blackbox/testdata/nested-properties/modules/lowerlevel/lower-level.qbs index f8b6a7dc0..a5a6c7d4b 100644 --- a/tests/auto/blackbox/testdata/nested-properties/modules/lowerlevel/lower-level.qbs +++ b/tests/auto/blackbox/testdata/nested-properties/modules/lowerlevel/lower-level.qbs @@ -10,7 +10,7 @@ Module { var cmd = new JavaScriptCommand(); cmd.sourceCode = function() { }; var prop = product.lowerlevel.prop; - cmd.description = "lowerlevel.prop is '" + prop + "'."; + cmd.description = "lowerlevel.prop is '" + prop + "'"; return [cmd]; } } diff --git a/tests/auto/blackbox/testdata/no-exported-symbols/no-exported-symbols.qbs b/tests/auto/blackbox/testdata/no-exported-symbols/no-exported-symbols.qbs index 346a94e21..9aad3d032 100644 --- a/tests/auto/blackbox/testdata/no-exported-symbols/no-exported-symbols.qbs +++ b/tests/auto/blackbox/testdata/no-exported-symbols/no-exported-symbols.qbs @@ -12,7 +12,7 @@ Project { id: toolchainProbe property stringList toolchain: qbs.toolchain configure: { - if (toolchain.contains("msvc") && !toolchain.contains("clang-cl")) + if (toolchain.includes("msvc") && !toolchain.includes("clang-cl")) console.info("compiler is MSVC") else console.info("compiler is not MSVC") diff --git a/tests/auto/blackbox/testdata/nodejs/hello.qbs b/tests/auto/blackbox/testdata/nodejs/hello.qbs index d7c545922..849a8789f 100644 --- a/tests/auto/blackbox/testdata/nodejs/hello.qbs +++ b/tests/auto/blackbox/testdata/nodejs/hello.qbs @@ -1,6 +1,8 @@ +import qbs.Host + NodeJSApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata/nsis/hello.qbs b/tests/auto/blackbox/testdata/nsis/hello.qbs index a161a6998..f70f27e2b 100644 --- a/tests/auto/blackbox/testdata/nsis/hello.qbs +++ b/tests/auto/blackbox/testdata/nsis/hello.qbs @@ -1,5 +1,5 @@ NSISSetup { - condition: qbs.targetOS.contains("windows") + condition: qbs.targetOS.includes("windows") name: "Qbs Hello" targetName: "qbs-hello-" + qbs.architecture files: ["hello.nsi", "hello.bat"] diff --git a/tests/auto/blackbox/testdata/nsisDependencies/nsisDependencies.qbs b/tests/auto/blackbox/testdata/nsisDependencies/nsisDependencies.qbs index d8185aabf..a4ce92067 100644 --- a/tests/auto/blackbox/testdata/nsisDependencies/nsisDependencies.qbs +++ b/tests/auto/blackbox/testdata/nsisDependencies/nsisDependencies.qbs @@ -2,7 +2,7 @@ import qbs.FileInfo import qbs.TextFile Project { - condition: qbs.targetOS.contains("windows") + condition: qbs.targetOS.includes("windows") NSISSetup { Depends { name: "app" } diff --git a/tests/auto/blackbox/testdata/output-redirection/output-redirection.qbs b/tests/auto/blackbox/testdata/output-redirection/output-redirection.qbs index 3ee443438..d2474cecf 100644 --- a/tests/auto/blackbox/testdata/output-redirection/output-redirection.qbs +++ b/tests/auto/blackbox/testdata/output-redirection/output-redirection.qbs @@ -1,4 +1,5 @@ import qbs.FileInfo +import qbs.Host Product { name: "the-product" @@ -21,7 +22,7 @@ Product { prepare: { var binary; var prefixArgs; - if (product.qbs.hostOS.contains("windows")) { + if (Host.os().includes("windows")) { binary = product.qbs.windowsShellPath; prefixArgs = ["/c", "type"]; } else { diff --git a/tests/auto/blackbox/testdata/overrideProjectProperties/helper_lib.qbs b/tests/auto/blackbox/testdata/overrideProjectProperties/helper_lib.qbs index b69dd0da8..c7eab99e2 100644 --- a/tests/auto/blackbox/testdata/overrideProjectProperties/helper_lib.qbs +++ b/tests/auto/blackbox/testdata/overrideProjectProperties/helper_lib.qbs @@ -3,7 +3,7 @@ DynamicLibrary { files: "helperlib.cpp" Depends { name: "cpp" } Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } } diff --git a/tests/auto/blackbox/testdata/path-list-in-probe/main.cpp b/tests/auto/blackbox/testdata/path-list-in-probe/main.cpp new file mode 100644 index 000000000..5bc549337 --- /dev/null +++ b/tests/auto/blackbox/testdata/path-list-in-probe/main.cpp @@ -0,0 +1,4 @@ +int main() +{ + return 0; +}
\ No newline at end of file diff --git a/tests/auto/blackbox/testdata/path-list-in-probe/path-list-in-probe.qbs b/tests/auto/blackbox/testdata/path-list-in-probe/path-list-in-probe.qbs new file mode 100644 index 000000000..3bf36367a --- /dev/null +++ b/tests/auto/blackbox/testdata/path-list-in-probe/path-list-in-probe.qbs @@ -0,0 +1,18 @@ +Project { + CppApplication { + Probe { + id: theProbe + property pathList result + configure: { + result = ["main.cpp"] + found = true + } + } + property pathList res: theProbe.found ? theProbe.result : [] + + Group { + name: "files" + files: res + } + } +} diff --git a/tests/auto/blackbox/testdata/path-probe/candidate-filter.qbs b/tests/auto/blackbox/testdata/path-probe/candidate-filter.qbs index c40f22736..5c259ae9b 100644 --- a/tests/auto/blackbox/testdata/path-probe/candidate-filter.qbs +++ b/tests/auto/blackbox/testdata/path-probe/candidate-filter.qbs @@ -4,8 +4,9 @@ BaseApp { inputNames: ["tool.1", "tool.2"] inputSearchPaths: "bin" inputCandidateFilter: { + var fi = FileInfo; return function(f) { - return FileInfo.fileName(f) == "tool.2"; + return fi.fileName(f) == "tool.2"; } } outputFilePaths: ["bin/tool.2"] diff --git a/tests/auto/blackbox/testdata/plugin-dependency/helper1.cpp b/tests/auto/blackbox/testdata/plugin-dependency/helper1.cpp index 72331da80..15a3e0d86 100644 --- a/tests/auto/blackbox/testdata/plugin-dependency/helper1.cpp +++ b/tests/auto/blackbox/testdata/plugin-dependency/helper1.cpp @@ -1,4 +1,4 @@ -#include <stdio.h> +#include <cstdio> #if defined(_WIN32) || defined(WIN32) # define EXPORT __declspec(dllexport) @@ -12,5 +12,5 @@ EXPORT void helper1_hello() { - puts("helper1 says hello!"); + std::puts("helper1 says hello!"); } diff --git a/tests/auto/blackbox/testdata/plugin-dependency/helper2.cpp b/tests/auto/blackbox/testdata/plugin-dependency/helper2.cpp index cdcdfc942..dccd72a04 100644 --- a/tests/auto/blackbox/testdata/plugin-dependency/helper2.cpp +++ b/tests/auto/blackbox/testdata/plugin-dependency/helper2.cpp @@ -1,7 +1,7 @@ #include "../dllexport.h" -#include <stdio.h> +#include <cstdio> DLL_EXPORT void helper2_hello() { - puts("Hello from helper2!"); + std::puts("Hello from helper2!"); } diff --git a/tests/auto/blackbox/testdata/plugin-dependency/plugin-dependency.qbs b/tests/auto/blackbox/testdata/plugin-dependency/plugin-dependency.qbs index c619b33ef..752673b78 100644 --- a/tests/auto/blackbox/testdata/plugin-dependency/plugin-dependency.qbs +++ b/tests/auto/blackbox/testdata/plugin-dependency/plugin-dependency.qbs @@ -1,16 +1,18 @@ +import qbs.Host + Project { CppApplication { name: "myapp" files: ["main.cpp"] Depends { name: "plugin1" // not to be linked - cpp.link: qbs.hostOS === undefined + cpp.link: Host.os() === undefined } Depends { name: "plugin2" } // not to be linked Depends { name: "plugin3" // supposed to be linked - //property bool theCondition: true - cpp.link: /*theCondition && */product.name === "myapp" // TODO: Make this work + property bool theCondition: true + cpp.link: theCondition && product.name === "myapp" } Depends { name: "plugin4" } // supposed to be linked Depends { name: "helper1" } // supposed to be linked diff --git a/tests/auto/blackbox/testdata/plugin-dependency/plugin1.cpp b/tests/auto/blackbox/testdata/plugin-dependency/plugin1.cpp index 2535bd85e..8cf7e3851 100644 --- a/tests/auto/blackbox/testdata/plugin-dependency/plugin1.cpp +++ b/tests/auto/blackbox/testdata/plugin-dependency/plugin1.cpp @@ -1,7 +1,7 @@ #include "../dllexport.h" -#include <stdio.h> +#include <cstdio> DLL_EXPORT void plugin1_hello() { - puts("plugin1 says hello!"); + std::puts("plugin1 says hello!"); } diff --git a/tests/auto/blackbox/testdata/plugin-dependency/plugin2.cpp b/tests/auto/blackbox/testdata/plugin-dependency/plugin2.cpp index fb2030d60..9efc83e2b 100644 --- a/tests/auto/blackbox/testdata/plugin-dependency/plugin2.cpp +++ b/tests/auto/blackbox/testdata/plugin-dependency/plugin2.cpp @@ -1,7 +1,7 @@ #include "../dllexport.h" -#include <stdio.h> +#include <cstdio> DLL_EXPORT void plugin2_hello() { - puts("plugin2 says hello!"); + std::puts("plugin2 says hello!"); } diff --git a/tests/auto/blackbox/testdata/plugin-dependency/plugin3.cpp b/tests/auto/blackbox/testdata/plugin-dependency/plugin3.cpp index 8a9f5ee76..0e08ac85a 100644 --- a/tests/auto/blackbox/testdata/plugin-dependency/plugin3.cpp +++ b/tests/auto/blackbox/testdata/plugin-dependency/plugin3.cpp @@ -1,7 +1,7 @@ #include "../dllexport.h" -#include <stdio.h> +#include <cstdio> DLL_EXPORT void plugin3_hello() { - puts("plugin3 says hello!"); + std::puts("plugin3 says hello!"); } diff --git a/tests/auto/blackbox/testdata/plugin-dependency/plugin4.cpp b/tests/auto/blackbox/testdata/plugin-dependency/plugin4.cpp index 4663247fa..cee2362ec 100644 --- a/tests/auto/blackbox/testdata/plugin-dependency/plugin4.cpp +++ b/tests/auto/blackbox/testdata/plugin-dependency/plugin4.cpp @@ -1,7 +1,7 @@ #include "../dllexport.h" -#include <stdio.h> +#include <cstdio> DLL_EXPORT void plugin4_hello() { - puts("plugin4 says hello!"); + std::puts("plugin4 says hello!"); } diff --git a/tests/auto/blackbox/testdata/precompiled-headers-and-redefine/precompiled-headers-and-redefine.qbs b/tests/auto/blackbox/testdata/precompiled-headers-and-redefine/precompiled-headers-and-redefine.qbs index 55b53a7af..3974b514e 100644 --- a/tests/auto/blackbox/testdata/precompiled-headers-and-redefine/precompiled-headers-and-redefine.qbs +++ b/tests/auto/blackbox/testdata/precompiled-headers-and-redefine/precompiled-headers-and-redefine.qbs @@ -8,7 +8,7 @@ CppApplication { Group { files: ["file.cpp"] cpp.defines: ["MYDEF=1"] - cpp.cxxFlags: base.concat(qbs.toolchain.contains("clang-cl") ? ["-Wno-clang-cl-pch"] : []) + cpp.cxxFlags: base.concat(qbs.toolchain.includes("clang-cl") ? ["-Wno-clang-cl-pch"] : []) } cpp.treatWarningsAsErrors: true diff --git a/tests/auto/blackbox/testdata/probe-in-exported-module/modules/depmodule/depmodule.qbs b/tests/auto/blackbox/testdata/probe-in-exported-module/modules/depmodule/depmodule.qbs index 41c6cfe50..45b8e157f 100644 --- a/tests/auto/blackbox/testdata/probe-in-exported-module/modules/depmodule/depmodule.qbs +++ b/tests/auto/blackbox/testdata/probe-in-exported-module/modules/depmodule/depmodule.qbs @@ -7,7 +7,7 @@ Module { outputFileTags: "dep-out" prepare: { var cmd = new JavaScriptCommand(); - cmd.description = "Creating dep-out artifact"; + cmd.description = "creating dep-out artifact"; cmd.sourceCode = function() { console.info("prop: " + product.depmodule.prop); console.info("listProp: " + product.depmodule.listProp); diff --git a/tests/auto/blackbox/testdata/probe-in-exported-module/modules/mymodule/mymodule.qbs b/tests/auto/blackbox/testdata/probe-in-exported-module/modules/mymodule/mymodule.qbs index 89d544f7e..31275aa40 100644 --- a/tests/auto/blackbox/testdata/probe-in-exported-module/modules/mymodule/mymodule.qbs +++ b/tests/auto/blackbox/testdata/probe-in-exported-module/modules/mymodule/mymodule.qbs @@ -13,7 +13,7 @@ Module { outputFileTags: "out" prepare: { var cmd = new JavaScriptCommand(); - cmd.description = "Creating out artifact"; + cmd.description = "creating out artifact"; cmd.sourceCode = function() { console.info("found: " + product.mymodule.found); }; diff --git a/tests/auto/blackbox/testdata/product-dependencies-by-type/product-dependencies-by-type.qbs b/tests/auto/blackbox/testdata/product-dependencies-by-type/product-dependencies-by-type.qbs index 8fa761a2d..8e1f291f3 100644 --- a/tests/auto/blackbox/testdata/product-dependencies-by-type/product-dependencies-by-type.qbs +++ b/tests/auto/blackbox/testdata/product-dependencies-by-type/product-dependencies-by-type.qbs @@ -91,7 +91,7 @@ Project { name: "lib-product" files: "main.cpp" Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } } @@ -116,7 +116,7 @@ Project { } prepare: { var cmd = new JavaScriptCommand(); - cmd.description = "Collecting apps"; + cmd.description = "collecting apps"; cmd.sourceCode = function() { var file = new TextFile(output.filePath, TextFile.WriteOnly); for (var i = 0; i < inputs["application"].length; ++i) diff --git a/tests/auto/blackbox/testdata/product-in-exported-module/product-in-exported-module.qbs b/tests/auto/blackbox/testdata/product-in-exported-module/product-in-exported-module.qbs index f978aa778..3ead0ca6c 100644 --- a/tests/auto/blackbox/testdata/product-in-exported-module/product-in-exported-module.qbs +++ b/tests/auto/blackbox/testdata/product-in-exported-module/product-in-exported-module.qbs @@ -1,6 +1,6 @@ Project { Product { - name: "p" + name: "importing" Depends { name: "dep" } } Product { diff --git a/tests/auto/blackbox/testdata/proper quoting/main.cpp b/tests/auto/blackbox/testdata/proper quoting/main.cpp index 22cafeaa9..6e9be6df1 100644 --- a/tests/auto/blackbox/testdata/proper quoting/main.cpp +++ b/tests/auto/blackbox/testdata/proper quoting/main.cpp @@ -26,16 +26,16 @@ ** ****************************************************************************/ -#include <stdio.h> +#include <cstdio> int bla(); int main() { - printf(DEFINE"\n"); - printf(DEFINEWITHSPACE"\n"); - printf(DEFINEWITHTAB"\n"); - printf(DEFINEWITHBACKSLASH"\n"); + std::printf(DEFINE"\n"); + std::printf(DEFINEWITHSPACE"\n"); + std::printf(DEFINEWITHTAB"\n"); + std::printf(DEFINEWITHBACKSLASH"\n"); return bla(); } diff --git a/tests/auto/blackbox/testdata/proper quoting/my static lib.cpp b/tests/auto/blackbox/testdata/proper quoting/my static lib.cpp index e7490e807..7c07fd4c9 100644 --- a/tests/auto/blackbox/testdata/proper quoting/my static lib.cpp +++ b/tests/auto/blackbox/testdata/proper quoting/my static lib.cpp @@ -26,12 +26,13 @@ ** ****************************************************************************/ -#include <stdio.h> #include <some helper.h> +#include <cstdio> + int bla() { int n = getSomeNumber(); - printf("Hello World! The magic number is %d.", n); + std::printf("Hello World! The magic number is %d.", n); return n; } diff --git a/tests/auto/blackbox/testdata/proper quoting/proper quoting.qbs b/tests/auto/blackbox/testdata/proper quoting/proper quoting.qbs index 3330b8263..1587940a2 100644 --- a/tests/auto/blackbox/testdata/proper quoting/proper quoting.qbs +++ b/tests/auto/blackbox/testdata/proper quoting/proper quoting.qbs @@ -1,7 +1,9 @@ +import qbs.Host + Project { Product { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata/property-assignment-on-non-present-module/property-assignment-on-non-present-module.qbs b/tests/auto/blackbox/testdata/property-assignment-on-non-present-module/property-assignment-on-non-present-module.qbs deleted file mode 100644 index a01d6c561..000000000 --- a/tests/auto/blackbox/testdata/property-assignment-on-non-present-module/property-assignment-on-non-present-module.qbs +++ /dev/null @@ -1,4 +0,0 @@ -Product { - Depends { name: "nein"; required: false } - nein.doch: "ohhh!" -} diff --git a/tests/auto/blackbox/testdata/propertyChanges/modules/TestModule/module.qbs b/tests/auto/blackbox/testdata/propertyChanges/modules/TestModule/module.qbs index b1e4a1fdc..590736f6a 100644 --- a/tests/auto/blackbox/testdata/propertyChanges/modules/TestModule/module.qbs +++ b/tests/auto/blackbox/testdata/propertyChanges/modules/TestModule/module.qbs @@ -18,7 +18,7 @@ Module { prepare: { var cmd = new JavaScriptCommand(); cmd.highlight = "codegen"; - cmd.description = "Making output from input"; + cmd.description = "making output from input"; cmd.sourceCode = function() { // console.info('Change in source code'); console.info(input.TestModule.testProperty); diff --git a/tests/auto/blackbox/testdata/propertyChanges/propertyChanges.qbs b/tests/auto/blackbox/testdata/propertyChanges/propertyChanges.qbs index f13b1986e..29365a887 100644 --- a/tests/auto/blackbox/testdata/propertyChanges/propertyChanges.qbs +++ b/tests/auto/blackbox/testdata/propertyChanges/propertyChanges.qbs @@ -27,7 +27,7 @@ Project { name: "library" files: "lib.cpp" Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } } @@ -80,7 +80,7 @@ Project { prepare: { var cmd = new JavaScriptCommand(); cmd.highlight = "codegen"; - cmd.description = "Making output from other output"; + cmd.description = "making output from other output"; cmd.sourceCode = function() { File.copy(input.filePath, output.filePath); } return cmd; } diff --git a/tests/auto/blackbox/testdata/protobuf-library-install/protobuf-library.qbs b/tests/auto/blackbox/testdata/protobuf-library-install/protobuf-library.qbs index af7e6ced6..501675c15 100644 --- a/tests/auto/blackbox/testdata/protobuf-library-install/protobuf-library.qbs +++ b/tests/auto/blackbox/testdata/protobuf-library-install/protobuf-library.qbs @@ -1,6 +1,8 @@ +import qbs.Host + StaticLibrary { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result && hasProtobuf; diff --git a/tests/auto/blackbox/testdata/protobuf/addressbook_cpp.qbs b/tests/auto/blackbox/testdata/protobuf/addressbook_cpp.qbs index ac97f6bd5..959552ea5 100644 --- a/tests/auto/blackbox/testdata/protobuf/addressbook_cpp.qbs +++ b/tests/auto/blackbox/testdata/protobuf/addressbook_cpp.qbs @@ -1,6 +1,8 @@ +import qbs.Host + CppApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result && hasProtobuf; @@ -9,12 +11,12 @@ CppApplication { consoleApplication: true Depends { name: "cpp" } - cpp.cxxLanguageVersion: "c++11" - cpp.minimumMacosVersion: "10.8" + cpp.minimumMacosVersion: "10.15" 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..3dfc911e1 100644 --- a/tests/auto/blackbox/testdata/protobuf/addressbook_nanopb.qbs +++ b/tests/auto/blackbox/testdata/protobuf/addressbook_nanopb.qbs @@ -1,6 +1,8 @@ +import qbs.Host + CppApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result && hasProtobuf; @@ -9,12 +11,12 @@ CppApplication { consoleApplication: true Depends { name: "cpp" } - cpp.cxxLanguageVersion: "c++11" cpp.minimumMacosVersion: "10.8" 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..7f0b999aa 100644 --- a/tests/auto/blackbox/testdata/protobuf/addressbook_objc.qbs +++ b/tests/auto/blackbox/testdata/protobuf/addressbook_objc.qbs @@ -1,6 +1,8 @@ +import qbs.Host + CppApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result && hasProtobuf; @@ -12,6 +14,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/conanfile.txt b/tests/auto/blackbox/testdata/protobuf/conanfile.txt new file mode 100644 index 000000000..e7d849b1a --- /dev/null +++ b/tests/auto/blackbox/testdata/protobuf/conanfile.txt @@ -0,0 +1,6 @@ +[requires] +protobuf/3.21.12 +[tool_requires] +protobuf/3.21.12 +[generators] +QbsDeps diff --git a/tests/auto/blackbox/testdata/protobuf/create-proto-library.qbs b/tests/auto/blackbox/testdata/protobuf/create-proto-library.qbs index d888937f1..005752fd8 100644 --- a/tests/auto/blackbox/testdata/protobuf/create-proto-library.qbs +++ b/tests/auto/blackbox/testdata/protobuf/create-proto-library.qbs @@ -1,7 +1,9 @@ +import qbs.Host + Project { StaticLibrary { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result && hasProtobuf; @@ -9,7 +11,6 @@ Project { name: "proto_lib" Depends { name: "cpp" } - cpp.cxxLanguageVersion: "c++11" cpp.minimumMacosVersion: "10.8" protobuf.cpp.importPaths: product.sourceDirectory @@ -17,6 +18,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..56d489de8 100644 --- a/tests/auto/blackbox/testdata/protobuf/import.qbs +++ b/tests/auto/blackbox/testdata/protobuf/import.qbs @@ -1,6 +1,8 @@ +import qbs.Host + CppApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result && hasProtobuf; @@ -10,12 +12,12 @@ CppApplication { protobuf.cpp.importPaths: [sourceDirectory] - cpp.cxxLanguageVersion: "c++11" cpp.minimumMacosVersion: "10.8" 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..07be566cb 100644 --- a/tests/auto/blackbox/testdata/protobuf/needs-import-dir.qbs +++ b/tests/auto/blackbox/testdata/protobuf/needs-import-dir.qbs @@ -1,6 +1,8 @@ +import qbs.Host + CppApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result && hasProtobuf; @@ -11,12 +13,12 @@ CppApplication { property path theImportDir protobuf.cpp.importPaths: (theImportDir ? [theImportDir] : []).concat([sourceDirectory]) - cpp.cxxLanguageVersion: "c++11" cpp.minimumMacosVersion: "10.8" 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/qbs-config-import-export/config.json b/tests/auto/blackbox/testdata/qbs-config-import-export/config.json new file mode 100644 index 000000000..edcaf238a --- /dev/null +++ b/tests/auto/blackbox/testdata/qbs-config-import-export/config.json @@ -0,0 +1,11 @@ +{ + "group": { + "key1": "value1", + "key2": "value2" + }, + "key": "value", + "listKey": [ + "valueOne", + "valueTwo" + ] +} diff --git a/tests/auto/blackbox/testdata/qbs-config-import-export/config.txt b/tests/auto/blackbox/testdata/qbs-config-import-export/config.txt new file mode 100644 index 000000000..2bd19c422 --- /dev/null +++ b/tests/auto/blackbox/testdata/qbs-config-import-export/config.txt @@ -0,0 +1,4 @@ +group.key1: "value1" +group.key2: "value2" +key: "value" +listKey: ["valueOne", "valueTwo"] diff --git a/tests/auto/blackbox/testdata/qbspkgconfig-module-provider/libdir/libA.pc b/tests/auto/blackbox/testdata/qbspkgconfig-module-provider/libdir/libA.pc deleted file mode 100644 index 077a05893..000000000 --- a/tests/auto/blackbox/testdata/qbspkgconfig-module-provider/libdir/libA.pc +++ /dev/null @@ -1,6 +0,0 @@ -Name: libA -Description: just a test -Version: 0.0.1 - -Cflags: -DTHE_MAGIC_DEFINE -I/usr/local/include -Libs: -L/usr/local/lib -llibA diff --git a/tests/auto/blackbox/testdata/recursive_wildcards/recursive_wildcards.qbs b/tests/auto/blackbox/testdata/recursive_wildcards/recursive_wildcards.qbs index 4e9da01d3..4fc275877 100644 --- a/tests/auto/blackbox/testdata/recursive_wildcards/recursive_wildcards.qbs +++ b/tests/auto/blackbox/testdata/recursive_wildcards/recursive_wildcards.qbs @@ -23,7 +23,7 @@ Product { } prepare: { var cmd = new JavaScriptCommand(); - cmd.description = "Creating " + output.fileName; + cmd.description = "creating " + output.fileName; cmd.sourceCode = function() { var inputList = explicitlyDependsOn["txt.in"]; var fileNameList = []; diff --git a/tests/auto/blackbox/testdata/remove-duplicate-libs/remove-duplicate-libs.qbs b/tests/auto/blackbox/testdata/remove-duplicate-libs/remove-duplicate-libs.qbs index a6b97bad2..d89e47414 100644 --- a/tests/auto/blackbox/testdata/remove-duplicate-libs/remove-duplicate-libs.qbs +++ b/tests/auto/blackbox/testdata/remove-duplicate-libs/remove-duplicate-libs.qbs @@ -1,4 +1,5 @@ import "MyStaticLib.qbs" as MyStaticLib +import qbs.Host Project { property bool removeDuplicates @@ -6,7 +7,7 @@ Project { property bool dummy: { // most BSD systems (including macOS) use LLVM linker now console.info("is bfd linker: " - + (qbs.toolchain.contains("gcc") && !qbs.hostOS.contains("bsd"))) + + (qbs.toolchain.includes("gcc") && !Host.os().includes("bsd"))) } qbsSearchPaths: "." diff --git a/tests/auto/blackbox/testdata/reproducible-build/reproducible-build.qbs b/tests/auto/blackbox/testdata/reproducible-build/reproducible-build.qbs index f7ed8e61a..fabdf48db 100644 --- a/tests/auto/blackbox/testdata/reproducible-build/reproducible-build.qbs +++ b/tests/auto/blackbox/testdata/reproducible-build/reproducible-build.qbs @@ -2,4 +2,9 @@ CppApplication { name: "the product" files: ["file1.cpp", "file2.cpp", "main.cpp"] cpp.cxxFlags: ["-flto"] + Probe { + id: checker + property bool isGcc: qbs.toolchain.contains("gcc") && !qbs.toolchain.contains("clang") + configure: { console.info("is gcc: " + isGcc); } + } } diff --git a/tests/auto/blackbox/testdata/require-deprecated/blubb.js b/tests/auto/blackbox/testdata/require-deprecated/blubb.js deleted file mode 100644 index 9acc13968..000000000 --- a/tests/auto/blackbox/testdata/require-deprecated/blubb.js +++ /dev/null @@ -1,13 +0,0 @@ -var TextFile = loadExtension("qbs.TextFile") -var zort = loadFile("zort.js") - -function createCommands(filePaths) { - var cmd = new JavaScriptCommand(); - cmd.description = "Write an empty file"; - cmd.filePath = filePaths[0]; - cmd.sourceCode = function() { - var f = new TextFile(filePath, TextFile.WriteOnly); - f.close(); - } - return [cmd, zort.createCommand(filePaths)]; -} diff --git a/tests/auto/blackbox/testdata/require-deprecated/require.qbs b/tests/auto/blackbox/testdata/require-deprecated/require.qbs deleted file mode 100644 index 87d8b054b..000000000 --- a/tests/auto/blackbox/testdata/require-deprecated/require.qbs +++ /dev/null @@ -1,21 +0,0 @@ -import 'blubb.js' as blubb - -Product { - type: ["text"] - Rule { - multiplex: true - Artifact { - fileTags: ["text"] - filePath: "one.txt" - } - Artifact { - fileTags: ["text"] - filePath: "two.txt" - } - prepare: { - var filePaths = outputs.text.map(function (artifact) {return artifact.filePath; }); - return blubb.createCommands(filePaths); - } - } -} - diff --git a/tests/auto/blackbox/testdata/require-deprecated/zort.js b/tests/auto/blackbox/testdata/require-deprecated/zort.js deleted file mode 100644 index 0dcffb767..000000000 --- a/tests/auto/blackbox/testdata/require-deprecated/zort.js +++ /dev/null @@ -1,11 +0,0 @@ -var File = loadExtension("qbs.File") - -function createCommand(filePaths) { - var cmd = new JavaScriptCommand(); - cmd.description = "Create another empty file"; - cmd.filePaths = filePaths; - cmd.sourceCode = function() { - File.copy(filePaths[0], filePaths[1]); - }; - return cmd; -} diff --git a/tests/auto/blackbox/testdata/response-files/response-files.qbs b/tests/auto/blackbox/testdata/response-files/response-files.qbs index 168cdf66a..c18fcac43 100644 --- a/tests/auto/blackbox/testdata/response-files/response-files.qbs +++ b/tests/auto/blackbox/testdata/response-files/response-files.qbs @@ -1,4 +1,5 @@ import qbs.FileInfo +import qbs.Host import qbs.TextFile Project { @@ -9,7 +10,7 @@ Project { } Product { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; @@ -46,7 +47,7 @@ Project { type: ["dynamiclibrary"] // clang-cl does not use response file internally, thus linker complains that command is // too long. This can be worked around by calling the linker directly - cpp.linkerMode: qbs.toolchain.contains("clang-cl") ? "manual" : original + cpp.linkerMode: qbs.toolchain.includes("clang-cl") ? "manual" : original Depends { name: "cpp" } Rule { multiplex: true diff --git a/tests/auto/blackbox/testdata/rpathlink-deduplication/rpathlink-deduplication-lib.cpp b/tests/auto/blackbox/testdata/rpathlink-deduplication/rpathlink-deduplication-lib.cpp new file mode 100644 index 000000000..6418df94d --- /dev/null +++ b/tests/auto/blackbox/testdata/rpathlink-deduplication/rpathlink-deduplication-lib.cpp @@ -0,0 +1,3 @@ +int dynamicFunc() { + return 1; +}
\ No newline at end of file diff --git a/tests/auto/blackbox/testdata/rpathlink-deduplication/rpathlink-deduplication-main.cpp b/tests/auto/blackbox/testdata/rpathlink-deduplication/rpathlink-deduplication-main.cpp new file mode 100644 index 000000000..60f8494f6 --- /dev/null +++ b/tests/auto/blackbox/testdata/rpathlink-deduplication/rpathlink-deduplication-main.cpp @@ -0,0 +1,5 @@ +extern int dynamicFunc(); + +int main() { + return dynamicFunc(); +}
\ No newline at end of file diff --git a/tests/auto/blackbox/testdata/rpathlink-deduplication/rpathlink-deduplication.qbs b/tests/auto/blackbox/testdata/rpathlink-deduplication/rpathlink-deduplication.qbs new file mode 100644 index 000000000..adb63872a --- /dev/null +++ b/tests/auto/blackbox/testdata/rpathlink-deduplication/rpathlink-deduplication.qbs @@ -0,0 +1,47 @@ +Project { + DynamicLibrary { + Depends { name: "bundle" } + Depends { name: "cpp" } + + bundle.isBundle: false + name: "DynamicLibraryA" + files: ["rpathlink-deduplication-lib.cpp"] + } + + DynamicLibrary { + Depends { name: "bundle" } + Depends { name: "cpp" } + Depends { name: "DynamicLibraryA" } + + bundle.isBundle: false + name: "DynamicLibraryB" + files: ["rpathlink-deduplication-lib.cpp"] + } + + DynamicLibrary { + Depends { name: "bundle" } + Depends { name: "cpp" } + Depends { name: "DynamicLibraryA" } + + bundle.isBundle: false + name: "DynamicLibraryC" + files: ["rpathlink-deduplication-lib.cpp"] + } + + CppApplication { + Depends { name: "bundle" } + Depends { name: "DynamicLibraryB" } + Depends { name: "DynamicLibraryC" } + consoleApplication: true + bundle.isBundle: false + cpp.removeDuplicateLibraries: false + files: "rpathlink-deduplication-main.cpp" + property bool test: { + if (cpp.useRPathLink) + console.info("useRPathLink: true"); + else + console.info("useRPathLink: false"); + console.info("===" + cpp.rpathLinkFlag + "==="); + } + } +}
\ No newline at end of file diff --git a/tests/auto/blackbox/testdata/rule-with-non-required-inputs/rule-with-non-required-inputs.qbs b/tests/auto/blackbox/testdata/rule-with-non-required-inputs/rule-with-non-required-inputs.qbs index 1bd9beebf..9d861b674 100644 --- a/tests/auto/blackbox/testdata/rule-with-non-required-inputs/rule-with-non-required-inputs.qbs +++ b/tests/auto/blackbox/testdata/rule-with-non-required-inputs/rule-with-non-required-inputs.qbs @@ -22,7 +22,7 @@ Product { } prepare: { var cmd = new JavaScriptCommand(); - cmd.description = "Generating " + output.fileName; + cmd.description = "generating " + output.fileName; cmd.sourceCode = function() { var f = new TextFile(output.filePath, TextFile.WriteOnly); f.write('('); diff --git a/tests/auto/blackbox/testdata/run-multiplexed/main.cpp b/tests/auto/blackbox/testdata/run-multiplexed/main.cpp new file mode 100644 index 000000000..237c8ce18 --- /dev/null +++ b/tests/auto/blackbox/testdata/run-multiplexed/main.cpp @@ -0,0 +1 @@ +int main() {} diff --git a/tests/auto/blackbox/testdata/run-multiplexed/run-multiplexed.qbs b/tests/auto/blackbox/testdata/run-multiplexed/run-multiplexed.qbs new file mode 100644 index 000000000..11577b54a --- /dev/null +++ b/tests/auto/blackbox/testdata/run-multiplexed/run-multiplexed.qbs @@ -0,0 +1,21 @@ +import qbs.Host + +CppApplication { + aggregate: false + consoleApplication: true + name: "app" + multiplexByQbsProperties: "buildVariants" + + qbs.buildVariants: ["debug", "release"] + + files: "main.cpp" + + Probe { + id: checker + property string targetPlatform: qbs.targetPlatform + configure: { + if (targetPlatform !== Host.platform()) + console.info("targetPlatform differs from hostPlatform"); + } + } +} diff --git a/tests/auto/blackbox/testdata/sanitizer/sanitizer.qbs b/tests/auto/blackbox/testdata/sanitizer/sanitizer.qbs index 0aa7f3e87..438f3cc39 100644 --- a/tests/auto/blackbox/testdata/sanitizer/sanitizer.qbs +++ b/tests/auto/blackbox/testdata/sanitizer/sanitizer.qbs @@ -1,9 +1,15 @@ CppApplication { + Depends { name: "Sanitizers.address" } + Sanitizers.address.enabled: sanitizer === "address" property string sanitizer property bool supportsSanitizer: { - if (qbs.toolchain.contains("clang-cl")) { - if (cpp.toolchainInstallPath.contains("Microsoft Visual Studio") + if (qbs.toolchain.includes("mingw")) + return false; + if (sanitizer === "address") + return Sanitizers.address._supported; + if (qbs.toolchain.includes("clang-cl")) { + if (cpp.toolchainInstallPath.includes("Microsoft Visual Studio") && qbs.architecture === "x86_64") { // 32 bit sanitizer shipped with VS misses the x86_64 libraries return false; @@ -11,11 +17,9 @@ CppApplication { // only these are supported return sanitizer === "address" || sanitizer === "undefined"; } - if (!qbs.toolchain.contains("gcc")) - return false; - if (qbs.toolchain.contains("mingw")) + if (!qbs.toolchain.includes("gcc")) return false; - if (qbs.targetOS.contains("ios")) { + if (qbs.targetOS.includes("ios")) { // thread sanitizer is not supported return sanitizer !== "thread"; } @@ -34,7 +38,7 @@ CppApplication { cpp.minimumMacosVersion: "10.8" consoleApplication: true cpp.runtimeLibrary: "static" - cpp.driverFlags: sanitizer ? ["-fsanitize=" + sanitizer] : [] + cpp.driverFlags: sanitizer && sanitizer !== "address" ? ["-fsanitize=" + sanitizer] : [] cpp.debugInformation: true files: "sanitizer.cpp" } diff --git a/tests/auto/blackbox/testdata/separate-debug-info/separate-debug-info.qbs b/tests/auto/blackbox/testdata/separate-debug-info/separate-debug-info.qbs index 48e70f260..4198b863f 100644 --- a/tests/auto/blackbox/testdata/separate-debug-info/separate-debug-info.qbs +++ b/tests/auto/blackbox/testdata/separate-debug-info/separate-debug-info.qbs @@ -8,10 +8,13 @@ Project { Probe { id: osProbe property stringList targetOS: qbs.targetOS + property stringList toolchain: qbs.toolchain configure: { - console.info("is windows: " + (targetOS.contains("windows") ? "yes" : "no")); - console.info("is macos: " + (targetOS.contains("macos") ? "yes" : "no")); - console.info("is darwin: " + (targetOS.contains("darwin") ? "yes" : "no")); + console.info("is windows: " + (targetOS.includes("windows") ? "yes" : "no")); + console.info("is macos: " + (targetOS.includes("macos") ? "yes" : "no")); + console.info("is darwin: " + (targetOS.includes("darwin") ? "yes" : "no")); + console.info("is gcc: " + (toolchain.includes("gcc") ? "yes" : "no")); + console.info("is msvc: " + (toolchain.includes("msvc") ? "yes" : "no")); } } } @@ -55,7 +58,7 @@ Project { files: ["main.cpp"] cpp.separateDebugInformation: true Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") cpp.dsymutilFlags: ["--flat"] } } @@ -66,7 +69,7 @@ Project { files: ["foo.cpp"] cpp.separateDebugInformation: true Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") cpp.dsymutilFlags: ["--flat"] } } @@ -76,7 +79,7 @@ Project { files: ["foo.cpp"] cpp.separateDebugInformation: true Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") cpp.dsymutilFlags: ["--flat"] } } @@ -94,7 +97,7 @@ Project { type: ["dynamiclibrary"] files: ["foo.cpp"] Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } cpp.separateDebugInformation: true @@ -104,7 +107,7 @@ Project { name: "bar4" files: ["foo.cpp"] Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } cpp.separateDebugInformation: true @@ -115,12 +118,12 @@ Project { type: ["application"] files: ["main.cpp"] Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } cpp.separateDebugInformation: true Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") cpp.dsymutilFlags: ["--flat"] } } @@ -130,12 +133,12 @@ Project { type: ["dynamiclibrary"] files: ["foo.cpp"] Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } cpp.separateDebugInformation: true Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") cpp.dsymutilFlags: ["--flat"] } } @@ -144,12 +147,12 @@ Project { name: "bar5" files: ["foo.cpp"] Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } cpp.separateDebugInformation: true Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") cpp.dsymutilFlags: ["--flat"] } } diff --git a/tests/auto/blackbox/testdata/setup-run-environment/setup-run-environment.qbs b/tests/auto/blackbox/testdata/setup-run-environment/setup-run-environment.qbs index 5c5100b29..b1310c005 100644 --- a/tests/auto/blackbox/testdata/setup-run-environment/setup-run-environment.qbs +++ b/tests/auto/blackbox/testdata/setup-run-environment/setup-run-environment.qbs @@ -1,4 +1,5 @@ import qbs.FileInfo +import qbs.Host Project { DynamicLibrary { // Product dependency, installed @@ -7,13 +8,13 @@ Project { files: ["lib1.cpp"] - install: !qbs.targetOS.contains("darwin") + install: !qbs.targetOS.includes("darwin") installImportLib: true installDir: "lib1" importLibInstallDir: installDir Group { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") fileTagsFilter: ["bundle.content"] qbs.install: true qbs.installSourceBase: destinationDirectory @@ -26,7 +27,7 @@ Project { Depends { name: "lib5" } Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } @@ -40,7 +41,7 @@ Project { files: ["lib3.cpp"] Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } @@ -57,14 +58,14 @@ Project { files: ["lib4.cpp"] Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } // Testing shows that clang (8.0) does not find dynamic libraries via // the -L<dir> and -l<libname> mechanism unless the name is "lib<libname>.a". Properties { - condition: qbs.hostOS.contains("windows") && qbs.toolchain.contains("clang") + condition: Host.os().includes("windows") && qbs.toolchain.includes("clang") cpp.dynamicLibraryPrefix: "lib" cpp.dynamicLibraryImportSuffix: ".a" } @@ -82,7 +83,7 @@ Project { Depends { name: "cpp" } Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } @@ -91,7 +92,7 @@ Project { CppApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; @@ -107,7 +108,7 @@ Project { property string fullInstallPrefix: FileInfo.joinPaths(qbs.installRoot, qbs.installPrefix) property string lib3FilePath: FileInfo.joinPaths(fullInstallPrefix, "lib3", - cpp.dynamicLibraryPrefix + "lib3" + (qbs.targetOS.contains("windows") + cpp.dynamicLibraryPrefix + "lib3" + (qbs.targetOS.includes("windows") ? cpp.dynamicLibraryImportSuffix : cpp.dynamicLibrarySuffix)) cpp.dynamicLibraries: [lib3FilePath, "lib4"] @@ -116,7 +117,7 @@ Project { Probe { id: osPrinter - property bool isWindows: qbs.targetOS.contains("windows") + property bool isWindows: qbs.targetOS.includes("windows") configure: { console.info("is windows"); found = true; diff --git a/tests/auto/blackbox/testdata/smart-relinking/smart-relinking.qbs b/tests/auto/blackbox/testdata/smart-relinking/smart-relinking.qbs index aac0692a8..29e6c2e17 100644 --- a/tests/auto/blackbox/testdata/smart-relinking/smart-relinking.qbs +++ b/tests/auto/blackbox/testdata/smart-relinking/smart-relinking.qbs @@ -5,7 +5,7 @@ Project { property stringList toolchain: qbs.toolchain property stringList targetOS: qbs.targetOS configure: { - found = toolchain.contains("gcc") && targetOS.contains("unix"); + found = toolchain.includes("gcc") && targetOS.includes("unix"); if (!found) console.info("project disabled"); } diff --git a/tests/auto/blackbox/testdata/source-artifact-changes/source-artifact-changes.qbs b/tests/auto/blackbox/testdata/source-artifact-changes/source-artifact-changes.qbs index de56376df..a53819753 100644 --- a/tests/auto/blackbox/testdata/source-artifact-changes/source-artifact-changes.qbs +++ b/tests/auto/blackbox/testdata/source-artifact-changes/source-artifact-changes.qbs @@ -4,7 +4,7 @@ CppApplication { consoleApplication: true Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.embedInfoPlist: false } @@ -12,7 +12,7 @@ CppApplication { id: toolchainProbe property stringList toolchain: qbs.toolchain configure: { - console.info("is gcc: " + toolchain.contains("gcc")); + console.info("is gcc: " + toolchain.includes("gcc")); found = true; } } diff --git a/tests/auto/blackbox/testdata/static-lib-without-sources/static-lib-without-sources.qbs b/tests/auto/blackbox/testdata/static-lib-without-sources/static-lib-without-sources.qbs index 32a58c94b..54ec5e230 100644 --- a/tests/auto/blackbox/testdata/static-lib-without-sources/static-lib-without-sources.qbs +++ b/tests/auto/blackbox/testdata/static-lib-without-sources/static-lib-without-sources.qbs @@ -6,7 +6,7 @@ StaticLibrary { } Product { - type: qbs.targetOS.contains("darwin") ? undefined : ["staticlibrary"] + type: qbs.targetOS.includes("darwin") ? undefined : ["staticlibrary"] name: "b" Depends { name: "cpp" } Depends { name: "a" } diff --git a/tests/auto/blackbox/testdata/successive-changes/successive-changes.qbs b/tests/auto/blackbox/testdata/successive-changes/successive-changes.qbs index 77df81e39..c33e24d34 100644 --- a/tests/auto/blackbox/testdata/successive-changes/successive-changes.qbs +++ b/tests/auto/blackbox/testdata/successive-changes/successive-changes.qbs @@ -17,7 +17,7 @@ Project { } prepare: { var cmd = new JavaScriptCommand(); - cmd.description = "Creating output"; + cmd.description = "creating output"; cmd.sourceCode = function() { var f = new TextFile(output.filePath, TextFile.WriteOnly); f.write(project.version); diff --git a/tests/auto/blackbox/testdata/symbolLinkMode/lib.cpp b/tests/auto/blackbox/testdata/symbolLinkMode/lib.cpp index 8d96f5094..9dcb48738 100644 --- a/tests/auto/blackbox/testdata/symbolLinkMode/lib.cpp +++ b/tests/auto/blackbox/testdata/symbolLinkMode/lib.cpp @@ -3,9 +3,9 @@ int somefunction() return 42; } -#include <stdio.h> +#include <cstdio> static const auto func = []() { - printf("Lib was loaded!\n"); + std::printf("Lib was loaded!\n"); return 0; }(); diff --git a/tests/auto/blackbox/testdata/symbolLinkMode/main.cpp b/tests/auto/blackbox/testdata/symbolLinkMode/main.cpp index 801491634..4d847ba19 100644 --- a/tests/auto/blackbox/testdata/symbolLinkMode/main.cpp +++ b/tests/auto/blackbox/testdata/symbolLinkMode/main.cpp @@ -1,15 +1,15 @@ extern WEAK_IMPORT int somefunction(); extern void indirect(); -#include <stdio.h> +#include <cstdio> int main() { - printf("meow\n"); + std::printf("meow\n"); if (&somefunction != nullptr) - printf("somefunction existed and it returned %d\n", somefunction()); + std::printf("somefunction existed and it returned %d\n", somefunction()); else - printf("somefunction did not exist\n"); + std::printf("somefunction did not exist\n"); #if SHOULD_INSTALL_LIB indirect(); #endif diff --git a/tests/auto/blackbox/testdata/symbolLinkMode/symbolLinkMode.qbs b/tests/auto/blackbox/testdata/symbolLinkMode/symbolLinkMode.qbs index 63789a182..49bcd9951 100644 --- a/tests/auto/blackbox/testdata/symbolLinkMode/symbolLinkMode.qbs +++ b/tests/auto/blackbox/testdata/symbolLinkMode/symbolLinkMode.qbs @@ -1,4 +1,5 @@ import qbs.FileInfo +import qbs.Host Project { property bool shouldInstallLibrary: true @@ -6,7 +7,7 @@ Project { Application { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; @@ -15,7 +16,7 @@ Project { Depends { name: "functions"; cpp.symbolLinkMode: product.symbolLinkMode - cpp.link: !(product.qbs.targetOS.contains("linux") && product.symbolLinkMode === "weak") + cpp.link: !(product.qbs.targetOS.includes("linux") && product.symbolLinkMode === "weak") } property string symbolLinkMode: project.lazy ? "lazy" : "weak" @@ -26,7 +27,7 @@ Project { property string installLib: "SHOULD_INSTALL_LIB=" + project.shouldInstallLibrary cpp.defines: { if (symbolLinkMode === "weak") { - return qbs.targetOS.contains("darwin") + return qbs.targetOS.includes("darwin") ? ["WEAK_IMPORT=__attribute__((weak_import))", installLib] : ["WEAK_IMPORT=__attribute__((weak))", installLib]; } @@ -48,7 +49,7 @@ Project { Depends { name: "indirect"; cpp.symbolLinkMode: "reexport" } Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } name: "functions" @@ -58,7 +59,7 @@ Project { cpp.rpaths: [cpp.rpathOrigin] Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") cpp.sonamePrefix: "@rpath" } @@ -71,7 +72,7 @@ Project { Export { // let the autotest pass on Linux where reexport is not supported - Depends { name: "indirect"; condition: !qbs.targetOS.contains("darwin") } + Depends { name: "indirect"; condition: !qbs.targetOS.includes("darwin") } // on Linux, there is no LC_WEAK_LOAD_DYLIB equivalent (the library is simply omitted // from the list of load commands entirely), so use LD_PRELOAD to emulate @@ -90,7 +91,7 @@ Project { Depends { name: "cpp" } Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") bundle.isBundle: false } name: "indirect" @@ -99,7 +100,7 @@ Project { cpp.minimumMacosVersion: "10.7" Properties { - condition: qbs.targetOS.contains("darwin") + condition: qbs.targetOS.includes("darwin") // reexport is incompatible with rpath, // "ERROR: ld: file not found: @rpath/libindirect.dylib for architecture x86_64" cpp.sonamePrefix: qbs.installRoot + "/lib" diff --git a/tests/auto/blackbox/testdata/system-include-paths/main.cpp b/tests/auto/blackbox/testdata/system-include-paths/main.cpp index e449173d3..10d376a31 100644 --- a/tests/auto/blackbox/testdata/system-include-paths/main.cpp +++ b/tests/auto/blackbox/testdata/system-include-paths/main.cpp @@ -1,4 +1,4 @@ -#include <stdio.h> +#include <cstdio> #include <gagagugu.h> int main() diff --git a/tests/auto/blackbox/testdata/system-run-paths/system-run-paths.qbs b/tests/auto/blackbox/testdata/system-run-paths/system-run-paths.qbs index 6e2137173..35dd7a00f 100644 --- a/tests/auto/blackbox/testdata/system-run-paths/system-run-paths.qbs +++ b/tests/auto/blackbox/testdata/system-run-paths/system-run-paths.qbs @@ -20,4 +20,9 @@ Project { cpp.rpaths: qbs.installRoot + "/lib" cpp.systemRunPaths: project.setRunPaths ? [qbs.installRoot + "/lib"] : [] } + Probe { + id: checker + property bool isUnix: qbs.targetOS.contains("unix") + configure: { console.info("is unix: " + isUnix); } + } } diff --git a/tests/auto/blackbox/testdata/trackAddFile/after/trackAddFile.qbs b/tests/auto/blackbox/testdata/trackAddFile/after/trackAddFile.qbs index 113f44316..4d454d4ff 100644 --- a/tests/auto/blackbox/testdata/trackAddFile/after/trackAddFile.qbs +++ b/tests/auto/blackbox/testdata/trackAddFile/after/trackAddFile.qbs @@ -1,7 +1,9 @@ +import qbs.Host + Project { Product { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata/trackAddFile/before/trackAddFile.qbs b/tests/auto/blackbox/testdata/trackAddFile/before/trackAddFile.qbs index 74efdf8f7..fd858b247 100644 --- a/tests/auto/blackbox/testdata/trackAddFile/before/trackAddFile.qbs +++ b/tests/auto/blackbox/testdata/trackAddFile/before/trackAddFile.qbs @@ -1,7 +1,9 @@ +import qbs.Host + Project { Product { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata/trackExternalProductChanges/trackExternalProductChanges.qbs b/tests/auto/blackbox/testdata/trackExternalProductChanges/trackExternalProductChanges.qbs index 534f49ff2..0e28e5687 100644 --- a/tests/auto/blackbox/testdata/trackExternalProductChanges/trackExternalProductChanges.qbs +++ b/tests/auto/blackbox/testdata/trackExternalProductChanges/trackExternalProductChanges.qbs @@ -11,4 +11,9 @@ CppApplication { name: "file that needs help from the environment to find a header" files: "including.cpp" } + Probe { + id: checker + property bool isGcc: qbs.toolchain.contains("gcc") + configure: { console.info("is gcc: " + isGcc); } + } } diff --git a/tests/auto/blackbox/testdata/trackFileTags/after/trackFileTags.qbs b/tests/auto/blackbox/testdata/trackFileTags/after/trackFileTags.qbs index 1d589978a..1c5b6b56f 100644 --- a/tests/auto/blackbox/testdata/trackFileTags/after/trackFileTags.qbs +++ b/tests/auto/blackbox/testdata/trackFileTags/after/trackFileTags.qbs @@ -1,9 +1,11 @@ import qbs.TextFile +import qbs.Host + Project { Product { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata/trackFileTags/before/trackFileTags.qbs b/tests/auto/blackbox/testdata/trackFileTags/before/trackFileTags.qbs index 4c9e77dd8..86771ab8f 100644 --- a/tests/auto/blackbox/testdata/trackFileTags/before/trackFileTags.qbs +++ b/tests/auto/blackbox/testdata/trackFileTags/before/trackFileTags.qbs @@ -1,9 +1,11 @@ import qbs.TextFile +import qbs.Host + Project { Product { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata/variant-suffix/variant-suffix.qbs b/tests/auto/blackbox/testdata/variant-suffix/variant-suffix.qbs index b6e025e4c..1131e6a2f 100644 --- a/tests/auto/blackbox/testdata/variant-suffix/variant-suffix.qbs +++ b/tests/auto/blackbox/testdata/variant-suffix/variant-suffix.qbs @@ -1,8 +1,8 @@ StaticLibrary { name: "l" - Depends { condition: qbs.targetOS.contains("darwin"); name: "bundle" } - Properties { condition: qbs.targetOS.contains("darwin"); bundle.isBundle: false } + Depends { condition: qbs.targetOS.includes("darwin"); name: "bundle" } + Properties { condition: qbs.targetOS.includes("darwin"); bundle.isBundle: false } aggregate: false property string variantSuffix @@ -31,8 +31,8 @@ StaticLibrary { id: targetOSProbe property stringList targetOS: qbs.targetOS configure: { - console.info("is Windows: " + targetOS.contains("windows")); - console.info("is Apple: " + targetOS.contains("darwin")); + console.info("is Windows: " + targetOS.includes("windows")); + console.info("is Apple: " + targetOS.includes("darwin")); } } } diff --git a/tests/auto/blackbox/testdata/vcs/vcstest.qbs b/tests/auto/blackbox/testdata/vcs/vcstest.qbs index dabe889b6..4f861654b 100644 --- a/tests/auto/blackbox/testdata/vcs/vcstest.qbs +++ b/tests/auto/blackbox/testdata/vcs/vcstest.qbs @@ -1,6 +1,8 @@ +import qbs.Host + CppApplication { condition: { - var result = qbs.targetPlatform === qbs.hostPlatform; + var result = qbs.targetPlatform === Host.platform(); if (!result) console.info("targetPlatform differs from hostPlatform"); return result; diff --git a/tests/auto/blackbox/testdata/versionscript/versionscript.qbs b/tests/auto/blackbox/testdata/versionscript/versionscript.qbs index cc5c7b1cc..fcb4314a2 100644 --- a/tests/auto/blackbox/testdata/versionscript/versionscript.qbs +++ b/tests/auto/blackbox/testdata/versionscript/versionscript.qbs @@ -20,6 +20,12 @@ DynamicLibrary { return [cmd]; } } + Probe { + id: checker + property bool isLinux: qbs.targetOS.includes("linux") + property bool isGcc: qbs.toolchain.contains("gcc") + configure: { console.info("is gcc for Linux: " + (isLinux && isGcc)); } + } qbs.installPrefix: "" install: true diff --git a/tests/auto/blackbox/testdata/whole-archive/whole-archive.qbs b/tests/auto/blackbox/testdata/whole-archive/whole-archive.qbs index f3bcff2cd..c138e46c0 100644 --- a/tests/auto/blackbox/testdata/whole-archive/whole-archive.qbs +++ b/tests/auto/blackbox/testdata/whole-archive/whole-archive.qbs @@ -32,7 +32,8 @@ Project { property string compilerVersion: cpp.compilerVersion property string dummy: product.linkWholeArchive // To force probe re-execution configure: { - if (!toolchain.contains("msvc") + if (!toolchain.includes("msvc") + || toolchain.includes("clang-cl") || Utilities.versionCompare(compilerVersion, "19.0.24215.1") >= 0) { console.info("can link whole archives"); } else { diff --git a/tests/auto/blackbox/testdata/concurrent-executor/dummy2.input b/tests/auto/blackbox/testdata/wildcards-and-change-tracking/nonrecursive/subdir1/file.txt index e69de29bb..e69de29bb 100644 --- a/tests/auto/blackbox/testdata/concurrent-executor/dummy2.input +++ b/tests/auto/blackbox/testdata/wildcards-and-change-tracking/nonrecursive/subdir1/file.txt diff --git a/tests/auto/blackbox/testdata/wildcards-and-change-tracking/nonrecursive/subdir2/file.txt b/tests/auto/blackbox/testdata/wildcards-and-change-tracking/nonrecursive/subdir2/file.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/auto/blackbox/testdata/wildcards-and-change-tracking/nonrecursive/subdir2/file.txt diff --git a/tests/auto/blackbox/testdata/wildcards-and-change-tracking/recursive1/recursive.txt b/tests/auto/blackbox/testdata/wildcards-and-change-tracking/recursive1/recursive.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/auto/blackbox/testdata/wildcards-and-change-tracking/recursive1/recursive.txt diff --git a/tests/auto/blackbox/testdata/wildcards-and-change-tracking/recursive2/recursive.txt b/tests/auto/blackbox/testdata/wildcards-and-change-tracking/recursive2/recursive.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/auto/blackbox/testdata/wildcards-and-change-tracking/recursive2/recursive.txt diff --git a/tests/auto/blackbox/testdata/wildcards-and-change-tracking/wildcards-and-change-tracking.qbs b/tests/auto/blackbox/testdata/wildcards-and-change-tracking/wildcards-and-change-tracking.qbs new file mode 100644 index 000000000..0a889bab3 --- /dev/null +++ b/tests/auto/blackbox/testdata/wildcards-and-change-tracking/wildcards-and-change-tracking.qbs @@ -0,0 +1,16 @@ +Product { + Group { + name: "recursive" + files: "**/file.txt" + } + Group { + name: "directories" + prefix: "nonrecursive/" + files: "subdi?/file.txt" + } + Group { + prefix: "nonrecursive/empty/" + name: "no files" + files: "*.txt" + } +} diff --git a/tests/auto/blackbox/testdata/wildcards-and-rules/wildcards-and-rules.qbs b/tests/auto/blackbox/testdata/wildcards-and-rules/wildcards-and-rules.qbs index f6662529d..fe6088943 100644 --- a/tests/auto/blackbox/testdata/wildcards-and-rules/wildcards-and-rules.qbs +++ b/tests/auto/blackbox/testdata/wildcards-and-rules/wildcards-and-rules.qbs @@ -22,7 +22,7 @@ Product { } prepare: { var cmd = new JavaScriptCommand(); - cmd.description = "Creating output artifact"; + cmd.description = "creating output artifact"; cmd.highlight = "codegen"; cmd.sourceCode = function() { var file = new TextFile(output.filePath, TextFile.WriteOnly); diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index debcc6f30..dbabfb311 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -53,6 +53,7 @@ #include <QtCore/qsettings.h> #include <QtCore/qtemporarydir.h> #include <QtCore/qtemporaryfile.h> +#include <QtCore/qversionnumber.h> #include <algorithm> #include <functional> @@ -62,7 +63,6 @@ #define WAIT_FOR_NEW_TIMESTAMP() waitForNewTimestamp(testDataDir) using qbs::Internal::HostOsInfo; -using qbs::Profile; class MacosTarHealer { public: @@ -138,12 +138,32 @@ QString TestBlackbox::findArchiver(const QString &fileName, int *status) QString binary = findExecutable(QStringList(fileName)); if (binary.isEmpty()) { const SettingsPtr s = settings(); - Profile p(profileName(), s.get()); + qbs::Profile p(profileName(), s.get()); binary = findExecutable(p.value("archiver.command").toStringList()); } return binary; } +bool TestBlackbox::prepareAndRunConan() +{ + QString executable = findExecutable({"conan"}); + if (executable.isEmpty()) { + qInfo() << "conan is not installed or not available in PATH."; + return false; + } + const auto profilePath = QDir::homePath() + "/.conan2/profiles/qbs-test"; + if (!QFileInfo(profilePath).exists()) { + qInfo() << "conan profile is not installed, run './scripts/setup-conan-profiles.sh'"; + return false; + } + QProcess conan; + QDir::setCurrent(testDataDir + "/conan-provider/testlibdep"); + rmDirR("build"); + QStringList arguments{"install", ".", "--profile:all=qbs-test", "--output-folder=build"}; + conan.start(executable, arguments); + return waitForProcessSuccess(conan, 60000); +} + bool TestBlackbox::lexYaccExist() { return !findExecutable(QStringList("lex")).isEmpty() @@ -298,7 +318,7 @@ void TestBlackbox::textTemplate() static QStringList sortedFileList(const QByteArray &ba) { - auto list = QString::fromUtf8(ba).split(QRegularExpression("[\r\n]"), QBS_SKIP_EMPTY_PARTS); + auto list = QString::fromUtf8(ba).split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts); std::sort(list.begin(), list.end()); return list; } @@ -698,7 +718,7 @@ void TestBlackbox::buildDirectories() QDir::setCurrent(projectDir); QCOMPARE(runQbs(), 0); const QStringList outputLines - = QString::fromLocal8Bit(m_qbsStdout.trimmed()).split('\n', QBS_SKIP_EMPTY_PARTS); + = QString::fromLocal8Bit(m_qbsStdout.trimmed()).split('\n', Qt::SkipEmptyParts); QVERIFY2(outputLines.contains(projectDir + '/' + relativeProductBuildDir("p1")), m_qbsStdout.constData()); QVERIFY2(outputLines.contains(projectDir + '/' + relativeProductBuildDir("p2")), @@ -707,6 +727,45 @@ void TestBlackbox::buildDirectories() QVERIFY2(outputLines.contains(projectDir), m_qbsStdout.constData()); } +void TestBlackbox::buildDirPlaceholders_data() +{ + QTest::addColumn<QString>("buildDir"); + QTest::addColumn<bool>("setProjectFile"); + QTest::addColumn<bool>("successExpected"); + + QTest::newRow("normal dir, with project file") << "somedir" << true << true; + QTest::newRow("normal dir, without project file") << "somedir" << false << true; + QTest::newRow("@project, with project file") << "somedir/@project" << true << true; + QTest::newRow("@project, without project file") << "somedir/@project" << false << false; + QTest::newRow("@path, with project file") << "somedir/@path" << true << true; + QTest::newRow("@path, without project file") << "somedir/@path" << false << false; +} + +void TestBlackbox::buildDirPlaceholders() +{ + QFETCH(QString, buildDir); + QFETCH(bool, setProjectFile); + QFETCH(bool, successExpected); + + const QString projectDir = testDataDir + "/build-dir-placeholders"; + rmDirR(projectDir); + QVERIFY(QDir().mkpath(projectDir)); + QDir::setCurrent(projectDir); + QFile projectFile("build-dir-placeholders.qbs"); + QVERIFY(projectFile.open(QIODevice::WriteOnly)); + projectFile.write("Product {\n}\n"); + projectFile.flush(); + rmDirR(relativeBuildDir()); + QbsRunParameters params; + params.buildDirectory = buildDir; + if (setProjectFile) { + params.arguments << "-f" + << "build-dir-placeholders.qbs"; + } + params.expectFailure = !successExpected; + QCOMPARE(runQbs(params) == 0, successExpected); +} + void TestBlackbox::buildEnvChange() { QDir::setCurrent(testDataDir + "/buildenv-change"); @@ -793,28 +852,45 @@ void TestBlackbox::buildVariantDefaults() void TestBlackbox::capnproto() { QFETCH(QString, projectFile); + QFETCH(QStringList, arguments); QDir::setCurrent(testDataDir + "/capnproto"); rmDirR(relativeBuildDir()); + if (QTest::currentDataTag() == QLatin1String("cpp-conan") + || QTest::currentDataTag() == QLatin1String("rpc-conan")) { + if (!prepareAndRunConan()) + QSKIP("conan is not prepared, check messages above"); + } + QbsRunParameters params{QStringLiteral("resolve"), {QStringLiteral("-f"), projectFile}}; + params.arguments << arguments; + QCOMPARE(runQbs(params), 0); if (m_qbsStdout.contains("targetPlatform differs from hostPlatform")) QSKIP("Cannot run binaries in cross-compiled build"); if (m_qbsStdout.contains("capnproto is not present")) QSKIP("capnproto is not present"); - params.command.clear(); + params.command = QStringLiteral("build"); QCOMPARE(runQbs(params), 0); } void TestBlackbox::capnproto_data() { QTest::addColumn<QString>("projectFile"); + QTest::addColumn<QStringList>("arguments"); + + QStringList pkgConfigArgs({"project.qbsModuleProviders:qbspkgconfig"}); + QTest::newRow("cpp-pkgconfig") << QStringLiteral("capnproto_cpp.qbs") << pkgConfigArgs; + QTest::newRow("rpc-pkgconfig") << QStringLiteral("greeter_cpp.qbs") << pkgConfigArgs; + QTest::newRow("relative import") + << QStringLiteral("capnproto_relative_import.qbs") << pkgConfigArgs; + QTest::newRow("absolute import") + << QStringLiteral("capnproto_absolute_import.qbs") << pkgConfigArgs; - QTest::newRow("cpp") << QStringLiteral("capnproto_cpp.qbs"); - QTest::newRow("cpp-pkgconfig") << QStringLiteral("capnproto_cpp_pkgconfig.qbs"); - QTest::newRow("greeter cpp (grpc)") << QStringLiteral("greeter_cpp.qbs"); - QTest::newRow("relative import") << QStringLiteral("capnproto_relative_import.qbs"); - QTest::newRow("absolute import") << QStringLiteral("capnproto_absolute_import.qbs"); + QStringList conanArgs( + {"project.qbsModuleProviders:conan", "moduleProviders.conan.installDirectory:build"}); + QTest::newRow("cpp-conan") << QStringLiteral("capnproto_cpp.qbs") << conanArgs; + QTest::newRow("rpc-conan") << QStringLiteral("greeter_cpp.qbs") << conanArgs; } void TestBlackbox::changedFiles_data() @@ -1001,7 +1077,7 @@ void TestBlackbox::dependenciesProperty() REPLACE_IN_FILE(projectFile, "// Depends { name: 'newDependency' }", "Depends { name: 'newDependency' }"); QCOMPARE(runQbs(), 0); - QVERIFY2(m_qbsStdout.contains("generate product1.deps"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("generating product1.deps"), m_qbsStdout.constData()); readDepsOutput(depsFile, jsondoc); dependencies = jsondoc.array(); QCOMPARE(dependencies.size(), 3); @@ -1012,7 +1088,7 @@ void TestBlackbox::dependenciesProperty() REPLACE_IN_FILE(projectFile, "// Depends { name: 'product2' }", "Depends { name: 'product2' }"); QCOMPARE(runQbs(), 0); QVERIFY2(m_qbsStdout.contains("Resolving"), m_qbsStdout.constData()); - QVERIFY2(!m_qbsStdout.contains("generate product1.deps"), m_qbsStdout.constData()); + QVERIFY2(!m_qbsStdout.contains("generating product1.deps"), m_qbsStdout.constData()); readDepsOutput(depsFile, jsondoc); dependencies = jsondoc.array(); QCOMPARE(dependencies.size(), 3); @@ -1022,7 +1098,7 @@ void TestBlackbox::dependenciesProperty() 0); QCOMPARE(runQbs(), 0); QVERIFY2(!m_qbsStdout.contains("compiling product2.cpp"), m_qbsStdout.constData()); - QVERIFY2(m_qbsStdout.contains("generate product1.deps"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("generating product1.deps"), m_qbsStdout.constData()); readDepsOutput(depsFile, jsondoc); dependencies = jsondoc.array(); QCOMPARE(dependencies.size(), 3); @@ -1034,7 +1110,7 @@ void TestBlackbox::dependenciesProperty() "products.product2.cpp.defines:DIGEDAG"})), 0); QCOMPARE(runQbs(), 0); QVERIFY2(m_qbsStdout.contains("compiling product2.cpp"), m_qbsStdout.constData()); - QVERIFY2(m_qbsStdout.contains("generate product1.deps"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("generating product1.deps"), m_qbsStdout.constData()); readDepsOutput(depsFile, jsondoc); dependencies = jsondoc.array(); QCOMPARE(dependencies.size(), 3); @@ -1055,22 +1131,68 @@ void TestBlackbox::dependencyScanningLoop() void TestBlackbox::deprecatedProperty() { + QFETCH(QString, version); + QFETCH(QString, mode); + QFETCH(bool, expiringWarning); + QFETCH(bool, expiringError); + QDir::setCurrent(testDataDir + "/deprecated-property"); QbsRunParameters params(QStringList("-q")); params.expectFailure = true; + params.environment.insert("REMOVAL_VERSION", version); + if (!mode.isEmpty()) + params.arguments << "--deprecation-warnings" << mode; QVERIFY(runQbs(params) != 0); m_qbsStderr = QDir::fromNativeSeparators(QString::fromLocal8Bit(m_qbsStderr)).toLocal8Bit(); - QVERIFY2(m_qbsStderr.contains("deprecated-property.qbs:6:24 The property 'oldProp' is " - "deprecated and will be removed in Qbs 99.9.0."), m_qbsStderr.constData()); - QVERIFY2(m_qbsStderr.contains("deprecated-property.qbs:7:28 The property 'veryOldProp' can no " - "longer be used. It was removed in Qbs 1.3.0."), m_qbsStderr.constData()); + const bool hasExpiringWarning = m_qbsStderr.contains(QByteArray( + "deprecated-property.qbs:4:29 The property 'expiringProp' is " + "deprecated and will be removed in Qbs ") + version.toLocal8Bit()); + QVERIFY2(expiringWarning == hasExpiringWarning, m_qbsStderr.constData()); + const bool hasRemovedOutput = m_qbsStderr.contains( + "deprecated-property.qbs:5:28 The property 'veryOldProp' can no " + "longer be used. It was removed in Qbs 1.3.0."); + QVERIFY2(hasRemovedOutput == !expiringError, m_qbsStderr.constData()); QVERIFY2(m_qbsStderr.contains("Property 'forgottenProp' was scheduled for removal in version " "1.8.0, but is still present."), m_qbsStderr.constData()); QVERIFY2(m_qbsStderr.contains("themodule/m.qbs:22:5 Removal version for 'forgottenProp' " "specified here."), m_qbsStderr.constData()); - QVERIFY2(m_qbsStderr.count("Use newProp instead.") == 2, m_qbsStderr.constData()); - QVERIFY2(m_qbsStderr.count("is deprecated") == 1, m_qbsStderr.constData()); - QVERIFY2(m_qbsStderr.count("was removed") == 1, m_qbsStderr.constData()); + QVERIFY2(m_qbsStderr.count("Use newProp instead.") == 1 + + int(expiringWarning && !expiringError), m_qbsStderr.constData()); + QVERIFY2(m_qbsStderr.count("is deprecated") == int(expiringWarning), m_qbsStderr.constData()); + QVERIFY2(m_qbsStderr.count("was removed") == int(!expiringError), m_qbsStderr.constData()); +} + +void TestBlackbox::deprecatedProperty_data() +{ + QTest::addColumn<QString>("version"); + QTest::addColumn<QString>("mode"); + QTest::addColumn<bool>("expiringWarning"); + QTest::addColumn<bool>("expiringError"); + + const auto current = QVersionNumber::fromString(QBS_VERSION); + const QString next = QVersionNumber(current.majorVersion(), current.minorVersion() + 1) + .toString(); + const QString nextNext = QVersionNumber(current.majorVersion(), current.minorVersion() + 2) + .toString(); + const QString nextMajor = QVersionNumber(current.majorVersion() + 1).toString(); + + QTest::newRow("default/next") << next << QString() << true << false; + QTest::newRow("default/nextnext") << nextNext << QString() << false << false; + QTest::newRow("default/nextmajor") << nextMajor << QString() << true << false; + QTest::newRow("error/next") << next << QString("error") << true << true; + QTest::newRow("error/nextnext") << nextNext << QString("error") << true << true; + QTest::newRow("error/nextmajor") << nextMajor << QString("error") << true << true; + QTest::newRow("on/next") << next << QString("on") << true << false; + QTest::newRow("on/nextnext") << nextNext << QString("on") << true << false; + QTest::newRow("on/nextmajor") << nextMajor << QString("on") << true << false; + QTest::newRow("before-removal/next") << next << QString("before-removal") << true << false; + QTest::newRow("before-removal/nextnext") << nextNext << QString("before-removal") + << false << false; + QTest::newRow("before-removal/nextmajor") << nextMajor << QString("before-removal") + << true << false; + QTest::newRow("off/next") << next << QString("off") << false << false; + QTest::newRow("off/nextnext") << nextNext << QString("off") << false << false; + QTest::newRow("off/nextmajor") << nextMajor << QString("off") << false << false; } void TestBlackbox::disappearedProfile() @@ -1103,16 +1225,16 @@ void TestBlackbox::disappearedProfile() QbsRunParameters buildParams; buildParams.profile.clear(); QCOMPARE(runQbs(buildParams), 0); - QVERIFY2(m_qbsStdout.contains("Creating dummy1.txt with p1 from profile"), + QVERIFY2(m_qbsStdout.contains("creating dummy1.txt with p1 from profile"), m_qbsStdout.constData()); - QVERIFY2(m_qbsStdout.contains("Creating dummy2.txt with p2 from profile"), + QVERIFY2(m_qbsStdout.contains("creating dummy2.txt with p2 from profile"), m_qbsStdout.constData()); // Now we do use the "resolve" command, so the new property value is taken into account. QCOMPARE(runQbs(resolveParams), 0); QCOMPARE(runQbs(buildParams), 0); - QVERIFY2(!m_qbsStdout.contains("Creating dummy1.txt"), m_qbsStdout.constData()); - QVERIFY2(m_qbsStdout.contains("Creating dummy2.txt with p2 new from profile"), + QVERIFY2(!m_qbsStdout.contains("creating dummy1.txt"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("creating dummy2.txt with p2 new from profile"), m_qbsStdout.constData()); // Now we change the profile again without a "resolve" command. However, this time we @@ -1125,8 +1247,8 @@ void TestBlackbox::disappearedProfile() "property string p1: 'p1 from module'"); QCOMPARE(runQbs(buildParams), 0); QVERIFY2(m_qbsStdout.contains("Resolving"), m_qbsStdout.constData()); - QVERIFY2(!m_qbsStdout.contains("Creating dummy1.txt"), m_qbsStdout.constData()); - QVERIFY2(!m_qbsStdout.contains("Creating dummy2.txt"), m_qbsStdout.constData()); + QVERIFY2(!m_qbsStdout.contains("creating dummy1.txt"), m_qbsStdout.constData()); + QVERIFY2(!m_qbsStdout.contains("creating dummy2.txt"), m_qbsStdout.constData()); // Now we run the "resolve" command without giving the necessary settings path to find // the profile. @@ -1179,6 +1301,13 @@ void TestBlackbox::discardUnusedData_data() QTest::newRow("default") << QString() << true; } +void TestBlackbox::dotDotPcFile() +{ + QDir::setCurrent(testDataDir + "/dot-dot-pc-file"); + + QCOMPARE(runQbs(), 0); +} + void TestBlackbox::driverLinkerFlags() { QDir::setCurrent(testDataDir + QLatin1String("/driver-linker-flags")); @@ -1333,19 +1462,6 @@ void TestBlackbox::variantSuffix_data() std::make_pair(QString("unix"), QStringList())}); } -static bool waitForProcessSuccess(QProcess &p) -{ - if (!p.waitForStarted() || !p.waitForFinished()) { - qDebug() << p.errorString(); - return false; - } - if (p.exitCode() != 0) { - qDebug() << p.readAllStandardError(); - return false; - } - return true; -} - void TestBlackbox::vcsGit() { const QString gitFilePath = findExecutable(QStringList("git")); @@ -1540,14 +1656,14 @@ void TestBlackbox::versionCheck_data() void TestBlackbox::versionScript() { - const SettingsPtr s = settings(); - Profile buildProfile(profileName(), s.get()); - QStringList toolchain = profileToolchain(buildProfile); - if (!toolchain.contains("gcc") || targetOs() != HostOsInfo::HostOsLinux) - QSKIP("version script test only applies to Linux"); QDir::setCurrent(testDataDir + "/versionscript"); - QCOMPARE(runQbs(QbsRunParameters(QStringList("-q") - << ("qbs.installRoot:" + QDir::currentPath()))), 0); + QCOMPARE(runQbs(QbsRunParameters("resolve", {"qbs.installRoot:" + QDir::currentPath()})), 0); + const bool isLinuxGcc = m_qbsStdout.contains("is gcc for Linux: true"); + const bool isNotLinuxGcc = m_qbsStdout.contains("is gcc for Linux: false"); + if (isNotLinuxGcc) + QSKIP("version script test only applies to Linux"); + QVERIFY(isLinuxGcc); + QCOMPARE(runQbs(QbsRunParameters(QStringList("-q"))), 0); const QString output = QString::fromLocal8Bit(m_qbsStderr); const QRegularExpression pattern(QRegularExpression::anchoredPattern(".*---(.*)---.*"), QRegularExpression::DotMatchesEverythingOption); @@ -1665,7 +1781,7 @@ void TestBlackbox::clean() QVERIFY(!QFile(appExeFilePath).exists()); QVERIFY(!QFile(depObjectFilePath).exists()); QVERIFY(!QFile(depLibFilePath).exists()); - for (const QString &symLink : qAsConst(symlinks)) + for (const QString &symLink : std::as_const(symlinks)) QVERIFY2(!symlinkExists(symLink), qPrintable(symLink)); // Remove all, with a forced re-resolve in between. @@ -1684,7 +1800,7 @@ void TestBlackbox::clean() QVERIFY(!QFile(appExeFilePath).exists()); QVERIFY(!QFile(depObjectFilePath).exists()); QVERIFY(!QFile(depLibFilePath).exists()); - for (const QString &symLink : qAsConst(symlinks)) + for (const QString &symLink : std::as_const(symlinks)) QVERIFY2(!symlinkExists(symLink), qPrintable(symLink)); // Dry run. @@ -1696,7 +1812,7 @@ void TestBlackbox::clean() QVERIFY(regularFileExists(appExeFilePath)); QVERIFY(regularFileExists(depObjectFilePath)); QVERIFY(regularFileExists(depLibFilePath)); - for (const QString &symLink : qAsConst(symlinks)) + for (const QString &symLink : std::as_const(symlinks)) QVERIFY2(symlinkExists(symLink), qPrintable(symLink)); // Product-wise, dependency only. @@ -1710,7 +1826,7 @@ void TestBlackbox::clean() QVERIFY(regularFileExists(appExeFilePath)); QVERIFY(!QFile(depObjectFilePath).exists()); QVERIFY(!QFile(depLibFilePath).exists()); - for (const QString &symLink : qAsConst(symlinks)) + for (const QString &symLink : std::as_const(symlinks)) QVERIFY2(!symlinkExists(symLink), qPrintable(symLink)); // Product-wise, dependent product only. @@ -1724,17 +1840,10 @@ void TestBlackbox::clean() QVERIFY(!QFile(appExeFilePath).exists()); QVERIFY(regularFileExists(depObjectFilePath)); QVERIFY(regularFileExists(depLibFilePath)); - for (const QString &symLink : qAsConst(symlinks)) + for (const QString &symLink : std::as_const(symlinks)) QVERIFY2(symlinkExists(symLink), qPrintable(symLink)); } -void TestBlackbox::concurrentExecutor() -{ - QDir::setCurrent(testDataDir + "/concurrent-executor"); - QCOMPARE(runQbs(QStringList() << "-j" << "2"), 0); - QVERIFY2(!m_qbsStderr.contains("ASSERT"), m_qbsStderr.constData()); -} - void TestBlackbox::conditionalExport() { QDir::setCurrent(testDataDir + "/conditional-export"); @@ -1867,8 +1976,21 @@ 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); + + if (qEnvironmentVariableIsSet("GITHUB_ACTIONS")) + QSKIP("Skip this test when running on GitHub"); + QString executable = findExecutable({"conan"}); if (executable.isEmpty()) QSKIP("conan is not installed or not available in PATH."); @@ -1883,7 +2005,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)); @@ -1901,6 +2026,42 @@ void TestBlackbox::conanfileProbe() QCOMPARE(actualResults, expectedResults); } +void TestBlackbox::conflictingPropertyValues_data() +{ + QTest::addColumn<bool>("overrideInProduct"); + QTest::newRow("don't override in product") << false; + QTest::newRow("override in product") << true; +} + +void TestBlackbox::conflictingPropertyValues() +{ + QFETCH(bool, overrideInProduct); + + QDir::setCurrent(testDataDir + "/conflicting-property-values"); + if (overrideInProduct) + REPLACE_IN_FILE("conflicting-property-values.qbs", "// low.prop: name", "low.prop: name"); + else + REPLACE_IN_FILE("conflicting-property-values.qbs", "low.prop: name", "// low.prop: name"); + WAIT_FOR_NEW_TIMESTAMP(); + QCOMPARE(runQbs(QString("resolve")), 0); + if (overrideInProduct) { + // Binding in product itself overrides everything else, module-level conflicts + // are irrelevant. + QVERIFY2(m_qbsStdout.contains("final prop value: toplevel"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStderr.isEmpty(), m_qbsStderr.constData()); + } else { + // Only the conflicts in the highest-level modules are reported, lower-level conflicts + // are irrelevant. + // prop2 does not cause a conflict, because the values are the same. + QVERIFY2(m_qbsStdout.contains("final prop value: highest"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStderr.contains("Conflicting scalar values for property 'prop'"), + m_qbsStderr.constData()); + QVERIFY2(m_qbsStderr.count("values.qbs") == 2, m_qbsStderr.constData()); + QVERIFY2(m_qbsStderr.contains("values.qbs:20:23"), m_qbsStderr.constData()); + QVERIFY2(m_qbsStderr.contains("values.qbs:30:23"), m_qbsStderr.constData()); + } +} + void TestBlackbox::cpuFeatures() { QDir::setCurrent(testDataDir + "/cpu-features"); @@ -1932,6 +2093,13 @@ void TestBlackbox::cpuFeatures() } } +void TestBlackbox::dateProperty() +{ + QDir::setCurrent(testDataDir + "/date-property"); + QCOMPARE(runQbs(), 0); + QVERIFY2(m_qbsStdout.contains("The stored date was 1999-12-31"), m_qbsStdout.constData()); +} + void TestBlackbox::renameDependency() { QDir::setCurrent(testDataDir + "/renameDependency"); @@ -1965,10 +2133,13 @@ void TestBlackbox::separateDebugInfo() const bool isDarwin = m_qbsStdout.contains("is darwin: yes"); const bool isNotDarwin = m_qbsStdout.contains("is darwin: no"); QVERIFY(isDarwin != isNotDarwin); + const bool isGcc = m_qbsStdout.contains("is gcc: yes"); + const bool isNotGcc = m_qbsStdout.contains("is gcc: no"); + QVERIFY(isGcc != isNotGcc); + const bool isMsvc = m_qbsStdout.contains("is msvc: yes"); + const bool isNotMsvc = m_qbsStdout.contains("is msvc: no"); + QVERIFY(isMsvc != isNotMsvc); - const SettingsPtr s = settings(); - Profile buildProfile(profileName(), s.get()); - QStringList toolchain = profileToolchain(buildProfile); if (isDarwin) { QVERIFY(directoryExists(relativeProductBuildDir("app1") + "/app1.app.dSYM")); QVERIFY(regularFileExists(relativeProductBuildDir("app1") @@ -2048,7 +2219,7 @@ void TestBlackbox::separateDebugInfo() + "/bar4.bundle.dSYM/Contents/Resources/DWARF") .entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries).size(), 1); QVERIFY(regularFileExists(relativeProductBuildDir("bar5") + "/bar5.bundle.dwarf")); - } else if (toolchain.contains("gcc")) { + } else if (isGcc) { const QString exeSuffix = isWindows ? ".exe" : ""; const QString dllPrefix = isWindows ? "" : "lib"; const QString dllSuffix = isWindows ? ".dll" : ".so"; @@ -2062,7 +2233,7 @@ void TestBlackbox::separateDebugInfo() + '/' + dllPrefix + "bar1" + dllSuffix + ".debug")); QVERIFY(!QFile::exists(relativeProductBuildDir("bar2") + '/' + dllPrefix + "bar2" + dllSuffix + ".debug")); - } else if (toolchain.contains("msvc")) { + } else if (isMsvc) { QVERIFY(QFile::exists(relativeProductBuildDir("app1") + "/app1.pdb")); QVERIFY(QFile::exists(relativeProductBuildDir("foo1") + "/foo1.pdb")); QVERIFY(QFile::exists(relativeProductBuildDir("bar1") + "/bar1.pdb")); @@ -2119,6 +2290,9 @@ void TestBlackbox::trackExternalProductChanges() QVERIFY(!m_qbsStdout.contains("compiling jsFileChange.cpp")); QVERIFY(!m_qbsStdout.contains("compiling fileExists.cpp")); + const bool isGcc = m_qbsStdout.contains("is gcc: true"); + const bool isNotGcc = m_qbsStdout.contains("is gcc: false"); + QbsRunParameters params; params.environment.insert("QBS_TEST_PULL_IN_FILE_VIA_ENV", "1"); QCOMPARE(runQbs(params), 0); @@ -2168,12 +2342,11 @@ void TestBlackbox::trackExternalProductChanges() QVERIFY(!m_qbsStdout.contains("compiling jsFileChange.cpp")); QVERIFY(m_qbsStdout.contains("compiling fileExists.cpp")); + if (isNotGcc) + QSKIP("The remainder of this test requires a GCC-like toolchain"); + QVERIFY(isGcc); + rmDirR(relativeBuildDir()); - const SettingsPtr s = settings(); - const Profile profile(profileName(), s.get()); - const QStringList toolchainTypes = profileToolchain(profile); - if (!toolchainTypes.contains("gcc")) - QSKIP("Need GCC-like compiler to run this test"); params.environment = QbsRunParameters::defaultEnvironment(); params.environment.insert("INCLUDE_PATH_TEST", "1"); params.expectFailure = true; @@ -2438,8 +2611,8 @@ void TestBlackbox::referenceErrorInExport() QbsRunParameters params; params.expectFailure = true; QVERIFY(runQbs(params) != 0); - QVERIFY(m_qbsStderr.contains( - "referenceErrorInExport.qbs:15:12 ReferenceError: Can't find variable: includePaths")); + QVERIFY2(m_qbsStderr.contains("referenceErrorInExport.qbs:5:27 'includePaths' is not defined"), + m_qbsStderr.constData()); } void TestBlackbox::removeDuplicateLibraries_data() @@ -2466,22 +2639,21 @@ void TestBlackbox::removeDuplicateLibraries() void TestBlackbox::reproducibleBuild() { - const SettingsPtr s = settings(); - const Profile profile(profileName(), s.get()); - const QStringList toolchains = profileToolchain(profile); - if (!toolchains.contains("gcc")) - QSKIP("reproducible builds only supported for gcc"); - if (toolchains.contains("clang")) - QSKIP("reproducible builds are not supported for clang"); - QFETCH(bool, reproducible); QDir::setCurrent(testDataDir + "/reproducible-build"); - QbsRunParameters params; + QbsRunParameters params("resolve"); params.arguments << QString("modules.cpp.enableReproducibleBuilds:") + (reproducible ? "true" : "false"); rmDirR(relativeBuildDir()); QCOMPARE(runQbs(params), 0); + const bool isGcc = m_qbsStdout.contains("is gcc: true"); + const bool isNotGcc = m_qbsStdout.contains("is gcc: false"); + if (isNotGcc) + QSKIP("reproducible builds only supported for gcc"); + QVERIFY(isGcc); + + QCOMPARE(runQbs(), 0); QFile object(relativeProductBuildDir("the product") + '/' + inputDirHash(".") + '/' + objectFileName("file1.cpp", profileName())); QVERIFY2(object.open(QIODevice::ReadOnly), qPrintable(object.fileName())); @@ -2489,6 +2661,7 @@ void TestBlackbox::reproducibleBuild() object.close(); QCOMPARE(runQbs(QbsRunParameters("clean")), 0); QVERIFY(!object.exists()); + params.command = "build"; QCOMPARE(runQbs(params), 0); if (reproducible) { QVERIFY(object.open(QIODevice::ReadOnly)); @@ -2550,6 +2723,32 @@ void TestBlackbox::retaggedOutputArtifact() QVERIFY2(!QFile::exists(a3), qPrintable(a3)); } +void TestBlackbox::rpathlinkDeduplication() +{ + QDir::setCurrent(testDataDir + "/rpathlink-deduplication"); + QbsRunParameters resolveParams{"resolve"}; + QCOMPARE(runQbs(resolveParams), 0); + const bool useRPathLink = m_qbsStdout.contains("useRPathLink: true"); + const bool dontUseRPathLink = m_qbsStdout.contains("useRPathLink: false"); + QVERIFY2(useRPathLink || dontUseRPathLink, m_qbsStdout); + if (dontUseRPathLink) + QSKIP("Only applies to toolchains that support rPathLink"); + const QString output = QString::fromLocal8Bit(m_qbsStdout); + const QRegularExpression pattern(QRegularExpression::anchoredPattern(".*===(.*)===.*"), + QRegularExpression::DotMatchesEverythingOption); + const QRegularExpressionMatch match = pattern.match(output); + QVERIFY2(match.hasMatch(), qPrintable(output)); + QCOMPARE(pattern.captureCount(), 1); + const QString linkFlag = match.captured(1); + + QbsRunParameters buildParams; + buildParams.arguments = QStringList({"--command-echo-mode", "command-line"}); + QCOMPARE(runQbs(buildParams), 0); + // private DynamicLibraryA is a dependency for 2 other libs but should only appear once + const auto libDir = QFileInfo(relativeProductBuildDir("DynamicLibraryA")).absoluteFilePath(); + QCOMPARE(m_qbsStdout.count((linkFlag + libDir).toUtf8()), 1); +} + void TestBlackbox::ruleConditions() { QDir::setCurrent(testDataDir + "/ruleConditions"); @@ -2627,11 +2826,30 @@ void TestBlackbox::ruleWithNonRequiredInputs() output = outFile.readAll(); QCOMPARE(output, QByteArray("(a.inp,b.inp,c.inp,)")); QCOMPARE(runQbs(), 0); - QVERIFY2(!m_qbsStdout.contains("Generating"), m_qbsStdout.constData()); + QVERIFY2(!m_qbsStdout.contains("generating"), m_qbsStdout.constData()); WAIT_FOR_NEW_TIMESTAMP(); touch("a.inp"); QCOMPARE(runQbs(), 0); - QVERIFY2(m_qbsStdout.contains("Generating"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("generating"), m_qbsStdout.constData()); +} + +void TestBlackbox::runMultiplexed() +{ + QDir::setCurrent(testDataDir + "/run-multiplexed"); + QCOMPARE(runQbs({"resolve"}), 0); + if (m_qbsStdout.contains("targetPlatform differs from hostPlatform")) + QSKIP("Cannot run binaries in cross-compiled build"); + + QbsRunParameters params("run"); + params.expectFailure = true; + QVERIFY(runQbs(params) != 0); + params.arguments = QStringList{"-p", "app"}; + QVERIFY(runQbs(params) != 0); + params.expectFailure = false; + params.arguments.last() = "app {\"buildVariant\":\"debug\"}"; + QCOMPARE(runQbs(params), 0); + params.arguments.last() = "app {\"buildVariant\":\"release\"}"; + QCOMPARE(runQbs(params), 0); } void TestBlackbox::sanitizer_data() @@ -2657,10 +2875,10 @@ void TestBlackbox::sanitizer() if (m_qbsStdout.contains(QByteArrayLiteral("Compiler does not support sanitizer"))) QSKIP("Compiler does not support the specified sanitizer"); if (!sanitizer.isEmpty()) { - QVERIFY2(m_qbsStdout.contains(QByteArrayLiteral("-fsanitize=") + sanitizer.toLatin1()), + QVERIFY2(m_qbsStdout.contains(QByteArrayLiteral("fsanitize=") + sanitizer.toLatin1()), qPrintable(m_qbsStdout)); } else { - QVERIFY2(!m_qbsStdout.contains(QByteArrayLiteral("-fsanitize=")), qPrintable(m_qbsStdout)); + QVERIFY2(!m_qbsStdout.contains(QByteArrayLiteral("fsanitize=")), qPrintable(m_qbsStdout)); } } @@ -3038,20 +3256,35 @@ void TestBlackbox::pathProbe() QVERIFY2(m_qbsStderr.contains("Probe failed to find files"), m_qbsStderr); } +void TestBlackbox::pathListInProbe() +{ + QDir::setCurrent(testDataDir + "/path-list-in-probe"); + QCOMPARE(runQbs(), 0); +} + void TestBlackbox::pchChangeTracking() { QDir::setCurrent(testDataDir + "/pch-change-tracking"); - QCOMPARE(runQbs(), 0); + bool success = runQbs() == 0; + if (!success && m_qbsStderr.contains("mingw32_gt_pch_use_address")) + QSKIP("https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91440"); + QVERIFY(success); QVERIFY(m_qbsStdout.contains("precompiling pch.h (cpp)")); WAIT_FOR_NEW_TIMESTAMP(); touch("header1.h"); - QCOMPARE(runQbs(), 0); + success = runQbs() == 0; + if (!success && m_qbsStderr.contains("mingw32_gt_pch_use_address")) + QSKIP("https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91440"); + QVERIFY(success); QVERIFY(m_qbsStdout.contains("precompiling pch.h (cpp)")); QVERIFY(m_qbsStdout.contains("compiling header2.cpp")); QVERIFY(m_qbsStdout.contains("compiling main.cpp")); WAIT_FOR_NEW_TIMESTAMP(); touch("header2.h"); - QCOMPARE(runQbs(), 0); + success = runQbs() == 0; + if (!success && m_qbsStderr.contains("mingw32_gt_pch_use_address")) + QSKIP("https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91440"); + QVERIFY(success); QVERIFY2(!m_qbsStdout.contains("precompiling pch.h (cpp)"), m_qbsStdout.constData()); } @@ -3181,13 +3414,19 @@ void TestBlackbox::pluginDependency() void TestBlackbox::precompiledAndPrefixHeaders() { QDir::setCurrent(testDataDir + "/precompiled-and-prefix-headers"); - QCOMPARE(runQbs(), 0); + const bool success = runQbs() == 0; + if (!success && m_qbsStderr.contains("mingw32_gt_pch_use_address")) + QSKIP("https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91440"); + QVERIFY(success); } void TestBlackbox::precompiledHeaderAndRedefine() { QDir::setCurrent(testDataDir + "/precompiled-headers-and-redefine"); - QCOMPARE(runQbs(), 0); + const bool success = runQbs() == 0; + if (!success && m_qbsStderr.contains("mingw32_gt_pch_use_address")) + QSKIP("https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91440"); + QVERIFY(success); } void TestBlackbox::preventFloatingPointValues() @@ -3339,13 +3578,6 @@ void TestBlackbox::productProperties() QVERIFY(regularFileExists(relativeExecutableFilePath("blubb_user"))); } -void TestBlackbox::propertyAssignmentOnNonPresentModule() -{ - QDir::setCurrent(testDataDir + "/property-assignment-on-non-present-module"); - QCOMPARE(runQbs(), 0); - QVERIFY2(m_qbsStderr.isEmpty(), m_qbsStderr.constData()); -} - void TestBlackbox::propertyAssignmentInFailedModule() { QDir::setCurrent(testDataDir + "/property-assignment-in-failed-module"); @@ -3355,7 +3587,7 @@ void TestBlackbox::propertyAssignmentInFailedModule() QVERIFY(runQbs(failParams) != 0); QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("modules.m.doFail:true"))), 0); QVERIFY2(m_qbsStdout.contains("Resolving"), m_qbsStdout.constData()); - QEXPECT_FAIL(nullptr, "circular dependency between module merging and validation", Continue); + failParams.expectFailure = false; QCOMPARE(runQbs(failParams), 0); } @@ -3373,9 +3605,9 @@ void TestBlackbox::propertyChanges() QVERIFY(m_qbsStdout.contains("compiling lib.cpp")); QVERIFY(m_qbsStdout.contains("linking product 1.debug")); QVERIFY(m_qbsStdout.contains("generated.txt")); - QVERIFY(m_qbsStdout.contains("Making output from input")); + QVERIFY(m_qbsStdout.contains("making output from input")); QVERIFY(m_qbsStdout.contains("default value")); - QVERIFY(m_qbsStdout.contains("Making output from other output")); + QVERIFY(m_qbsStdout.contains("making output from other output")); QFile generatedFile(relativeProductBuildDir("generated text file") + "/generated.txt"); QVERIFY(generatedFile.open(QIODevice::ReadOnly)); QCOMPARE(generatedFile.readAll(), QByteArray("prefix 1contents 1suffix 1")); @@ -3389,8 +3621,8 @@ void TestBlackbox::propertyChanges() QVERIFY(!m_qbsStdout.contains("compiling lib.cpp.cpp")); QVERIFY(!m_qbsStdout.contains("linking")); QVERIFY(!m_qbsStdout.contains("generated.txt")); - QVERIFY(!m_qbsStdout.contains("Making output from input")); - QVERIFY(!m_qbsStdout.contains("Making output from other output")); + QVERIFY(!m_qbsStdout.contains("making output from input")); + QVERIFY(!m_qbsStdout.contains("making output from other output")); // Incremental build with no changes, but updated project file timestamp. WAIT_FOR_NEW_TIMESTAMP(); @@ -3402,8 +3634,8 @@ void TestBlackbox::propertyChanges() QVERIFY(!m_qbsStdout.contains("compiling lib.cpp")); QVERIFY(!m_qbsStdout.contains("linking")); QVERIFY(!m_qbsStdout.contains("generated.txt")); - QVERIFY(!m_qbsStdout.contains("Making output from input")); - QVERIFY(!m_qbsStdout.contains("Making output from other output")); + QVERIFY(!m_qbsStdout.contains("making output from input")); + QVERIFY(!m_qbsStdout.contains("making output from other output")); // Incremental build, input property changed for first product WAIT_FOR_NEW_TIMESTAMP(); @@ -3415,8 +3647,8 @@ void TestBlackbox::propertyChanges() QVERIFY(!m_qbsStdout.contains("linking product 3")); QVERIFY(!m_qbsStdout.contains("linking library")); QVERIFY(!m_qbsStdout.contains("generated.txt")); - QVERIFY(!m_qbsStdout.contains("Making output from input")); - QVERIFY(!m_qbsStdout.contains("Making output from other output")); + QVERIFY(!m_qbsStdout.contains("making output from input")); + QVERIFY(!m_qbsStdout.contains("making output from other output")); // Incremental build, input property changed via project for second product. WAIT_FOR_NEW_TIMESTAMP(); @@ -3426,8 +3658,8 @@ void TestBlackbox::propertyChanges() QVERIFY(m_qbsStdout.contains("compiling source2.cpp")); QVERIFY(!m_qbsStdout.contains("linking product 3")); QVERIFY(!m_qbsStdout.contains("generated.txt")); - QVERIFY(!m_qbsStdout.contains("Making output from input")); - QVERIFY(!m_qbsStdout.contains("Making output from other output")); + QVERIFY(!m_qbsStdout.contains("making output from input")); + QVERIFY(!m_qbsStdout.contains("making output from other output")); // Incremental build, input property changed via command line for second product. params.command = "resolve"; @@ -3445,8 +3677,8 @@ void TestBlackbox::propertyChanges() QVERIFY(m_qbsStdout.contains("compiling source2.cpp")); QVERIFY(!m_qbsStdout.contains("linking product 3")); QVERIFY(!m_qbsStdout.contains("generated.txt")); - QVERIFY(!m_qbsStdout.contains("Making output from input")); - QVERIFY(!m_qbsStdout.contains("Making output from other output")); + QVERIFY(!m_qbsStdout.contains("making output from input")); + QVERIFY(!m_qbsStdout.contains("making output from other output")); // Incremental build, input property changed via environment for third product. params.environment.insert("QBS_BLACKBOX_DEFINE", "newvalue"); @@ -3461,8 +3693,8 @@ void TestBlackbox::propertyChanges() QVERIFY(!m_qbsStdout.contains("linking product 2")); QVERIFY(!m_qbsStdout.contains("compiling source3.cpp")); QVERIFY(!m_qbsStdout.contains("generated.txt")); - QVERIFY(!m_qbsStdout.contains("Making output from input")); - QVERIFY(!m_qbsStdout.contains("Making output from other output")); + QVERIFY(!m_qbsStdout.contains("making output from input")); + QVERIFY(!m_qbsStdout.contains("making output from other output")); params.environment.insert("QBS_BLACKBOX_DEFINE", "newvalue"); QCOMPARE(runQbs(params), 0); QCOMPARE(runQbs(), 0); @@ -3477,8 +3709,8 @@ void TestBlackbox::propertyChanges() QVERIFY(!m_qbsStdout.contains("linking product 2")); QVERIFY(m_qbsStdout.contains("compiling source3.cpp")); QVERIFY(!m_qbsStdout.contains("generated.txt")); - QVERIFY(!m_qbsStdout.contains("Making output from input")); - QVERIFY(!m_qbsStdout.contains("Making output from other output")); + QVERIFY(!m_qbsStdout.contains("making output from input")); + QVERIFY(!m_qbsStdout.contains("making output from other output")); // Incremental build, module property changed via command line. params.arguments << "qbs.enableDebugCode:false"; @@ -3498,8 +3730,8 @@ void TestBlackbox::propertyChanges() QVERIFY(m_qbsStdout.contains("compiling source2.cpp")); QVERIFY(m_qbsStdout.contains("compiling source3.cpp")); QVERIFY(!m_qbsStdout.contains("generated.txt")); - QVERIFY(!m_qbsStdout.contains("Making output from input")); - QVERIFY(!m_qbsStdout.contains("Making output from other output")); + QVERIFY(!m_qbsStdout.contains("making output from input")); + QVERIFY(!m_qbsStdout.contains("making output from other output")); // Incremental build, non-essential dependency removed. WAIT_FOR_NEW_TIMESTAMP(); @@ -3511,8 +3743,8 @@ void TestBlackbox::propertyChanges() QVERIFY(!m_qbsStdout.contains("linking product 3")); QVERIFY(!m_qbsStdout.contains("linking library")); QVERIFY(!m_qbsStdout.contains("generated.txt")); - QVERIFY(!m_qbsStdout.contains("Making output from input")); - QVERIFY(!m_qbsStdout.contains("Making output from other output")); + QVERIFY(!m_qbsStdout.contains("making output from input")); + QVERIFY(!m_qbsStdout.contains("making output from other output")); // Incremental build, prepare script of a transformer changed. WAIT_FOR_NEW_TIMESTAMP(); @@ -3523,8 +3755,8 @@ void TestBlackbox::propertyChanges() QVERIFY(!m_qbsStdout.contains("compiling source3.cpp")); QVERIFY(!m_qbsStdout.contains("compiling lib.cpp")); QVERIFY(m_qbsStdout.contains("generated.txt")); - QVERIFY(!m_qbsStdout.contains("Making output from input")); - QVERIFY(!m_qbsStdout.contains("Making output from other output")); + QVERIFY(!m_qbsStdout.contains("making output from input")); + QVERIFY(!m_qbsStdout.contains("making output from other output")); QVERIFY(generatedFile.open(QIODevice::ReadOnly)); QCOMPARE(generatedFile.readAll(), QByteArray("prefix 1contents 2suffix 1")); generatedFile.close(); @@ -3538,8 +3770,8 @@ void TestBlackbox::propertyChanges() QVERIFY(!m_qbsStdout.contains("compiling source3.cpp")); QVERIFY(!m_qbsStdout.contains("compiling lib.cpp")); QVERIFY(m_qbsStdout.contains("generated.txt")); - QVERIFY(!m_qbsStdout.contains("Making output from input")); - QVERIFY(!m_qbsStdout.contains("Making output from other output")); + QVERIFY(!m_qbsStdout.contains("making output from input")); + QVERIFY(!m_qbsStdout.contains("making output from other output")); QVERIFY(generatedFile.open(QIODevice::ReadOnly)); QCOMPARE(generatedFile.readAll(), QByteArray("prefix 2contents 2suffix 1")); generatedFile.close(); @@ -3553,8 +3785,8 @@ void TestBlackbox::propertyChanges() QVERIFY(!m_qbsStdout.contains("compiling source3.cpp")); QVERIFY(!m_qbsStdout.contains("compiling lib.cpp")); QVERIFY(m_qbsStdout.contains("generated.txt")); - QVERIFY(!m_qbsStdout.contains("Making output from input")); - QVERIFY(!m_qbsStdout.contains("Making output from other output")); + QVERIFY(!m_qbsStdout.contains("making output from input")); + QVERIFY(!m_qbsStdout.contains("making output from other output")); QVERIFY(generatedFile.open(QIODevice::ReadOnly)); QCOMPARE(generatedFile.readAll(), QByteArray("prefix 2contents 2suffix 2")); generatedFile.close(); @@ -3568,8 +3800,8 @@ void TestBlackbox::propertyChanges() QVERIFY(!m_qbsStdout.contains("compiling source3.cpp")); QVERIFY(!m_qbsStdout.contains("compiling lib.cpp")); QVERIFY(!m_qbsStdout.contains("generated.txt")); - QVERIFY(m_qbsStdout.contains("Making output from input")); - QVERIFY(m_qbsStdout.contains("Making output from other output")); + QVERIFY(m_qbsStdout.contains("making output from input")); + QVERIFY(m_qbsStdout.contains("making output from other output")); QVERIFY(m_qbsStdout.contains("new value")); // Incremental build, prepare script of a rule in a module changed. @@ -3582,8 +3814,8 @@ void TestBlackbox::propertyChanges() QVERIFY(!m_qbsStdout.contains("compiling source3.cpp")); QVERIFY(!m_qbsStdout.contains("compiling lib.cpp")); QVERIFY(!m_qbsStdout.contains("generated.txt")); - QVERIFY(m_qbsStdout.contains("Making output from input")); - QVERIFY(m_qbsStdout.contains("Making output from other output")); + QVERIFY(m_qbsStdout.contains("making output from input")); + QVERIFY(m_qbsStdout.contains("making output from other output")); } void TestBlackbox::propertyEvaluationContext() @@ -3684,7 +3916,7 @@ void TestBlackbox::emptyProfile() QDir::setCurrent(testDataDir + "/empty-profile"); const SettingsPtr s = settings(); - const Profile buildProfile(profileName(), s.get()); + const qbs::Profile buildProfile(profileName(), s.get()); bool isMsvc = false; auto toolchainType = buildProfile.value(QStringLiteral("qbs.toolchainType")).toString(); QbsRunParameters params; @@ -3705,7 +3937,7 @@ void TestBlackbox::emptyProfile() QDir::toNativeSeparators( buildProfile.value(QStringLiteral("cpp.toolchainInstallPath")).toString()); auto paths = params.environment.value(QStringLiteral("PATH")) - .split(HostOsInfo::pathListSeparator(), QBS_SKIP_EMPTY_PARTS); + .split(HostOsInfo::pathListSeparator(), Qt::SkipEmptyParts); if (!tcPath.isEmpty() && !paths.contains(tcPath)) { paths.prepend(tcPath); params.environment.insert( @@ -3805,15 +4037,16 @@ void TestBlackbox::errorInfo() void TestBlackbox::escapedLinkerFlags() { - const SettingsPtr s = settings(); - const Profile buildProfile(profileName(), s.get()); - const QStringList toolchain = profileToolchain(buildProfile); - if (!toolchain.contains("gcc")) - QSKIP("escaped linker flags test only applies with gcc and GNU ld"); - if (targetOs() == HostOsInfo::HostOsMacos) - QSKIP("Does not apply on macOS"); QDir::setCurrent(testDataDir + "/escaped-linker-flags"); - QbsRunParameters params(QStringList("products.app.escapeLinkerFlags:false")); + QbsRunParameters params("resolve", QStringList("products.app.escapeLinkerFlags:false")); + QCOMPARE(runQbs(params), 0); + const bool isGcc = m_qbsStdout.contains("is gcc: true"); + const bool isNotGcc = m_qbsStdout.contains("is gcc: false"); + if (isNotGcc) + QSKIP("escaped linker flags test only applies on plain unix with gcc and GNU ld"); + QVERIFY(isGcc); + + params.command = "build"; QCOMPARE(runQbs(params), 0); params.command = "resolve"; params.arguments = QStringList() << "products.app.escapeLinkerFlags:true"; @@ -3870,26 +4103,24 @@ void TestBlackbox::exportedPropertyInDisabledProduct_data() void TestBlackbox::systemRunPaths() { - const SettingsPtr s = settings(); - const Profile buildProfile(profileName(), s.get()); - switch (targetOs()) { - case HostOsInfo::HostOsLinux: - case HostOsInfo::HostOsMacos: - case HostOsInfo::HostOsOtherUnix: - break; - default: - QSKIP("only applies on Unix"); - } - const QString lddFilePath = findExecutable(QStringList() << "ldd"); if (lddFilePath.isEmpty()) QSKIP("ldd not found"); + QDir::setCurrent(testDataDir + "/system-run-paths"); QFETCH(bool, setRunPaths); rmDirR(relativeBuildDir()); - QbsRunParameters params; + QbsRunParameters params("resolve"); params.arguments << QString("project.setRunPaths:") + (setRunPaths ? "true" : "false"); QCOMPARE(runQbs(params), 0); + const bool isUnix = m_qbsStdout.contains("is unix: true"); + const bool isNotUnix = m_qbsStdout.contains("is unix: false"); + if (isNotUnix) + QSKIP("only applies on Unix"); + QVERIFY(isUnix); + + params.command = "build"; + QCOMPARE(runQbs(params), 0); QProcess ldd; ldd.start(lddFilePath, QStringList() << relativeExecutableFilePath("app")); QVERIFY2(ldd.waitForStarted(), qPrintable(ldd.errorString())); @@ -3926,7 +4157,7 @@ void TestBlackbox::exportRule() params.expectFailure = false; QCOMPARE(runQbs(params), 0); QCOMPARE(runQbs(), 0); - QVERIFY2(m_qbsStdout.contains("Creating C++ source file"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("creating C++ source file"), m_qbsStdout.constData()); QVERIFY2(m_qbsStdout.contains("compiling myapp.cpp"), m_qbsStdout.constData()); } @@ -3940,12 +4171,88 @@ void TestBlackbox::exportToOutsideSearchPath() m_qbsStderr.constData()); } +void TestBlackbox::exportsCMake() +{ + QFETCH(QStringList, arguments); + + QDir::setCurrent(testDataDir + "/exports-cmake"); + rmDirR(relativeBuildDir()); + QbsRunParameters findCMakeParams("resolve", {"-f", "find-cmake.qbs"}); + QCOMPARE(runQbs(findCMakeParams), 0); + const QString output = QString::fromLocal8Bit(m_qbsStdout); + const QRegularExpression pattern( + QRegularExpression::anchoredPattern(".*---(.*)---.*"), + QRegularExpression::DotMatchesEverythingOption); + const QRegularExpressionMatch match = pattern.match(output); + QVERIFY2(match.hasMatch(), qPrintable(output)); + QCOMPARE(pattern.captureCount(), 1); + const QString jsonString = match.captured(1); + const QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonString.toUtf8()); + const QJsonObject jsonData = jsonDoc.object(); + + rmDirR(relativeBuildDir()); + const QStringList exporterArgs{"-f", "exports-cmake.qbs"}; + QbsRunParameters exporterRunParams("build", exporterArgs); + exporterRunParams.arguments << arguments; + QCOMPARE(runQbs(exporterRunParams), 0); + + if (!jsonData.value(u"cmakeFound").toBool()) { + QSKIP("cmake is not installed"); + return; + } + + if (jsonData.value(u"crossCompiling").toBool()) { + QSKIP("test is not applicable with cross-compile toolchains"); + return; + } + + const auto cmakeFilePath = jsonData.value(u"cmakeFilePath").toString(); + QVERIFY(!cmakeFilePath.isEmpty()); + + const auto generator = jsonData.value(u"generator").toString(); + if (generator.isEmpty()) { + QSKIP("cannot detect cmake generator"); + return; + } + + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + const auto buildEnv = jsonData.value(u"buildEnv").toObject(); + for (auto it = buildEnv.begin(), end = buildEnv.end(); it != end; ++it) { + env.insert(it.key(), it.value().toString()); + } + + const auto installPrefix = jsonData.value(u"installPrefix").toString(); + const auto cmakePrefixPath = QFileInfo(relativeBuildDir()).absoluteFilePath() + "/install-root/" + + installPrefix + "/lib/cmake"; + const auto sourceDirectory = testDataDir + "/exports-cmake/cmake"; + QProcess configure; + configure.setProcessEnvironment(env); + configure.setWorkingDirectory(sourceDirectory); + configure.start( + cmakeFilePath, {".", "-DCMAKE_PREFIX_PATH=" + cmakePrefixPath, "-G" + generator}); + QVERIFY(waitForProcessSuccess(configure, 120000)); + + QProcess build; + build.setProcessEnvironment(env); + build.setWorkingDirectory(sourceDirectory); + build.start(cmakeFilePath, QStringList{"--build", "."}); + QVERIFY(waitForProcessSuccess(build)); +} + +void TestBlackbox::exportsCMake_data() +{ + QTest::addColumn<QStringList>("arguments"); + QTest::newRow("dynamic lib") << QStringList("project.isStatic: false"); + QTest::newRow("static lib") << QStringList("project.isStatic: true"); + QTest::newRow("framework") << QStringList("project.isBundle: true"); +} + void TestBlackbox::exportsPkgconfig() { QDir::setCurrent(testDataDir + "/exports-pkgconfig"); QCOMPARE(runQbs(), 0); - QVERIFY2(m_qbsStdout.contains("Creating TheFirstLib.pc"), m_qbsStdout.constData()); - QVERIFY2(m_qbsStdout.contains("Creating TheSecondLib.pc"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("creating TheFirstLib.pc"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("creating TheSecondLib.pc"), m_qbsStdout.constData()); QFile sourcePcFile(HostOsInfo::isWindowsHost() ? "TheFirstLib_windows.pc" : "TheFirstLib.pc"); QString generatedPcFilePath = relativeProductBuildDir("TheFirstLib") + "/TheFirstLib.pc"; QFile generatedPcFile(generatedPcFilePath); @@ -3960,8 +4267,8 @@ void TestBlackbox::exportsPkgconfig() touch("firstlib.cpp"); QCOMPARE(runQbs(), 0); QVERIFY2(m_qbsStdout.contains("linking"), m_qbsStdout.constData()); - QVERIFY2(!m_qbsStdout.contains("Creating TheFirstLib.pc"), m_qbsStdout.constData()); - QVERIFY2(!m_qbsStdout.contains("Creating TheSecondLib.pc"), m_qbsStdout.constData()); + QVERIFY2(!m_qbsStdout.contains("creating TheFirstLib.pc"), m_qbsStdout.constData()); + QVERIFY2(!m_qbsStdout.contains("creating TheSecondLib.pc"), m_qbsStdout.constData()); } void TestBlackbox::exportsQbs() @@ -3997,7 +4304,8 @@ void TestBlackbox::exportsQbs() paramsExternalBuild.buildDirectory = QDir::currentPath() + "/external-consumer-profile"; paramsExternalBuild.expectFailure = true; QVERIFY(runQbs(paramsExternalBuild) != 0); - QVERIFY2(m_qbsStderr.contains("MyLib could not be loaded"), m_qbsStderr.constData()); + QVERIFY2(m_qbsStderr.contains("Dependency 'MyLib' not found for product 'consumer'"), + m_qbsStderr.constData()); // Removing the condition from the generated module leaves us with two conflicting // candidates. @@ -4011,19 +4319,19 @@ void TestBlackbox::exportsQbs() // Change tracking for accesses to product.exports (negative). QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList{"-f", "exports-qbs.qbs"})), 0); QCOMPARE(runQbs(), 0); - QVERIFY2(m_qbsStdout.contains("Creating MyTool.qbs"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("creating MyTool.qbs"), m_qbsStdout.constData()); WAIT_FOR_NEW_TIMESTAMP(); touch("exports-qbs.qbs"); QCOMPARE(runQbs(QStringList({"-p", "MyTool"})), 0); - QVERIFY2(!m_qbsStdout.contains("Creating MyTool.qbs"), m_qbsStdout.constData()); + QVERIFY2(!m_qbsStdout.contains("creating MyTool.qbs"), m_qbsStdout.constData()); // Rebuilding the target binary should not cause recreating the module file. WAIT_FOR_NEW_TIMESTAMP(); touch("mylib.cpp"); QCOMPARE(runQbs(), 0); QVERIFY2(m_qbsStdout.count("linking") >= 2, m_qbsStdout.constData()); - QVERIFY2(!m_qbsStdout.contains("Creating MyLib"), m_qbsStdout.constData()); - QVERIFY2(!m_qbsStdout.contains("Creating MyTool.qbs"), m_qbsStdout.constData()); + QVERIFY2(!m_qbsStdout.contains("creating MyLib"), m_qbsStdout.constData()); + QVERIFY2(!m_qbsStdout.contains("creating MyTool.qbs"), m_qbsStdout.constData()); // Changing a setting that influences the name of a target artifact should cause // recreating the module file. @@ -4032,14 +4340,14 @@ void TestBlackbox::exportsQbs() QCOMPARE(runQbs(resolveParams), 0); QCOMPARE(runQbs(), 0); QVERIFY2(m_qbsStdout.count("linking") >= 2, m_qbsStdout.constData()); - QVERIFY2(m_qbsStdout.count("Creating MyLib") == 2, m_qbsStdout.constData()); - QVERIFY2(!m_qbsStdout.contains("Creating MyTool.qbs"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.count("creating MyLib") == 2, m_qbsStdout.constData()); + QVERIFY2(!m_qbsStdout.contains("creating MyTool.qbs"), m_qbsStdout.constData()); // Change tracking for accesses to product.exports (positive). WAIT_FOR_NEW_TIMESTAMP(); REPLACE_IN_FILE("tool.qbs", "exportingProduct.toolTags", "[]"); QCOMPARE(runQbs(QStringList({"-p", "MyTool"})), 0); - QVERIFY2(m_qbsStdout.contains("Creating MyTool.qbs"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("creating MyTool.qbs"), m_qbsStdout.constData()); } void TestBlackbox::externalLibs() @@ -4101,6 +4409,43 @@ void TestBlackbox::fileTagsFilterMerging() QVERIFY2(QFile::exists(otherOutput), qPrintable(otherOutput)); } +void TestBlackbox::flatbuf() +{ + QFETCH(QString, projectFile); + + QDir::setCurrent(testDataDir + "/flatbuf"); + + rmDirR(relativeBuildDir()); + if (!prepareAndRunConan()) + QSKIP("conan is not prepared, check messages above"); + + QbsRunParameters resolveParams( + "resolve", QStringList{"-f", projectFile, "moduleProviders.conan.installDirectory:build"}); + QCOMPARE(runQbs(resolveParams), 0); + if (m_qbsStdout.contains("targetPlatform differs from hostPlatform")) + QSKIP("Cannot run binaries in cross-compiled build"); + const bool withFlatbuffers = m_qbsStdout.contains("has flatbuffers: true"); + const bool withoutFlatbuffers = m_qbsStdout.contains("has flatbuffers: false"); + QVERIFY2(withFlatbuffers || withoutFlatbuffers, m_qbsStdout.constData()); + if (withoutFlatbuffers) + QSKIP("flatbuf module not present"); + QbsRunParameters runParams("run"); + QCOMPARE(runQbs(runParams), 0); +} + +void TestBlackbox::flatbuf_data() +{ + QTest::addColumn<QString>("projectFile"); + + // QTest::newRow("c") << QString("flat_c.qbs"); + QTest::newRow("cpp") << QString("flat_cpp.qbs"); + QTest::newRow("relative import") << QString("flat_relative_import.qbs"); + QTest::newRow("absolute import") << QString("flat_absolute_import.qbs"); + QTest::newRow("filename suffix") << QString("flat_filename_suffix.qbs"); + QTest::newRow("filename extension") << QString("flat_filename_extension.qbs"); + QTest::newRow("keep prefix") << QString("flat_keep_prefix.qbs"); +} + void TestBlackbox::freedesktop() { if (!HostOsInfo::isAnyUnixHost()) @@ -4308,7 +4653,7 @@ void TestBlackbox::installPackage() cleanOutputLines.push_back(trimmedLine); } QCOMPARE(cleanOutputLines.size(), 3); - for (const QByteArray &line : qAsConst(cleanOutputLines)) { + for (const QByteArray &line : std::as_const(cleanOutputLines)) { QVERIFY2(line.contains("public_tool") || line.contains("mylib") || line.contains("lib.h"), line.constData()); } @@ -4355,6 +4700,33 @@ void TestBlackbox::installTree() QVERIFY(QFile::exists(installRoot + "content/subdir2/baz.txt")); } +void TestBlackbox::invalidArtifactPath_data() +{ + QTest::addColumn<QString>("baseDir"); + QTest::addColumn<bool>("isValid"); + + QTest::newRow("inside, normal case") << "subdir" << true; + QTest::newRow("inside, build dir 1") << "project.buildDirectory" << true; + QTest::newRow("inside, build dir 2") << "subdir/.." << true; + QTest::newRow("outside, absolute") << "/tmp" << false; + QTest::newRow("outside, relative 1") << "../../" << false; + QTest::newRow("outside, relative 2") << "subdir/../../.." << false; +} + +void TestBlackbox::invalidArtifactPath() +{ + QFETCH(QString, baseDir); + QFETCH(bool, isValid); + + rmDirR(relativeBuildDir()); + QDir::setCurrent(testDataDir + "/invalid-artifact-path"); + QbsRunParameters params(QStringList("project.artifactDir:" + baseDir)); + params.expectFailure = !isValid; + QCOMPARE(runQbs(params) == 0, isValid); + if (!isValid) + QVERIFY2(m_qbsStderr.contains("outside of build directory"), m_qbsStderr.constData()); +} + void TestBlackbox::invalidCommandProperty_data() { QTest::addColumn<QString>("errorType"); @@ -4385,7 +4757,7 @@ void TestBlackbox::invalidLibraryNames() QbsRunParameters params(QStringList("project.valueIndex:" + index)); params.expectFailure = !success; QCOMPARE(runQbs(params) == 0, success); - for (const QString &diag : qAsConst(diagnostics)) + for (const QString &diag : std::as_const(diagnostics)) QVERIFY2(m_qbsStderr.contains(diag.toLocal8Bit()), m_qbsStderr.constData()); } @@ -4446,7 +4818,7 @@ void TestBlackbox::cli() QCOMPARE(status, 0); const SettingsPtr s = settings(); - Profile p("qbs_autotests-cli", s.get()); + qbs::Profile p("qbs_autotests-cli", s.get()); const QStringList toolchain = profileToolchain(p); if (!p.exists() || !(toolchain.contains("dotnet") || toolchain.contains("mono"))) QSKIP("No suitable Common Language Infrastructure test profile"); @@ -4538,7 +4910,7 @@ void TestBlackbox::jsExtensionsFileInfo() QVERIFY(output.exists()); QVERIFY(output.open(QIODevice::ReadOnly)); const QList<QByteArray> lines = output.readAll().trimmed().split('\n'); - QCOMPARE(lines.size(), 26); + QCOMPARE(lines.size(), 28); int i = 0; QCOMPARE(lines.at(i++).trimmed().constData(), "blubb"); QCOMPARE(lines.at(i++).trimmed().constData(), qUtf8Printable( @@ -4567,6 +4939,44 @@ void TestBlackbox::jsExtensionsFileInfo() QCOMPARE(lines.at(i++).trimmed().constData(), "../blubb.tar.gz"); QCOMPARE(lines.at(i++).trimmed().constData(), "\\tmp\\blubb.tar.gz"); QCOMPARE(lines.at(i++).trimmed().constData(), "c:\\tmp\\blubb.tar.gz"); + QCOMPARE(lines.at(i++).trimmed().constData(), qUtf8Printable(HostOsInfo::pathListSeparator())); + QCOMPARE(lines.at(i++).trimmed().constData(), qUtf8Printable(HostOsInfo::pathSeparator())); +} + +void TestBlackbox::jsExtensionsHost() +{ + QDir::setCurrent(testDataDir + "//jsextensions-host"); + QbsRunParameters params(QStringList { "-f", "host.qbs" }); + QCOMPARE(runQbs(params), 0); + QFile output("output.txt"); + QVERIFY(output.exists()); + QVERIFY(output.open(QIODevice::ReadOnly)); + const QList<QByteArray> lines = output.readAll().trimmed().split('\n'); + QCOMPARE(lines.size(), 10); + int i = 0; + QCOMPARE(lines.at(i++).trimmed().constData(), "architecture: " + + HostOsInfo::hostOSArchitecture()); + QStringList list; + for (const auto &s : HostOsInfo::canonicalOSIdentifiers(HostOsInfo::hostOSIdentifier())) + list.push_back(s); + QCOMPARE(lines.at(i++).trimmed().constData(), "os: " + list.join(',')); + QCOMPARE(lines.at(i++).trimmed().constData(), "platform: " + HostOsInfo::hostOSIdentifier()); + QCOMPARE(lines.at(i++).trimmed().constData(), "osVersion: " + + HostOsInfo::hostOsVersion().toString()); + QCOMPARE(lines.at(i++).trimmed().constData(), "osBuildVersion: " + + (HostOsInfo::hostOsBuildVersion().isNull() ? "undefined" : + HostOsInfo::hostOsBuildVersion())); + QCOMPARE(lines.at(i++).trimmed().constData(), "osVersionParts: " + + HostOsInfo::hostOsVersion().toString(',')); + QCOMPARE(lines.at(i++).trimmed().constData(), "osVersionMajor: " + QString::number( + HostOsInfo::hostOsVersion().majorVersion())); + QCOMPARE(lines.at(i++).trimmed().constData(), "osVersionMinor: " + QString::number( + HostOsInfo::hostOsVersion().minorVersion())); + QCOMPARE(lines.at(i++).trimmed().constData(), "osVersionPatch: " + QString::number( + HostOsInfo::hostOsVersion().patchLevel())); + QString nullDevice = HostOsInfo::isWindowsHost() ? QStringLiteral("NUL") : + QStringLiteral("/dev/null"); + QCOMPARE(lines.at(i++).trimmed().constData(), "nullDevice: " + nullDevice); } void TestBlackbox::jsExtensionsProcess() @@ -4676,6 +5086,10 @@ void TestBlackbox::jsExtensionsBinaryFile() QCOMPARE(data.at(5), char(0x05)); QCOMPARE(data.at(6), char(0x06)); QCOMPARE(data.at(7), char(0xFF)); + QFile destination2("destination2.dat"); + QVERIFY(destination2.exists()); + QVERIFY(destination2.open(QIODevice::ReadOnly)); + QCOMPARE(destination2.readAll(), data); } void TestBlackbox::lastModuleCandidateBroken() @@ -4684,7 +5098,8 @@ void TestBlackbox::lastModuleCandidateBroken() QbsRunParameters params; params.expectFailure = true; QVERIFY(runQbs(params) != 0); - QVERIFY2(m_qbsStderr.contains("Module Foo could not be loaded"), m_qbsStderr); + QVERIFY2(m_qbsStderr.contains("Dependency 'Foo' not found for product " + "'last-module-candidate-broken'"), m_qbsStderr); } void TestBlackbox::ld() @@ -4790,6 +5205,7 @@ void TestBlackbox::linkerVariant_data() QTest::newRow("default") << QString(); QTest::newRow("bfd") << QString("bfd"); QTest::newRow("gold") << QString("gold"); + QTest::newRow("mold") << QString("mold"); } void TestBlackbox::linkerVariant() @@ -4923,22 +5339,20 @@ void TestBlackbox::lexyaccOutputs_data() void TestBlackbox::linkerLibraryDuplicates() { - const SettingsPtr s = settings(); - Profile buildProfile(profileName(), s.get()); - QStringList toolchain = profileToolchain(buildProfile); - if (!toolchain.contains("gcc")) - QSKIP("linkerLibraryDuplicates test only applies to GCC toolchain"); - QDir::setCurrent(testDataDir + "/linker-library-duplicates"); rmDirR(relativeBuildDir()); - QFETCH(QString, removeDuplicateLibraries); QStringList runParams; - if (!removeDuplicateLibraries.isEmpty()) { + if (!removeDuplicateLibraries.isEmpty()) runParams.append(removeDuplicateLibraries); - } QCOMPARE(runQbs(QbsRunParameters("resolve", runParams)), 0); + const bool isGcc = m_qbsStdout.contains("is gcc: true"); + const bool isNotGcc = m_qbsStdout.contains("is gcc: false"); + if (isNotGcc) + QSKIP("linkerLibraryDuplicates test only applies to GCC toolchain"); + QVERIFY(isGcc); + QCOMPARE(runQbs(QStringList { "--command-echo-mode", "command-line" }), 0); const QByteArrayList output = m_qbsStdout.split('\n'); QByteArray linkLine; @@ -5003,20 +5417,20 @@ void TestBlackbox::linkerLibraryDuplicates_data() void TestBlackbox::linkerScripts() { - const SettingsPtr s = settings(); - Profile buildProfile(profileName(), s.get()); - QStringList toolchain = profileToolchain(buildProfile); - if (!toolchain.contains("gcc") || targetOs() != HostOsInfo::HostOsLinux) - QSKIP("linker script test only applies to Linux "); - - QbsRunParameters runParams(QStringList() -// << "--log-level" << "debug" - << ("qbs.installRoot:" + QDir::currentPath())); const QString sourceDir = QDir::cleanPath(testDataDir + "/linkerscripts"); + QbsRunParameters runParams("resolve", {"qbs.installRoot:" + QDir::currentPath()}); runParams.buildDirectory = sourceDir + "/build"; runParams.workingDir = sourceDir; QCOMPARE(runQbs(runParams), 0); + const bool isGcc = m_qbsStdout.contains("is Linux gcc: true"); + const bool isNotGcc = m_qbsStdout.contains("is Linux gcc: false"); + if (isNotGcc) + QSKIP("linker script test only applies to Linux"); + QVERIFY(isGcc); + + runParams.command = "build"; + QCOMPARE(runQbs(runParams), 0); const QString output = QString::fromLocal8Bit(m_qbsStderr); const QRegularExpression pattern(QRegularExpression::anchoredPattern(".*---(.*)---.*"), QRegularExpression::DotMatchesEverythingOption); @@ -5160,16 +5574,6 @@ void TestBlackbox::require() QCOMPARE(runQbs(), 0); } -void TestBlackbox::requireDeprecated() -{ - QDir::setCurrent(testDataDir + "/require-deprecated"); - QCOMPARE(runQbs(), 0); - QVERIFY2(m_qbsStderr.contains("loadExtension() function is deprecated"), - m_qbsStderr.constData()); - QVERIFY2(m_qbsStderr.contains("loadFile() function is deprecated"), - m_qbsStderr.constData()); -} - void TestBlackbox::rescueTransformerData() { QDir::setCurrent(testDataDir + "/rescue-transformer-data"); @@ -5454,11 +5858,7 @@ void TestBlackbox::propertyPrecedence() switchProfileContents(profile.p, s.get(), false); switchFileContents(nonleafFile, true); QCOMPARE(runQbs(resolveParams), 0); - QVERIFY2(m_qbsStderr.contains("WARNING: Conflicting scalar values at") - && m_qbsStderr.contains("nonleaf.qbs:4:22") - && m_qbsStderr.contains("dep.qbs:6:26"), - m_qbsStderr.constData()); - QCOMPARE(runQbs(params), 0); + QVERIFY2(m_qbsStderr.isEmpty(), m_qbsStderr.constData()); QCOMPARE(runQbs(params), 0); QVERIFY2(m_qbsStdout.contains("scalar prop: export\n") && m_qbsStdout.contains("list prop: [\"export\",\"nonleaf\",\"leaf\"]\n"), m_qbsStdout.constData()); @@ -5466,10 +5866,7 @@ void TestBlackbox::propertyPrecedence() // Case 8: [cmdline=0,prod=0,export=1,nonleaf=1,profile=1] switchProfileContents(profile.p, s.get(), true); QCOMPARE(runQbs(resolveParams), 0); - QVERIFY2(m_qbsStderr.contains("WARNING: Conflicting scalar values at") - && m_qbsStderr.contains("nonleaf.qbs:4:22") - && m_qbsStderr.contains("dep.qbs:6:26"), - m_qbsStderr.constData()); + QVERIFY2(m_qbsStderr.isEmpty(), m_qbsStderr.constData()); QCOMPARE(runQbs(params), 0); QVERIFY2(m_qbsStdout.contains("scalar prop: export\n") && m_qbsStdout.contains("list prop: [\"export\",\"nonleaf\",\"profile\"]\n"), @@ -5759,8 +6156,7 @@ void TestBlackbox::productInExportedModule() { QDir::setCurrent(testDataDir + "/product-in-exported-module"); QCOMPARE(runQbs(), 0); - QEXPECT_FAIL(nullptr, "QBS-1576", Abort); - QVERIFY2(!m_qbsStdout.contains("product: dep"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("product: importing"), m_qbsStdout.constData()); } void TestBlackbox::properQuoting() @@ -5790,18 +6186,27 @@ 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-pkgconfig") + << QString("addressbook_cpp.qbs") + << QStringList({"project.qbsModuleProviders:qbspkgconfig"}) << true << true; + QTest::newRow("cpp-conan") << QString("addressbook_cpp.qbs") + << QStringList( + {"project.qbsModuleProviders:conan", + "qbs.buildVariant:release", + "moduleProviders.conan.installDirectory:build"}) + << 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() << true << true; QTest::newRow("missing import dir") << QString("needs-import-dir.qbs") - << QStringList() << false; + << QStringList() << true << false; QTest::newRow("provided import dir") << QString("needs-import-dir.qbs") - << QStringList("products.app.theImportDir:subdir") << true; + << QStringList("products.app.theImportDir:subdir") << true << true; QTest::newRow("create proto library") - << QString("create-proto-library.qbs") << QStringList() << true; + << QString("create-proto-library.qbs") << QStringList() << true << true; } void TestBlackbox::protobuf() @@ -5809,8 +6214,15 @@ void TestBlackbox::protobuf() QDir::setCurrent(testDataDir + "/protobuf"); QFETCH(QString, projectFile); QFETCH(QStringList, properties); + QFETCH(bool, hasModules); QFETCH(bool, successExpected); rmDirR(relativeBuildDir()); + + if (QTest::currentDataTag() == QLatin1String("cpp-conan")) { + if (!prepareAndRunConan()) + QSKIP("conan is not prepared, check messages above"); + } + QbsRunParameters resolveParams("resolve", QStringList{"-f", projectFile} << properties); QCOMPARE(runQbs(resolveParams), 0); if (m_qbsStdout.contains("targetPlatform differs from hostPlatform")) @@ -5820,6 +6232,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); @@ -5847,19 +6263,6 @@ void TestBlackbox::protobufLibraryInstall() QFileInfo::exists(installRootInclude + "/hello/world.pb.h")); } -// Tests whether it is possible to set providers properties in a Product or from command-line -void TestBlackbox::providersProperties() -{ - QDir::setCurrent(testDataDir + "/providers-properties"); - - QbsRunParameters params("build"); - params.arguments = QStringList("moduleProviders.provider_b.someProp: \"first,second\""); - QCOMPARE(runQbs(params), 0); - QVERIFY2(m_qbsStdout.contains("p.qbsmetatestmodule.listProp: [\"someValue\"]"), m_qbsStdout); - QVERIFY2(m_qbsStdout.contains( - "p.qbsothermodule.listProp: [\"first\",\"second\"]"), m_qbsStdout); -} - void TestBlackbox::pseudoMultiplexing() { // This is "pseudo-multiplexing" on all platforms that initialize qbs.architectures @@ -5969,6 +6372,10 @@ void TestBlackbox::qbsConfig() if (!canWriteToSystemSettings) { QVERIFY2(m_qbsStderr.contains("You do not have permission to write to that location."), m_qbsStderr.constData()); + } else { + // cleanup system settings + params.arguments = QStringList{"--system", "--unset", "key.subkey.scalar"}; + QCOMPARE(runQbs(params) == 0, canWriteToSystemSettings); } } @@ -6033,138 +6440,90 @@ void TestBlackbox::qbsConfigAddProfile_data() << QString("Profile properties must be key/value pairs"); } -// Tests whether it is possible to set qbsModuleProviders in Product and Project items -// and that the order of providers results in correct priority -void TestBlackbox::qbsModuleProviders() +void TestBlackbox::qbsConfigImport() { - QFETCH(QStringList, arguments); - QFETCH(QString, firstProp); - QFETCH(QString, secondProp); + QFETCH(QString, format); - QDir::setCurrent(testDataDir + "/qbs-module-providers"); + QDir::setCurrent(testDataDir + "/qbs-config-import-export"); + + QbsRunParameters params("config"); + QTemporaryDir settingsDir; + QVERIFY(settingsDir.isValid()); + const QStringList settingsDirArgs = QStringList{"--settings-dir", settingsDir.path()}; + params.arguments = settingsDirArgs; + params.arguments << "--import" << "config." + format; - QbsRunParameters params("resolve"); - params.arguments = arguments; QCOMPARE(runQbs(params), 0); - QVERIFY2(m_qbsStdout.contains(("p1.qbsmetatestmodule.prop: " + firstProp).toUtf8()), - m_qbsStdout); - QVERIFY2(m_qbsStdout.contains(("p1.qbsothermodule.prop: " + secondProp).toUtf8()), - m_qbsStdout); - QVERIFY2(m_qbsStdout.contains(("p2.qbsmetatestmodule.prop: " + firstProp).toUtf8()), - m_qbsStdout); - QVERIFY2(m_qbsStdout.contains(("p2.qbsothermodule.prop: " + secondProp).toUtf8()), - m_qbsStdout); + + params.arguments = settingsDirArgs; + params.arguments << "--list"; + QCOMPARE(runQbs(params), 0); + const QByteArray output = m_qbsStdout; + const auto lines = output.split('\n'); + QCOMPARE(lines.count(), 5); + QCOMPARE(lines[0], "group.key1: \"value1\""); + QCOMPARE(lines[1], "group.key2: \"value2\""); + QCOMPARE(lines[2], "key: \"value\""); + QCOMPARE(lines[3], "listKey: [\"valueOne\", \"valueTwo\"]"); + QCOMPARE(lines[4], ""); } -void TestBlackbox::qbsModuleProviders_data() -{ - QTest::addColumn<QStringList>("arguments"); - QTest::addColumn<QString>("firstProp"); - QTest::addColumn<QString>("secondProp"); - - QTest::newRow("default") << QStringList() << "from_provider_a" << "undefined"; - QTest::newRow("override") - << QStringList("projects.project.qbsModuleProviders:provider_b") - << "from_provider_b" - << "from_provider_b"; - QTest::newRow("override list a") - << QStringList("projects.project.qbsModuleProviders:provider_a,provider_b") - << "from_provider_a" - << "from_provider_b"; - QTest::newRow("override list b") - << QStringList("projects.project.qbsModuleProviders:provider_b,provider_a") - << "from_provider_b" - << "from_provider_b"; -} - -// Tests possible use-cases how to override providers from command-line -void TestBlackbox::qbsModuleProvidersCliOverride() +void TestBlackbox::qbsConfigImport_data() { - QFETCH(QStringList, arguments); - QFETCH(QString, propertyValue); - - QDir::setCurrent(testDataDir + "/qbs-module-providers-cli-override"); + QTest::addColumn<QString>("format"); - QbsRunParameters params("resolve"); - params.arguments = arguments; - QCOMPARE(runQbs(params), 0); - QVERIFY2(m_qbsStdout.contains(("qbsmetatestmodule.prop: " + propertyValue).toUtf8()), - m_qbsStdout); + QTest::newRow("text") << QStringLiteral("txt"); + QTest::newRow("json") << QStringLiteral("json"); } -void TestBlackbox::qbsModuleProvidersCliOverride_data() -{ - QTest::addColumn<QStringList>("arguments"); - QTest::addColumn<QString>("propertyValue"); - - QTest::newRow("default") << QStringList() << "undefined"; - QTest::newRow("project-wide") - << QStringList("project.qbsModuleProviders:provider_a") - << "from_provider_a"; - QTest::newRow("concrete project") - << QStringList("projects.innerProject.qbsModuleProviders:provider_a") - << "from_provider_a"; - QTest::newRow("concrete product") - << QStringList("products.product.qbsModuleProviders:provider_a") - << "from_provider_a"; - QTest::newRow("concrete project override project-wide") - << QStringList({ - "project.qbsModuleProviders:provider_a", - "projects.innerProject.qbsModuleProviders:provider_b"}) - << "from_provider_b"; - QTest::newRow("concrete product override project-wide") - << QStringList({ - "project.qbsModuleProviders:provider_a", - "products.product.qbsModuleProviders:provider_b"}) - << "from_provider_b"; -} - -// Tests whether scoped providers can be used as named, i.e. new provider machinery -// is compatible with the old one -void TestBlackbox::qbsModuleProvidersCompatibility() +void TestBlackbox::qbsConfigExport() { - QFETCH(QStringList, arguments); - QFETCH(QString, propertyValue); + QFETCH(QString, format); - QDir::setCurrent(testDataDir + "/qbs-module-providers-compatibility"); + QDir::setCurrent(testDataDir + "/qbs-config-import-export"); + + QbsRunParameters params("config"); + QTemporaryDir settingsDir; + const QString fileName = "config." + format; + const QString filePath = settingsDir.path() + "/" + fileName; + QVERIFY(settingsDir.isValid()); + const QStringList commonArgs = QStringList{"--settings-dir", settingsDir.path(), "--user"}; + + std::pair<QString, QString> values[] = { + {"key", "value"}, + {"listKey", "[\"valueOne\",\"valueTwo\"]"}, + {"group.key1", "value1"}, + {"group.key2", "value2"} + }; + + for (const auto &value: values) { + params.arguments = commonArgs; + params.arguments << value.first << value.second; + QCOMPARE(runQbs(params), 0); + } + + params.arguments = commonArgs; + params.arguments << "--export" << filePath; - QbsRunParameters params("resolve"); - params.arguments = arguments; QCOMPARE(runQbs(params), 0); - QVERIFY2(m_qbsStdout.contains(("qbsmetatestmodule.prop: " + propertyValue).toUtf8()), - m_qbsStdout); -} -void TestBlackbox::qbsModuleProvidersCompatibility_data() -{ - QTest::addColumn<QStringList>("arguments"); - QTest::addColumn<QString>("propertyValue"); + QVERIFY(QFileInfo(filePath).canonicalPath() != QFileInfo(fileName).canonicalPath()); - QTest::newRow("default") << QStringList() << "from_scoped_provider"; - QTest::newRow("scoped by name") << QStringList("project.qbsModuleProviders:qbsmetatestmodule") << "from_scoped_provider"; - QTest::newRow("named") << QStringList("project.qbsModuleProviders:named_provider") << "from_named_provider"; -} + QFile exported(filePath); + QFile expected(fileName); -void TestBlackbox::qbspkgconfigModuleProvider() -{ - QDir::setCurrent(testDataDir + "/qbspkgconfig-module-provider/libs"); + QVERIFY(exported.open(QIODevice::ReadOnly | QIODevice::Text)); + QVERIFY(expected.open(QIODevice::ReadOnly | QIODevice::Text)); - const auto commonParams = QbsRunParameters(QStringLiteral("install"), { - QStringLiteral("qbs.installPrefix:/usr/local"), - QStringLiteral("--install-root"), - QStringLiteral("install-root") - }); - auto dynamicParams = commonParams; - dynamicParams.arguments << "config:library" << "projects.libs.isBundle:false"; - QCOMPARE(runQbs(dynamicParams), 0); + QCOMPARE(exported.readAll(), expected.readAll()); +} - QDir::setCurrent(testDataDir + "/qbspkgconfig-module-provider"); +void TestBlackbox::qbsConfigExport_data() +{ + QTest::addColumn<QString>("format"); - QbsRunParameters params; - params.arguments - << "moduleProviders.qbspkgconfig.libDirs:libdir" - << "moduleProviders.qbspkgconfig.sysroot:" + QDir::currentPath() + "/libs/install-root"; - QCOMPARE(runQbs(params), 0); + QTest::newRow("text") << QStringLiteral("txt"); + QTest::newRow("json") << QStringLiteral("json"); } static QJsonObject getNextSessionPacket(QProcess &session, QByteArray &data) @@ -6203,6 +6562,137 @@ static QJsonObject getNextSessionPacket(QProcess &session, QByteArray &data) return QJsonDocument::fromJson(QByteArray::fromBase64(msg)).object(); } +static void sendSessionPacket(QProcess &sessionProc, const QJsonObject &message) +{ + const QByteArray data = QJsonDocument(message).toJson().toBase64(); + sessionProc.write("qbsmsg:"); + sessionProc.write(QByteArray::number(data.length())); + sessionProc.write("\n"); + sessionProc.write(data); +} + +void TestBlackbox::qbsLanguageServer_data() +{ + QTest::addColumn<QString>("request"); + QTest::addColumn<QString>("location"); + QTest::addColumn<QString>("insertLocation"); + QTest::addColumn<QString>("insertString"); + QTest::addColumn<QString>("expectedReply"); + + QTest::addRow("follow to module") << "--goto-def" + << (testDataDir + "/lsp/lsp.qbs:4:9") + << QString() << QString() + << (testDataDir + "/lsp/modules/m/m.qbs:1:1"); + QTest::addRow("follow to submodules") + << "--goto-def" + << (testDataDir + "/lsp/lsp.qbs:5:35") + << QString() << QString() + << ((testDataDir + "/lsp/modules/Prefix/m1/m1.qbs:1:1\n") + + (testDataDir + "/lsp/modules/Prefix/m2/m2.qbs:1:1\n") + + (testDataDir + "/lsp/modules/Prefix/m3/m3.qbs:1:1")); + QTest::addRow("follow to product") + << "--goto-def" << (testDataDir + "/lsp/lsp.qbs:9:19") << QString() << QString() + << (testDataDir + "/lsp/lsp.qbs:2:5"); + QTest::addRow("follow to module, non-invalidating insert") + << "--goto-def" << (testDataDir + "/lsp/lsp.qbs:4:9") << "5:9" + << QString("property bool dummy\n") << (testDataDir + "/lsp/modules/m/m.qbs:1:1"); + QTest::addRow("follow to module, invalidating insert") + << "--goto-def" << (testDataDir + "/lsp/lsp.qbs:4:9") << QString() + << QString("property bool dummy\n") << QString(); + QTest::addRow("completion: LHS, module prefix") + << "--completion" << (testDataDir + "/lsp/lsp.qbs:7:1") << QString() << QString("P") + << QString("Prefix.m1\nPrefix.m2\nPrefix.m3"); + QTest::addRow("completion: LHS, module name") + << "--completion" << (testDataDir + "/lsp/lsp.qbs:7:1") << QString() << QString("Prefix.m") + << QString("m1\nm2\nm3"); + QTest::addRow("completion: LHS, module property right after dot") + << "--completion" << (testDataDir + "/lsp/lsp.qbs:7:1") << QString() + << QString("Prefix.m1.") << QString("p1 bool\np2 string\nx bool"); + QTest::addRow("completion: LHS, module property with identifier prefix") + << "--completion" << (testDataDir + "/lsp/lsp.qbs:7:1") << QString() + << QString("Prefix.m1.p") << QString("p1 bool\np2 string"); + QTest::addRow("completion: simple RHS, module property") + << "--completion" << (testDataDir + "/lsp/lsp.qbs:7:1") << QString() + << QString("property bool dummy: Prefix.m1.p") << QString("p1 bool\np2 string"); + QTest::addRow("completion: complex RHS, module property") + << "--completion" << (testDataDir + "/lsp/lsp.qbs:7:1") << QString() + << QString("property bool dummy: { return Prefix.m1.p") << QString("p1 bool\np2 string"); +} + +void TestBlackbox::qbsLanguageServer() +{ + QFETCH(QString, request); + QFETCH(QString, location); + QFETCH(QString, insertLocation); + QFETCH(QString, insertString); + QFETCH(QString, expectedReply); + + QDir::setCurrent(testDataDir + "/lsp"); + QProcess sessionProc; + sessionProc.start(qbsExecutableFilePath, QStringList("session")); + + QVERIFY(sessionProc.waitForStarted()); + + QByteArray incomingData; + + // Wait for and verify hello packet. + QJsonObject receivedMessage = getNextSessionPacket(sessionProc, incomingData); + const QString socketPath = receivedMessage.value("lsp-socket").toString(); + QVERIFY(!socketPath.isEmpty()); + + // Resolve project. + QJsonObject resolveMessage; + resolveMessage.insert("type", "resolve-project"); + resolveMessage.insert("top-level-profile", profileName()); + resolveMessage.insert("project-file-path", QDir::currentPath() + "/lsp.qbs"); + resolveMessage.insert("build-root", QDir::currentPath()); + resolveMessage.insert("settings-directory", settings()->baseDirectory()); + sendSessionPacket(sessionProc, resolveMessage); + bool receivedReply = false; + while (!receivedReply) { + receivedMessage = getNextSessionPacket(sessionProc, incomingData); + QVERIFY(!receivedMessage.isEmpty()); + const QString msgType = receivedMessage.value("type").toString(); + if (msgType == "project-resolved") { + receivedReply = true; + const QJsonObject error = receivedMessage.value("error").toObject(); + if (!error.isEmpty()) + qDebug() << error; + QVERIFY(error.isEmpty()); + } + } + QVERIFY(receivedReply); + + // Employ client app to send request. + QProcess lspClient; + const QFileInfo qbsFileInfo(qbsExecutableFilePath); + const QString clientFilePath = HostOsInfo::appendExecutableSuffix( + qbsFileInfo.absolutePath() + "/qbs_lspclient"); + QStringList args{"--socket", socketPath, request, location}; + if (!insertString.isEmpty()) + args << "--insert-code" << insertString; + if (!insertLocation.isEmpty()) + args << "--insert-location" << insertLocation; + lspClient.start(clientFilePath, args); + QVERIFY2(lspClient.waitForStarted(), qPrintable(lspClient.errorString())); + QVERIFY2(lspClient.waitForFinished(), qPrintable(lspClient.errorString())); + QString errMsg; + if (lspClient.exitStatus() != QProcess::NormalExit) + errMsg = lspClient.errorString(); + if (errMsg.isEmpty()) + errMsg = QString::fromLocal8Bit(lspClient.readAllStandardError()); + QVERIFY2(lspClient.exitCode() == 0, qPrintable(errMsg)); + QVERIFY2(errMsg.isEmpty(), qPrintable(errMsg)); + QString output = QString::fromUtf8(lspClient.readAllStandardOutput().trimmed()); + output.replace("\r\n", "\n"); + QCOMPARE(output, expectedReply); + + QJsonObject quitRequest; + quitRequest.insert("type", "quit"); + sendSessionPacket(sessionProc, quitRequest); + QVERIFY(sessionProc.waitForFinished(3000)); +} + void TestBlackbox::qbsSession() { QDir::setCurrent(testDataDir + "/qbs-session"); @@ -6219,11 +6709,7 @@ void TestBlackbox::qbsSession() QVERIFY(sessionProc.waitForStarted()); const auto sendPacket = [&sessionProc](const QJsonObject &message) { - const QByteArray data = QJsonDocument(message).toJson().toBase64(); - sessionProc.write("qbsmsg:"); - sessionProc.write(QByteArray::number(data.length())); - sessionProc.write("\n"); - sessionProc.write(data); + sendSessionPacket(sessionProc, message); }; static const auto envToJson = [](const QProcessEnvironment &env) { @@ -6247,7 +6733,7 @@ void TestBlackbox::qbsSession() // Wait for and verify hello packet. QJsonObject receivedMessage = getNextSessionPacket(sessionProc, incomingData); QCOMPARE(receivedMessage.value("type"), "hello"); - QCOMPARE(receivedMessage.value("api-level").toInt(), 2); + QCOMPARE(receivedMessage.value("api-level").toInt(), 5); QCOMPARE(receivedMessage.value("api-compat-level").toInt(), 2); // Resolve & verify structure @@ -6263,6 +6749,7 @@ void TestBlackbox::qbsSession() resolveMessage.insert("overridden-properties", overriddenValues); resolveMessage.insert("environment", envToJson(QbsRunParameters::defaultEnvironment())); resolveMessage.insert("data-mode", "only-if-changed"); + resolveMessage.insert("max-job-count", 2); resolveMessage.insert("log-time", true); resolveMessage.insert("module-properties", QJsonArray::fromStringList({"cpp.cxxLanguageVersion"})); @@ -7186,6 +7673,7 @@ void TestBlackbox::autotestTimeout() { QFETCH(QStringList, resolveParams); QFETCH(bool, expectFailure); + QFETCH(QString, errorDetails); QDir::setCurrent(testDataDir + "/autotest-timeout"); QbsRunParameters resolveParameters("resolve", resolveParams); QCOMPARE(runQbs(resolveParameters), 0); @@ -7195,7 +7683,9 @@ void TestBlackbox::autotestTimeout() buildParameters.expectFailure = expectFailure; if (expectFailure) { QVERIFY(runQbs(buildParameters) != 0); - QVERIFY(m_qbsStderr.contains("cancelled") && m_qbsStderr.contains("timeout")); + QVERIFY( + m_qbsStderr.contains("cancelled") && m_qbsStderr.contains("timeout") + && m_qbsStderr.contains(errorDetails.toLocal8Bit())); } else QVERIFY(runQbs(buildParameters) == 0); @@ -7205,11 +7695,12 @@ void TestBlackbox::autotestTimeout_data() { QTest::addColumn<QStringList>("resolveParams"); QTest::addColumn<bool>("expectFailure"); - QTest::newRow("no timeout") << QStringList() << false; - QTest::newRow("timeout on test") << QStringList({"products.testApp.autotest.timeout:2"}) - << true; - QTest::newRow("timeout on runner") << QStringList({"products.autotest-runner.timeout:2"}) - << true; + QTest::addColumn<QString>("errorDetails"); + QTest::newRow("no timeout") << QStringList() << false << QString(); + QTest::newRow("timeout on test") + << QStringList({"products.testApp.autotest.timeout:2"}) << true << QString("testApp"); + QTest::newRow("timeout on runner") + << QStringList({"products.autotest-runner.timeout:2"}) << true << QString("testApp"); } void TestBlackbox::autotests_data() @@ -7245,9 +7736,9 @@ void TestBlackbox::autotests() QVERIFY2(m_qbsStderr.contains(expectedErrorMessage), m_qbsStderr.constData()); return; } - QVERIFY2(m_qbsStdout.contains("Running test test1") - && m_qbsStdout.contains("Running test test2") - && m_qbsStdout.contains("Running test test3"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("running test test1") + && m_qbsStdout.contains("running test test2") + && m_qbsStdout.contains("running test test3"), m_qbsStdout.constData()); QCOMPARE(m_qbsStdout.count("PASS"), 2); QCOMPARE(m_qbsStderr.count("FAIL"), 1); } @@ -7336,9 +7827,9 @@ static bool haveMakeNsis() << QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS"); QStringList paths = QProcessEnvironment::systemEnvironment().value("PATH") - .split(HostOsInfo::pathListSeparator(), QBS_SKIP_EMPTY_PARTS); + .split(HostOsInfo::pathListSeparator(), Qt::SkipEmptyParts); - for (const QString &key : qAsConst(regKeys)) { + for (const QString &key : std::as_const(regKeys)) { QSettings settings(key, QSettings::NativeFormat); QString str = settings.value(QStringLiteral(".")).toString(); if (!str.isEmpty()) @@ -7346,7 +7837,7 @@ static bool haveMakeNsis() } bool haveMakeNsis = false; - for (const QString &path : qAsConst(paths)) { + for (const QString &path : std::as_const(paths)) { if (regularFileExists(QDir::fromNativeSeparators(path) + HostOsInfo::appendExecutableSuffix(QStringLiteral("/makensis")))) { haveMakeNsis = true; @@ -7574,7 +8065,7 @@ void TestBlackbox::generator_data() void TestBlackbox::nodejs() { const SettingsPtr s = settings(); - Profile p(profileName(), s.get()); + qbs::Profile p(profileName(), s.get()); int status; findNodejs(&status); @@ -7593,6 +8084,11 @@ void TestBlackbox::nodejs() QSKIP("nodejs.packageManagerFilePath not set and automatic detection failed"); } + if (p.value("nodejs.interpreterFilePath").toString().isEmpty() + && status != 0 && m_qbsStderr.contains("interpreterPath")) { + QSKIP("nodejs.interpreterFilePath not set and automatic detection failed"); + } + if (m_qbsStdout.contains("targetPlatform differs from hostPlatform")) QSKIP("Cannot run binaries in cross-compiled build"); QCOMPARE(status, 0); @@ -7610,7 +8106,7 @@ void TestBlackbox::typescript() QSKIP("Skip this test when running on GitHub"); const SettingsPtr s = settings(); - Profile p(profileName(), s.get()); + qbs::Profile p(profileName(), s.get()); int status; findTypeScript(&status); @@ -7749,7 +8245,7 @@ void TestBlackbox::wildCardsAndRules() { QDir::setCurrent(testDataDir + "/wildcards-and-rules"); QCOMPARE(runQbs(), 0); - QVERIFY(m_qbsStdout.contains("Creating output artifact")); + QVERIFY(m_qbsStdout.contains("creating output artifact")); QFile output(relativeProductBuildDir("wildcards-and-rules") + "/test.mytype"); QVERIFY2(output.open(QIODevice::ReadOnly), qPrintable(output.errorString())); QCOMPARE(output.readAll().count('\n'), 1); @@ -7761,7 +8257,7 @@ void TestBlackbox::wildCardsAndRules() QbsRunParameters params; params.expectFailure = true; QCOMPARE(runQbs(params), 0); - QVERIFY(m_qbsStdout.contains("Creating output artifact")); + QVERIFY(m_qbsStdout.contains("creating output artifact")); QVERIFY2(output.open(QIODevice::ReadOnly), qPrintable(output.errorString())); QCOMPARE(output.readAll().count('\n'), 2); output.close(); @@ -7770,11 +8266,40 @@ void TestBlackbox::wildCardsAndRules() WAIT_FOR_NEW_TIMESTAMP(); touch("dep.dep"); QCOMPARE(runQbs(), 0); - QVERIFY(m_qbsStdout.contains("Creating output artifact")); + QVERIFY(m_qbsStdout.contains("creating output artifact")); // Add nothing. QCOMPARE(runQbs(), 0); - QVERIFY(!m_qbsStdout.contains("Creating output artifact")); + QVERIFY(!m_qbsStdout.contains("creating output artifact")); +} + +void TestBlackbox::wildCardsAndChangeTracking_data() +{ + QTest::addColumn<QString>("dirToModify"); + QTest::addColumn<bool>("expectReResolve"); + + QTest::newRow("root path") << QString(".") << false; + QTest::newRow("dir with recursive match") << QString("recursive1") << false; + QTest::newRow("non-recursive base dir") << QString("nonrecursive") << true; + QTest::newRow("empty base dir with file patterns") << QString("nonrecursive/empty") << true; +} + +void TestBlackbox::wildCardsAndChangeTracking() +{ + QFETCH(QString, dirToModify); + QFETCH(bool, expectReResolve); + + const QString srcDir = testDataDir + "/wildcards-and-change-tracking"; + QDir::setCurrent(srcDir); + rmDirR("default"); + QDir::current().mkdir("nonrecursive/empty"); + + QCOMPARE(runQbs({"resolve"}), 0); + QVERIFY2(m_qbsStdout.contains("Resolving"), m_qbsStdout.constData()); + WAIT_FOR_NEW_TIMESTAMP(); + touch(dirToModify + "/blubb.txt"); + QCOMPARE(runQbs({"resolve"}), 0); + QCOMPARE(m_qbsStdout.contains("Resolving"), expectReResolve); } void TestBlackbox::loadableModule() @@ -7838,14 +8363,18 @@ void TestBlackbox::maximumCLanguageVersion() QDir::setCurrent(testDataDir + "/maximum-c-language-version"); QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("products.app.enableNewestModule:true"))), 0); - if (m_qbsStdout.contains("is msvc")) - QSKIP("MSVC has no support for setting the C language version."); + const bool isMsvc = m_qbsStdout.contains("is msvc: true"); + if (isMsvc && m_qbsStdout.contains("is old msvc: true")) + QSKIP("MSVC supports setting the C language version only from version 16.8, and Clang from version 13."); QCOMPARE(runQbs(QStringList({"--command-echo-mode", "command-line", "-n"})), 0); QVERIFY2(m_qbsStdout.contains("c11") || m_qbsStdout.contains("c1x"), m_qbsStdout.constData()); QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("products.app.enableNewestModule:false"))), 0); QCOMPARE(runQbs(QStringList({"--command-echo-mode", "command-line", "-n"})), 0); - QVERIFY2(m_qbsStdout.contains("c99"), m_qbsStdout.constData()); + if (isMsvc) + QVERIFY2(!m_qbsStdout.contains("c11"), m_qbsStdout.constData()); + else + QVERIFY2(m_qbsStdout.contains("c99"), m_qbsStdout.constData()); } void TestBlackbox::maximumCxxLanguageVersion() @@ -7863,112 +8392,6 @@ void TestBlackbox::maximumCxxLanguageVersion() m_qbsStdout.constData()); } -void TestBlackbox::moduleProviders() -{ - QDir::setCurrent(testDataDir + "/module-providers"); - - // Resolving in dry-run mode must not leave any data behind. - QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("-n"))), 0); - if (m_qbsStdout.contains("targetPlatform differs from hostPlatform")) - QSKIP("Cannot run binaries in cross-compiled build"); - QCOMPARE(m_qbsStdout.count("Running setup script for mygenerator"), 2); - QVERIFY(!QFile::exists(relativeBuildDir())); - - // Initial build. - QCOMPARE(runQbs(QbsRunParameters("run", QStringList{"-p", "app1"})), 0); - QVERIFY(QFile::exists(relativeBuildDir())); - QCOMPARE(m_qbsStdout.count("Running setup script for mygenerator"), 2); - QVERIFY2(m_qbsStdout.contains("The letters are A and B"), m_qbsStdout.constData()); - QVERIFY2(m_qbsStdout.contains("The MY_DEFINE is app1"), m_qbsStdout.constData()); - QCOMPARE(runQbs(QbsRunParameters("run", QStringList{"-p", "app2"})), 0); - QVERIFY2(m_qbsStdout.contains("The letters are Z and Y"), m_qbsStdout.constData()); - QVERIFY2(m_qbsStdout.contains("The MY_DEFINE is app2"), m_qbsStdout.constData()); - - // Rebuild with overridden module provider config. The output for product 2 must change, - // but no setup script must be re-run, because both config values have already been - // handled in the first run. - const QStringList resolveArgs("moduleProviders.mygenerator.chooseLettersFrom:beginning"); - QCOMPARE(runQbs(QbsRunParameters("resolve", resolveArgs)), 0); - QVERIFY2(!m_qbsStdout.contains("Running setup script"), m_qbsStdout.constData()); - QCOMPARE(runQbs(QbsRunParameters("run", QStringList{"-p", "app1"})), 0); - QVERIFY2(m_qbsStdout.contains("The letters are A and B"), m_qbsStdout.constData()); - QCOMPARE(runQbs(QbsRunParameters("run", QStringList{"-p", "app2"})), 0); - QVERIFY2(m_qbsStdout.contains("The letters are A and B"), m_qbsStdout.constData()); - - // Forcing Probe execution triggers a re-run of the setup script. But only once, - // because the module provider config is the same now. - QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList(resolveArgs) - << "--force-probe-execution")), 0); - QCOMPARE(m_qbsStdout.count("Running setup script for mygenerator"), 1); - QCOMPARE(runQbs(QbsRunParameters("run", QStringList{"-p", "app1"})), 0); - QVERIFY2(m_qbsStdout.contains("The letters are A and B"), m_qbsStdout.constData()); - QCOMPARE(runQbs(QbsRunParameters("run", QStringList{"-p", "app2"})), 0); - QVERIFY2(m_qbsStdout.contains("The letters are A and B"), m_qbsStdout.constData()); - - // Now re-run without the module provider config override. Again, the setup script must - // run once, for the config value that was not present in the last run. - QCOMPARE(runQbs(QbsRunParameters("resolve")), 0); - QCOMPARE(m_qbsStdout.count("Running setup script for mygenerator"), 1); - QCOMPARE(runQbs(QbsRunParameters("run", QStringList{"-p", "app1"})), 0); - QVERIFY2(m_qbsStdout.contains("The letters are A and B"), m_qbsStdout.constData()); - QCOMPARE(runQbs(QbsRunParameters("run", QStringList{"-p", "app2"})), 0); - QVERIFY2(m_qbsStdout.contains("The letters are Z and Y"), m_qbsStdout.constData()); -} - -void TestBlackbox::fallbackModuleProvider_data() -{ - QTest::addColumn<bool>("fallbacksEnabledGlobally"); - QTest::addColumn<bool>("fallbacksEnabledInProduct"); - QTest::addColumn<QStringList>("pkgConfigLibDirs"); - QTest::addColumn<bool>("successExpected"); - QTest::newRow("without custom lib dir, fallbacks disabled globally and in product") - << false << false << QStringList() << false; - QTest::newRow("without custom lib dir, fallbacks disabled globally, enabled in product") - << false << true << QStringList() << false; - QTest::newRow("without custom lib dir, fallbacks enabled globally, disabled in product") - << true << false << QStringList() << false; - QTest::newRow("without custom lib dir, fallbacks enabled globally and in product") - << true << true << QStringList() << false; - QTest::newRow("with custom lib dir, fallbacks disabled globally and in product") - << false << false << QStringList(testDataDir + "/fallback-module-provider/libdir") - << false; - QTest::newRow("with custom lib dir, fallbacks disabled globally, enabled in product") - << false << true << QStringList(testDataDir + "/fallback-module-provider/libdir") - << false; - QTest::newRow("with custom lib dir, fallbacks enabled globally, disabled in product") - << true << false << QStringList(testDataDir + "/fallback-module-provider/libdir") - << false; - QTest::newRow("with custom lib dir, fallbacks enabled globally and in product") - << true << true << QStringList(testDataDir + "/fallback-module-provider/libdir") - << true; -} - -void TestBlackbox::fallbackModuleProvider() -{ - QFETCH(bool, fallbacksEnabledInProduct); - QFETCH(bool, fallbacksEnabledGlobally); - QFETCH(QStringList, pkgConfigLibDirs); - QFETCH(bool, successExpected); - - QDir::setCurrent(testDataDir + "/fallback-module-provider"); - static const auto b2s = [](bool b) { return QString(b ? "true" : "false"); }; - QbsRunParameters resolveParams("resolve", - QStringList{"modules.pkgconfig.libDirs:" + pkgConfigLibDirs.join(','), - "products.p.fallbacksEnabled:" + b2s(fallbacksEnabledInProduct), - "--force-probe-execution"}); - if (!fallbacksEnabledGlobally) - resolveParams.arguments << "--no-fallback-module-provider"; - QCOMPARE(runQbs(resolveParams), 0); - const bool pkgConfigPresent = m_qbsStdout.contains("pkg-config present: true"); - const bool pkgConfigNotPresent = m_qbsStdout.contains("pkg-config present: false"); - QVERIFY(pkgConfigPresent != pkgConfigNotPresent); - if (pkgConfigNotPresent) - successExpected = false; - QbsRunParameters buildParams; - buildParams.expectFailure = !successExpected; - QCOMPARE(runQbs(buildParams) == 0, successExpected); -} - void TestBlackbox::minimumSystemVersion() { rmDirR(relativeBuildDir()); @@ -8061,7 +8484,7 @@ void TestBlackbox::minimumSystemVersion_data() return "__MAC_OS_X_VERSION_MIN_REQUIRED=1070\nversion 10.7\n"; if (HostOsInfo::isWindowsHost()) - return "WINVER=1536\n6.00 operating system version\n6.00 subsystem version\n"; + return "WINVER=1538\n6.02 operating system version\n6.02 subsystem version\n"; return ""; }(); @@ -8089,7 +8512,7 @@ void TestBlackbox::missingBuildGraph() QbsRunParameters params; params.expectFailure = true; params.arguments << QLatin1String("config:") + actualConfigName; - for (const QString &command : qAsConst(commands)) { + for (const QString &command : std::as_const(commands)) { params.command = command; QVERIFY2(runQbs(params) != 0, qPrintable(command)); const QString expectedErrorMessage = QString("Build graph not found for " @@ -8199,6 +8622,12 @@ void TestBlackbox::movedFileDependency() QVERIFY2(!m_qbsStdout.contains("compiling main.cpp"), m_qbsStdout.constData()); } +void TestBlackbox::msvcAsmLinkerFlags() +{ + QDir::setCurrent(testDataDir + "/msvc-asm-flags"); + QCOMPARE(runQbs(), 0); +} + void TestBlackbox::badInterpreter() { if (!HostOsInfo::isAnyUnixHost()) @@ -8313,17 +8742,18 @@ void TestBlackbox::groupsInModules() QSKIP("Cannot run binaries in cross-compiled build"); QbsRunParameters params; QCOMPARE(runQbs(params), 0); - QVERIFY(m_qbsStdout.contains("compile rock.coal => rock.diamond")); - QVERIFY(m_qbsStdout.contains("compile chunk.coal => chunk.diamond")); + QVERIFY(m_qbsStdout.contains("compiling rock.coal to rock.diamond")); + QVERIFY(m_qbsStdout.contains("compiling chunk.coal to chunk.diamond")); QVERIFY(m_qbsStdout.contains("compiling helper2.c")); QVERIFY(!m_qbsStdout.contains("compiling helper3.c")); QVERIFY(m_qbsStdout.contains("compiling helper4.c")); QVERIFY(m_qbsStdout.contains("compiling helper5.c")); QVERIFY(!m_qbsStdout.contains("compiling helper6.c")); + QVERIFY(m_qbsStdout.contains("compiling helper7.c")); QCOMPARE(runQbs(params), 0); - QVERIFY(!m_qbsStdout.contains("compile rock.coal => rock.diamond")); - QVERIFY(!m_qbsStdout.contains("compile chunk.coal => chunk.diamond")); + QVERIFY(!m_qbsStdout.contains("compiling rock.coal to rock.diamond")); + QVERIFY(!m_qbsStdout.contains("compiling chunk.coal to chunk.diamond")); WAIT_FOR_NEW_TIMESTAMP(); touch("modules/helper/diamondc.c"); @@ -8331,8 +8761,8 @@ void TestBlackbox::groupsInModules() waitForFileUnlock(); QCOMPARE(runQbs(params), 0); QVERIFY(m_qbsStdout.contains("compiling diamondc.c")); - QVERIFY(m_qbsStdout.contains("compile rock.coal => rock.diamond")); - QVERIFY(m_qbsStdout.contains("compile chunk.coal => chunk.diamond")); + QVERIFY(m_qbsStdout.contains("compiling rock.coal to rock.diamond")); + QVERIFY(m_qbsStdout.contains("compiling chunk.coal to chunk.diamond")); QVERIFY(regularFileExists(relativeProductBuildDir("groups-in-modules") + "/rock.diamond")); QFile output(relativeProductBuildDir("groups-in-modules") + "/rock.diamond"); QVERIFY(output.open(QIODevice::ReadOnly)); @@ -8342,21 +8772,48 @@ 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"); + + 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; + QStringList conanArgs( + {"project.qbsModuleProviders:conan", "moduleProviders.conan.installDirectory:build"}); + QTest::newRow("cpp-conan") << QString("grpc_cpp.qbs") << conanArgs << true; } void TestBlackbox::grpc() { QDir::setCurrent(testDataDir + "/grpc"); QFETCH(QString, projectFile); + QFETCH(QStringList, arguments); + QFETCH(bool, hasModules); + rmDirR(relativeBuildDir()); + if (QTest::currentDataTag() == QLatin1String("cpp-conan")) { + if (!prepareAndRunConan()) + QSKIP("conan is not prepared, check messages above"); + } + 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"); @@ -8372,9 +8829,10 @@ void TestBlackbox::hostOsProperties() QSKIP("Cannot run binaries in cross-compiled build"); QCOMPARE(runQbs(QStringLiteral("run")), 0); QVERIFY2(m_qbsStdout.contains( - ("HOST_ARCHITECTURE = " + HostOsInfo::hostOSArchitecture()).data()), + ("HOST_ARCHITECTURE = " + HostOsInfo::hostOSArchitecture().toUtf8()).data()), m_qbsStdout.constData()); - QVERIFY2(m_qbsStdout.contains(("HOST_PLATFORM = " + HostOsInfo::hostOSIdentifier()).data()), + QVERIFY2(m_qbsStdout.contains( + ("HOST_PLATFORM = " + HostOsInfo::hostOSIdentifier().toUtf8()).data()), m_qbsStdout.constData()); } diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index 2f443f681..3f817b481 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -60,6 +60,8 @@ private slots: void bomSources(); void buildDataOfDisabledProduct(); void buildDirectories(); + void buildDirPlaceholders_data(); + void buildDirPlaceholders(); void buildEnvChange(); void buildGraphVersions(); void buildVariantDefaults_data(); @@ -82,21 +84,26 @@ private slots: void combinedSources(); void commandFile(); void compilerDefinesByLanguage(); - void concurrentExecutor(); void conditionalExport(); void conditionalFileTagger(); void configure(); void conflictingArtifacts(); void cxxLanguageVersion(); void cxxLanguageVersion_data(); + void conanfileProbe_data(); void conanfileProbe(); + void conflictingPropertyValues_data(); + void conflictingPropertyValues(); void cpuFeatures(); + void dateProperty(); void dependenciesProperty(); void dependencyScanningLoop(); void deprecatedProperty(); + void deprecatedProperty_data(); void disappearedProfile(); void discardUnusedData(); void discardUnusedData_data(); + void dotDotPcFile(); void driverLinkerFlags(); void driverLinkerFlags_data(); void dynamicLibraryInModule(); @@ -121,11 +128,15 @@ private slots: void exportedPropertyInDisabledProduct_data(); void exportRule(); void exportToOutsideSearchPath(); + void exportsCMake(); + void exportsCMake_data(); void exportsPkgconfig(); void exportsQbs(); void externalLibs(); void fileDependencies(); void fileTagsFilterMerging(); + void flatbuf(); + void flatbuf_data(); void freedesktop(); void generatedArtifactAsInputToDynamicRule(); void generateLinkerMapFile(); @@ -158,6 +169,8 @@ private slots: void installPackage(); void installRootFromProjectFile(); void installTree(); + void invalidArtifactPath_data(); + void invalidArtifactPath(); void invalidCommandProperty_data(); void invalidCommandProperty(); void invalidExtensionInstantiation(); @@ -167,6 +180,7 @@ private slots: void invalidLibraryNames_data(); void jsExtensionsFile(); void jsExtensionsFileInfo(); + void jsExtensionsHost(); void jsExtensionsProcess(); void jsExtensionsPropertyList(); void jsExtensionsTemporaryDir(); @@ -192,9 +206,6 @@ private slots: void makefileGenerator(); void maximumCLanguageVersion(); void maximumCxxLanguageVersion(); - void moduleProviders(); - void fallbackModuleProvider_data(); - void fallbackModuleProvider(); void minimumSystemVersion(); void minimumSystemVersion_data(); void missingBuildGraph(); @@ -204,6 +215,7 @@ private slots: void missingOverridePrefix(); void moduleConditions(); void movedFileDependency(); + void msvcAsmLinkerFlags(); void multipleChanges(); void multipleConfigurations(); void multiplexedTool(); @@ -226,6 +238,7 @@ private slots: void overrideProjectProperties(); void pathProbe_data(); void pathProbe(); + void pathListInProbe(); void pchChangeTracking(); void perGroupDefineInExportItem(); void pkgConfigProbe(); @@ -244,7 +257,6 @@ private slots: void productDependenciesByType(); void productInExportedModule(); void productProperties(); - void propertyAssignmentOnNonPresentModule(); void propertyAssignmentInFailedModule(); void propertyChanges(); void propertyEvaluationContext(); @@ -254,18 +266,16 @@ private slots: void protobuf_data(); void protobuf(); void protobufLibraryInstall(); - void providersProperties(); void pseudoMultiplexing(); void qbsConfig(); void qbsConfigAddProfile(); void qbsConfigAddProfile_data(); - void qbsModuleProviders(); - void qbsModuleProviders_data(); - void qbsModuleProvidersCliOverride(); - void qbsModuleProvidersCliOverride_data(); - void qbsModuleProvidersCompatibility(); - void qbsModuleProvidersCompatibility_data(); - void qbspkgconfigModuleProvider(); + void qbsConfigImport(); + void qbsConfigImport_data(); + void qbsConfigExport(); + void qbsConfigExport_data(); + void qbsLanguageServer_data(); + void qbsLanguageServer(); void qbsSession(); void qbsVersion(); void qtBug51237(); @@ -279,15 +289,16 @@ private slots: void reproducibleBuild(); void reproducibleBuild_data(); void require(); - void requireDeprecated(); void rescueTransformerData(); void responseFiles(); void retaggedOutputArtifact(); + void rpathlinkDeduplication(); void ruleConditions(); void ruleConnectionWithExcludedInputs(); void ruleCycle(); void ruleWithNoInputs(); void ruleWithNonRequiredInputs(); + void runMultiplexed(); void sanitizer_data(); void sanitizer(); void scannerItem(); @@ -342,6 +353,8 @@ private slots: void wholeArchive(); void wholeArchive_data(); void wildCardsAndRules(); + void wildCardsAndChangeTracking_data(); + void wildCardsAndChangeTracking(); void wildcardRenaming(); void zip(); void zip_data(); @@ -352,6 +365,7 @@ private: QMap<QString, QString> findNodejs(int *status); QMap<QString, QString> findTypeScript(int *status); QString findArchiver(const QString &fileName, int *status = nullptr); + bool prepareAndRunConan(); static bool lexYaccExist(); static qbs::Version bisonVersion(); }; diff --git a/tests/auto/blackbox/tst_blackboxandroid.cpp b/tests/auto/blackbox/tst_blackboxandroid.cpp index bbaac1c21..a74d9415d 100644 --- a/tests/auto/blackbox/tst_blackboxandroid.cpp +++ b/tests/auto/blackbox/tst_blackboxandroid.cpp @@ -131,9 +131,9 @@ void TestBlackboxAndroid::android() buildParams.buildDirectory = buildSubDir; buildParams.profile = p.name(); QCOMPARE(runQbs(buildParams), 0); - for (const QString &productName : qAsConst(productNames)) { + for (const QString &productName : std::as_const(productNames)) { const QByteArray tag(QTest::currentDataTag()); - QCOMPARE(m_qbsStdout.count("Generating BuildConfig.java"), + QCOMPARE(m_qbsStdout.count("generating BuildConfig.java"), isIncrementalBuild ? 0 : productNames.size()); const QString packageName = productName + (generateAab ? ".aab" : ".apk"); QVERIFY(m_qbsStdout.contains(packageName.toLocal8Bit())); @@ -174,7 +174,7 @@ void TestBlackboxAndroid::android() return f.contains("qmltooling"); }; if (none_of(actualFiles, isFileSharedObject) - || std::all_of(actualFiles.cbegin(), actualFiles.cend(), isQmlToolingLib)) { + || qbs::Internal::all_of(actualFiles, isQmlToolingLib)) { qWarning() << msg; } else { QFAIL(msg); @@ -221,7 +221,7 @@ void TestBlackboxAndroid::android_data() const bool usesClang = (forQt ? pQt : p).value(QStringLiteral("qbs.toolchainType")) .toString() == "clang"; const QByteArray path = "lib/${ARCH}/"; - return path + (usesClang ? "libc++_shared.so" : oldcxxLib); + return path + (usesClang ? QByteArrayLiteral("libc++_shared.so") : oldcxxLib); }; qbs::Version version(5, 13); QStringList qmakeFilePaths = pQt.value(QStringLiteral("moduleProviders.Qt.qmakeFilePaths")). @@ -259,10 +259,10 @@ void TestBlackboxAndroid::android_data() auto expandArchs = [] (const QByteArrayList &archs, const QByteArrayList &lst, bool aabPackage) { const QByteArray &archPlaceHolder = "${ARCH}"; QByteArrayList result; - QByteArray base( aabPackage ? "base/" : QByteArray()); + QByteArray base( aabPackage ? "base/" : ""); for (const QByteArray &entry : lst) { if (entry.contains(archPlaceHolder)) { - for (const QByteArray &arch : qAsConst(archs)) + for (const QByteArray &arch : std::as_const(archs)) result << (base + QByteArray(entry).replace(archPlaceHolder, arch)); } else { result << (base + entry); @@ -309,7 +309,6 @@ void TestBlackboxAndroid::android_data() return QString("modules.Android.sdk.dexCompilerName:") + (enableD8 ? "d8" : "dx"); }; bool enableD8 = true; - auto qtAppExpectedFiles = [&](bool generateAab, bool enableAapt2, bool codeSign = true, QString keyAlias="androiddebugkey") { QByteArrayList expectedFile; @@ -357,6 +356,11 @@ void TestBlackboxAndroid::android_data() "lib/${ARCH}/libplugins_imageformats_qtiff_${ARCH}.so", "lib/${ARCH}/libplugins_imageformats_qwbmp_${ARCH}.so", "lib/${ARCH}/libplugins_imageformats_qwebp_${ARCH}.so"}, generateAab); + if (version >= qbs::Version(6, 5)) + expectedFile << expandArchs(ndkArchsForQt, { + "lib/${ARCH}/libQt6Svg_${ARCH}.so", + "lib/${ARCH}/libplugins_iconengines_qsvgicon_${ARCH}.so", + "lib/${ARCH}/libplugins_imageformats_qsvg_${ARCH}.so"}, generateAab); if (!enableAapt2 && version < qbs::Version(6, 0)) expectedFile << "res/layout/splash.xml"; return expectedFile; @@ -613,9 +617,35 @@ void TestBlackboxAndroid::android_data() "lib/${ARCH}/libplugins_imageformats_qtiff_${ARCH}.so", "lib/${ARCH}/libplugins_imageformats_qwbmp_${ARCH}.so", "lib/${ARCH}/libplugins_imageformats_qwebp_${ARCH}.so"}, generateAab); + if (version >= qbs::Version(6, 5)) + expectedFile << expandArchs(ndkArchsForQt, { + "lib/${ARCH}/libQt6Svg_${ARCH}.so", + "lib/${ARCH}/libplugins_iconengines_qsvgicon_${ARCH}.so", + "lib/${ARCH}/libplugins_imageformats_qsvg_${ARCH}.so"}, generateAab); if (version >= qbs::Version(6, 0)) { expectedFile << expandArchs(ndkArchsForQt, { "lib/${ARCH}/libQt6OpenGL_${ARCH}.so", + "lib/${ARCH}/libqml_QtQml_Models_modelsplugin_${ARCH}.so", + "lib/${ARCH}/libqml_QtQml_WorkerScript_workerscriptplugin_${ARCH}.so", + "lib/${ARCH}/libqml_QtQuick_qtquick2plugin_${ARCH}.so"}, generateAab); + if (version >= qbs::Version(6, 5)) + expectedFile << expandArchs(ndkArchsForQt, { + "lib/${ARCH}/libqml_QtQml_Base_qmlplugin_${ARCH}.so", + "lib/${ARCH}/libqml_QtQml_qmlmetaplugin_${ARCH}.so"}, generateAab); + else + expectedFile << expandArchs(ndkArchsForQt, { + "lib/${ARCH}/libqml_QtQml_qmlplugin_${ARCH}.so"}, generateAab); + } + if (version >= qbs::Version(6, 2)) + expectedFile << expandArchs(ndkArchsForQt, { + "lib/${ARCH}/libplugins_networkinformation_qandroidnetworkinformation_${ARCH}.so", + "lib/${ARCH}/libplugins_tls_qcertonlybackend_${ARCH}.so", + "lib/${ARCH}/libplugins_tls_qopensslbackend_${ARCH}.so", + "lib/${ARCH}/libqml_QtQuick_Window_quickwindowplugin_${ARCH}.so", + }, generateAab); + + if (version >= qbs::Version(6, 0) && version < qbs::Version(6, 3)) { + expectedFile << expandArchs(ndkArchsForQt, { "lib/${ARCH}/libQt6QuickControls2Impl_${ARCH}.so", "lib/${ARCH}/libQt6QuickControls2_${ARCH}.so", "lib/${ARCH}/libQt6QuickParticles_${ARCH}.so", @@ -623,9 +653,6 @@ void TestBlackboxAndroid::android_data() "lib/${ARCH}/libQt6QuickTemplates2_${ARCH}.so", "lib/${ARCH}/libQt6Sql_${ARCH}.so", "lib/${ARCH}/libplugins_sqldrivers_qsqlite_${ARCH}.so", - "lib/${ARCH}/libqml_QtQml_Models_modelsplugin_${ARCH}.so", - "lib/${ARCH}/libqml_QtQml_WorkerScript_workerscriptplugin_${ARCH}.so", - "lib/${ARCH}/libqml_QtQml_qmlplugin_${ARCH}.so", "lib/${ARCH}/libqml_QtQuick_Controls_Basic_impl_qtquickcontrols2basicstyleimplplugin_${ARCH}.so", "lib/${ARCH}/libqml_QtQuick_Controls_Basic_qtquickcontrols2basicstyleplugin_${ARCH}.so", "lib/${ARCH}/libqml_QtQuick_Controls_Fusion_impl_qtquickcontrols2fusionstyleimplplugin_${ARCH}.so", @@ -644,11 +671,9 @@ void TestBlackboxAndroid::android_data() "lib/${ARCH}/libqml_QtQuick_Shapes_qmlshapesplugin_${ARCH}.so", "lib/${ARCH}/libqml_QtQuick_Templates_qtquicktemplates2plugin_${ARCH}.so", "lib/${ARCH}/libqml_QtQuick_Timeline_qtquicktimelineplugin_${ARCH}.so", - "lib/${ARCH}/libqml_QtQuick_Layouts_qquicklayoutsplugin_${ARCH}.so", - "lib/${ARCH}/libqml_QtQuick_qtquick2plugin_${ARCH}.so"}, generateAab); + "lib/${ARCH}/libqml_QtQuick_Layouts_qquicklayoutsplugin_${ARCH}.so"}, generateAab); if (version >= qbs::Version(6, 2)) expectedFile << expandArchs(ndkArchsForQt, { - "lib/${ARCH}/libqml_QtQuick_Window_quickwindowplugin_${ARCH}.so", "lib/${ARCH}/libqml_QtQuick_tooling_quicktoolingplugin_${ARCH}.so", "lib/${ARCH}/libQt6QmlLocalStorage_${ARCH}.so", "lib/${ARCH}/libQt6QmlXmlListModel_${ARCH}.so", @@ -657,15 +682,12 @@ void TestBlackboxAndroid::android_data() "lib/${ARCH}/libQt6QuickDialogs2_${ARCH}.so", "lib/${ARCH}/libQt6QuickLayouts_${ARCH}.so", "lib/${ARCH}/libQt6QuickTimeline_${ARCH}.so", - "lib/${ARCH}/libplugins_networkinformation_qandroidnetworkinformation_${ARCH}.so", - "lib/${ARCH}/libplugins_tls_qcertonlybackend_${ARCH}.so", - "lib/${ARCH}/libplugins_tls_qopensslbackend_${ARCH}.so", "lib/${ARCH}/libqml_QtQml_XmlListModel_qmlxmllistmodelplugin_${ARCH}.so", "lib/${ARCH}/libqml_QtQuick_Dialogs_qtquickdialogsplugin_${ARCH}.so", "lib/${ARCH}/libqml_QtQuick_Dialogs_quickimpl_qtquickdialogs2quickimplplugin_${ARCH}.so"}, generateAab); - else - expectedFile << expandArchs(ndkArchsForQt, { + else + expectedFile << expandArchs(ndkArchsForQt, { "lib/${ARCH}/libqml_QtQuick_Window_quickwindow_${ARCH}.so", "lib/${ARCH}/libqml_QtQuick_tooling_quicktooling_${ARCH}.so"}, generateAab); } @@ -769,9 +791,34 @@ void TestBlackboxAndroid::android_data() "lib/${ARCH}/libplugins_imageformats_qtiff_${ARCH}.so", "lib/${ARCH}/libplugins_imageformats_qwbmp_${ARCH}.so", "lib/${ARCH}/libplugins_imageformats_qwebp_${ARCH}.so"}, generateAab); + if (version >= qbs::Version(6, 5)) + expectedFile << expandArchs(ndkArchsForQt, { + "lib/${ARCH}/libQt6Svg_${ARCH}.so", + "lib/${ARCH}/libplugins_iconengines_qsvgicon_${ARCH}.so", + "lib/${ARCH}/libplugins_imageformats_qsvg_${ARCH}.so"}, generateAab); if (version >= qbs::Version(6, 0)) { expectedFile << expandArchs(ndkArchsForQt, { "lib/${ARCH}/libQt6OpenGL_${ARCH}.so", + "lib/${ARCH}/libqml_QtQml_Models_modelsplugin_${ARCH}.so", + "lib/${ARCH}/libqml_QtQml_WorkerScript_workerscriptplugin_${ARCH}.so", + "lib/${ARCH}/libqml_QtQuick_qtquick2plugin_${ARCH}.so"}, generateAab); + if (version >= qbs::Version(6, 5)) + expectedFile << expandArchs(ndkArchsForQt, { + "lib/${ARCH}/libqml_QtQml_Base_qmlplugin_${ARCH}.so", + "lib/${ARCH}/libqml_QtQml_qmlmetaplugin_${ARCH}.so"}, generateAab); + else + expectedFile << expandArchs(ndkArchsForQt, { + "lib/${ARCH}/libqml_QtQml_qmlplugin_${ARCH}.so"}, generateAab); + } + if (version >= qbs::Version(6, 2)) + expectedFile << expandArchs(ndkArchsForQt, { + "lib/${ARCH}/libplugins_networkinformation_qandroidnetworkinformation_${ARCH}.so", + "lib/${ARCH}/libplugins_tls_qcertonlybackend_${ARCH}.so", + "lib/${ARCH}/libplugins_tls_qopensslbackend_${ARCH}.so", + "lib/${ARCH}/libqml_QtQuick_Window_quickwindowplugin_${ARCH}.so", + }, generateAab); + if (version >= qbs::Version(6, 0) && version < qbs::Version(6, 3)) { + expectedFile << expandArchs(ndkArchsForQt, { "lib/${ARCH}/libQt6QuickControls2Impl_${ARCH}.so", "lib/${ARCH}/libQt6QuickControls2_${ARCH}.so", "lib/${ARCH}/libQt6QuickParticles_${ARCH}.so", @@ -779,9 +826,6 @@ void TestBlackboxAndroid::android_data() "lib/${ARCH}/libQt6QuickTemplates2_${ARCH}.so", "lib/${ARCH}/libQt6Sql_${ARCH}.so", "lib/${ARCH}/libplugins_sqldrivers_qsqlite_${ARCH}.so", - "lib/${ARCH}/libqml_QtQml_Models_modelsplugin_${ARCH}.so", - "lib/${ARCH}/libqml_QtQml_WorkerScript_workerscriptplugin_${ARCH}.so", - "lib/${ARCH}/libqml_QtQml_qmlplugin_${ARCH}.so", "lib/${ARCH}/libqml_QtQuick_Controls_Basic_impl_qtquickcontrols2basicstyleimplplugin_${ARCH}.so", "lib/${ARCH}/libqml_QtQuick_Controls_Basic_qtquickcontrols2basicstyleplugin_${ARCH}.so", "lib/${ARCH}/libqml_QtQuick_Controls_Fusion_impl_qtquickcontrols2fusionstyleimplplugin_${ARCH}.so", @@ -800,11 +844,9 @@ void TestBlackboxAndroid::android_data() "lib/${ARCH}/libqml_QtQuick_Shapes_qmlshapesplugin_${ARCH}.so", "lib/${ARCH}/libqml_QtQuick_Templates_qtquicktemplates2plugin_${ARCH}.so", "lib/${ARCH}/libqml_QtQuick_Timeline_qtquicktimelineplugin_${ARCH}.so", - "lib/${ARCH}/libqml_QtQuick_Layouts_qquicklayoutsplugin_${ARCH}.so", - "lib/${ARCH}/libqml_QtQuick_qtquick2plugin_${ARCH}.so"}, generateAab); + "lib/${ARCH}/libqml_QtQuick_Layouts_qquicklayoutsplugin_${ARCH}.so"}, generateAab); if (version >= qbs::Version(6, 2)) expectedFile << expandArchs(ndkArchsForQt, { - "lib/${ARCH}/libqml_QtQuick_Window_quickwindowplugin_${ARCH}.so", "lib/${ARCH}/libqml_QtQuick_tooling_quicktoolingplugin_${ARCH}.so", "lib/${ARCH}/libQt6QmlLocalStorage_${ARCH}.so", "lib/${ARCH}/libQt6QmlXmlListModel_${ARCH}.so", @@ -813,9 +855,6 @@ void TestBlackboxAndroid::android_data() "lib/${ARCH}/libQt6QuickDialogs2_${ARCH}.so", "lib/${ARCH}/libQt6QuickLayouts_${ARCH}.so", "lib/${ARCH}/libQt6QuickTimeline_${ARCH}.so", - "lib/${ARCH}/libplugins_networkinformation_qandroidnetworkinformation_${ARCH}.so", - "lib/${ARCH}/libplugins_tls_qcertonlybackend_${ARCH}.so", - "lib/${ARCH}/libplugins_tls_qopensslbackend_${ARCH}.so", "lib/${ARCH}/libqml_QtQml_XmlListModel_qmlxmllistmodelplugin_${ARCH}.so", "lib/${ARCH}/libqml_QtQuick_Dialogs_qtquickdialogsplugin_${ARCH}.so", "lib/${ARCH}/libqml_QtQuick_Dialogs_quickimpl_qtquickdialogs2quickimplplugin_${ARCH}.so"}, @@ -957,14 +996,14 @@ void TestBlackboxAndroid::android_data() << QStringList{aaptVersion(enableAapt2), packageType(generateAab)} << enableAapt2 << generateAab << isIncrementalBuild << enableD8; enableAapt2 = true; - QTest::newRow("aidl") << "aidl" << QStringList("io.qbs.aidltest") + QTest::newRow("aidl aapt2") << "aidl" << QStringList("io.qbs.aidltest") << (QList<QByteArrayList>() << (QByteArrayList() << commonFiles(generateAab) << "resources.arsc")) << QStringList{aaptVersion(enableAapt2), packageType(generateAab)} << enableAapt2 << generateAab << isIncrementalBuild << enableD8; generateAab = true; - QTest::newRow("aidl") << "aidl" << QStringList("io.qbs.aidltest") + QTest::newRow("aidl aab") << "aidl" << QStringList("io.qbs.aidltest") << (QList<QByteArrayList>() << (QByteArrayList() << commonFiles(generateAab) << "base/resources.pb")) @@ -1021,6 +1060,7 @@ void TestBlackboxAndroid::android_data() << QStringList{aaptVersion(enableAapt2), packageType(generateAab), dexCompilerVersion(enableD8)} << enableAapt2 << generateAab << isIncrementalBuild << enableD8; + enableAapt2 = false; generateAab = false; auto expectedFiles1 = [&](bool generateAab) { @@ -1044,7 +1084,6 @@ void TestBlackboxAndroid::android_data() cxxLibPath("libstlport_shared.so", false)}, generateAab); return expectedFile; }; - QTest::newRow("multiple apks") << "multiple-apks-per-project" << (QStringList() << "twolibs1" << "twolibs2") 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()); } diff --git a/tests/auto/blackbox/tst_blackboxapple.h b/tests/auto/blackbox/tst_blackboxapple.h index 32eee2432..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 @@ -55,6 +57,7 @@ private slots: void assetCatalogsMultiple(); void bundleStructure(); void bundleStructure_data(); + void byteArrayInfoPlist(); void codesign(); void codesign_data(); void deploymentTarget(); @@ -71,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 diff --git a/tests/auto/blackbox/tst_blackboxbaremetal.cpp b/tests/auto/blackbox/tst_blackboxbaremetal.cpp index e0a068bc6..ec6ffcdc6 100644 --- a/tests/auto/blackbox/tst_blackboxbaremetal.cpp +++ b/tests/auto/blackbox/tst_blackboxbaremetal.cpp @@ -78,6 +78,15 @@ static QByteArray unsupportedToolsetMessage(const QByteArray &output) + "' for architecture '" + architecture + "'"; } +static QByteArray brokenProbeMessage(const QByteArray &output) +{ + QByteArray toolchain; + QByteArray architecture; + extractToolset(output, toolchain, architecture); + return "Broken probe for toolchain '" + toolchain + + "' for architecture '" + architecture + "'"; +} + TestBlackboxBareMetal::TestBlackboxBareMetal() : TestBlackboxBase (SRCDIR "/testdata-baremetal", "blackbox-baremetal") { @@ -110,7 +119,10 @@ void TestBlackboxBareMetal::application() QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("-n"))), 0); if (m_qbsStdout.contains("unsupported toolset:")) QSKIP(unsupportedToolsetMessage(m_qbsStdout)); - QCOMPARE(runQbs(), 0); + QCOMPARE(runQbs(QbsRunParameters("build")), 0); + if (m_qbsStdout.contains("targetPlatform differs from hostPlatform")) + QSKIP("Cannot run binaries in cross-compiled build"); + QCOMPARE(runQbs(QbsRunParameters("run")), 0); } void TestBlackboxBareMetal::staticLibraryDependencies() @@ -135,6 +147,20 @@ void TestBlackboxBareMetal::externalStaticLibraries() QCOMPARE(runQbs(), 0); } +void TestBlackboxBareMetal::sharedLibraries() +{ + QDir::setCurrent(testDataDir + "/shared-libraries"); + QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("-n"))), 0); + if (m_qbsStdout.contains("unsupported toolset:")) + QSKIP(unsupportedToolsetMessage(m_qbsStdout)); + QCOMPARE(runQbs(QbsRunParameters("build")), 0); + if (m_qbsStdout.contains("targetPlatform differs from hostPlatform")) + QSKIP("Cannot run binaries in cross-compiled build"); + QCOMPARE(runQbs(QbsRunParameters("run")), 0); + QVERIFY2(m_qbsStdout.contains("Hello from app"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("Hello from lib"), m_qbsStdout.constData()); +} + void TestBlackboxBareMetal::userIncludePaths() { QDir::setCurrent(testDataDir + "/user-include-paths"); @@ -274,4 +300,12 @@ void TestBlackboxBareMetal::compilerDefinesByLanguage() QCOMPARE(runQbs(params), 0); } +void TestBlackboxBareMetal::toolchainProbe() +{ + QDir::setCurrent(testDataDir + "/toolchain-probe"); + QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("-n"))), 0); + if (m_qbsStdout.contains("broken probe:")) + QFAIL(brokenProbeMessage(m_qbsStdout)); +} + QTEST_MAIN(TestBlackboxBareMetal) diff --git a/tests/auto/blackbox/tst_blackboxbaremetal.h b/tests/auto/blackbox/tst_blackboxbaremetal.h index 39d2f36c9..9c45fa63c 100644 --- a/tests/auto/blackbox/tst_blackboxbaremetal.h +++ b/tests/auto/blackbox/tst_blackboxbaremetal.h @@ -49,6 +49,8 @@ private slots: void staticLibraryDependencies(); void externalStaticLibraries(); + void sharedLibraries(); + void userIncludePaths(); void systemIncludePaths(); void distributionIncludePaths(); @@ -66,6 +68,8 @@ private slots: void compilerDefinesByLanguage(); + void toolchainProbe(); + private: }; diff --git a/tests/auto/blackbox/tst_blackboxbase.cpp b/tests/auto/blackbox/tst_blackboxbase.cpp index ed0b90b55..317a6b663 100644 --- a/tests/auto/blackbox/tst_blackboxbase.cpp +++ b/tests/auto/blackbox/tst_blackboxbase.cpp @@ -104,6 +104,8 @@ int TestBlackboxBase::runQbs(const QbsRunParameters ¶ms) qDebug("%s", qPrintable(process.errorString())); } exitCode = -1; + } else if (m_qbsStdout.contains("Memory leak:")) { + exitCode = 27; } else { exitCode = process.exitCode(); } @@ -219,7 +221,7 @@ void TestBlackboxBase::validateTestProfile() QString TestBlackboxBase::findExecutable(const QStringList &fileNames) { const QStringList path = QString::fromLocal8Bit(qgetenv("PATH")) - .split(HostOsInfo::pathListSeparator(), QBS_SKIP_EMPTY_PARTS); + .split(HostOsInfo::pathListSeparator(), Qt::SkipEmptyParts); for (const QString &fileName : fileNames) { QFileInfo fi(fileName); @@ -272,3 +274,16 @@ qbs::Version TestBlackboxBase::qmakeVersion(const QString &qmakeFilePath) qDebug() << "qmake '" << qmakeFilePath << "' version is not valid."; return version; } + +bool waitForProcessSuccess(QProcess &p, int msecs) +{ + if (!p.waitForStarted(msecs) || !p.waitForFinished(msecs)) { + qDebug() << p.errorString(); + return false; + } + if (p.exitCode() != 0) { + qDebug() << p.readAllStandardError(); + return false; + } + return true; +} diff --git a/tests/auto/blackbox/tst_blackboxbase.h b/tests/auto/blackbox/tst_blackboxbase.h index d020b7cd9..5733cacd7 100644 --- a/tests/auto/blackbox/tst_blackboxbase.h +++ b/tests/auto/blackbox/tst_blackboxbase.h @@ -90,6 +90,8 @@ public: public slots: virtual void initTestCase(); + static QString findExecutable(const QStringList &fileNames); + protected: virtual void validateTestProfile(); @@ -99,7 +101,6 @@ protected: static QByteArray unifiedLineEndings(const QByteArray &ba); static void sanitizeOutput(QByteArray *ba); static void ccp(const QString &sourceDirPath, const QString &targetDirPath); - static QString findExecutable(const QStringList &fileNames); QMap<QString, QString> findJdkTools(int *status); static qbs::Version qmakeVersion(const QString &qmakeFilePath); @@ -113,4 +114,6 @@ protected: int m_needsQt = false; }; +bool waitForProcessSuccess(QProcess &p, int msecs = 30000); + #endif // TST_BLACKBOXBASE_H diff --git a/tests/auto/blackbox/tst_blackboxexamples.cpp b/tests/auto/blackbox/tst_blackboxexamples.cpp index b6a26b7f3..13ccb7796 100644 --- a/tests/auto/blackbox/tst_blackboxexamples.cpp +++ b/tests/auto/blackbox/tst_blackboxexamples.cpp @@ -82,6 +82,7 @@ void TestBlackboxExamples::examples_data() auto examples = collectExamples(testDataDir); examples.append(collectExamples(testDataDir + "/protobuf")); + examples.append(collectExamples(testDataDir + "/flatbuffers")); std::sort(examples.begin(), examples.end()); for (const auto &example: examples) { diff --git a/tests/auto/blackbox/tst_blackboxjava.cpp b/tests/auto/blackbox/tst_blackboxjava.cpp index 9495ab1b7..4ddd6cdda 100644 --- a/tests/auto/blackbox/tst_blackboxjava.cpp +++ b/tests/auto/blackbox/tst_blackboxjava.cpp @@ -39,7 +39,9 @@ using qbs::Internal::HostOsInfo; using qbs::Profile; -TestBlackboxJava::TestBlackboxJava() : TestBlackboxBase (SRCDIR "/testdata-java", "blackbox-java") +TestBlackboxJava::TestBlackboxJava() + : TestBlackboxBase (SRCDIR "/testdata-java", "blackbox-java"), + m_blacklistedJdks(qgetenv("QBS_AUTOTEST_JDK_BLACKLIST")) { } @@ -96,7 +98,7 @@ void TestBlackboxJava::java() // Now check whether we correctly predicted the class file output paths. QCOMPARE(runQbs(QbsRunParameters("clean")), 0); - for (const QString &classFile : qAsConst(classFiles1)) { + for (const QString &classFile : std::as_const(classFiles1)) { QVERIFY2(!regularFileExists(classFile), qPrintable(classFile)); } @@ -148,8 +150,11 @@ void TestBlackboxJava::javaDependencyTracking() QDir::setCurrent(testDataDir + "/java"); QbsRunParameters rp; rp.arguments.push_back("--check-outputs"); - if (!jdkPath.isEmpty()) + if (!jdkPath.isEmpty()) { + if (m_blacklistedJdks.contains(jdkPath)) + QSKIP("skipping blacklisted JDK"); rp.arguments << ("modules.java.jdkPath:" + jdkPath); + } if (!javaVersion.isEmpty()) rp.arguments << ("modules.java.languageVersion:'" + javaVersion + "'"); rmDirR(relativeBuildDir()); @@ -170,7 +175,7 @@ void TestBlackboxJava::javaDependencyTracking_data() auto getSpecificJdkVersion = [](const QString &jdkVersion) -> QString { if (HostOsInfo::isMacosHost()) { QProcess java_home; - java_home.start("/usr/libexec/java_home", QStringList() << "--version" << jdkVersion); + java_home.start("/usr/libexec/java_home", {"--version", jdkVersion, "--failfast"}); java_home.waitForFinished(); if (java_home.exitStatus() == QProcess::NormalExit && java_home.exitCode() == 0) return QString::fromLocal8Bit(java_home.readAllStandardOutput().trimmed()); diff --git a/tests/auto/blackbox/tst_blackboxjava.h b/tests/auto/blackbox/tst_blackboxjava.h index 68d8a7f80..e770306df 100644 --- a/tests/auto/blackbox/tst_blackboxjava.h +++ b/tests/auto/blackbox/tst_blackboxjava.h @@ -43,6 +43,9 @@ private slots: void javaDependencyTracking(); void javaDependencyTracking_data(); void javaDependencyTrackingInnerClass(); + +private: + const QStringList m_blacklistedJdks; }; #endif // TST_BLACKBOX_H diff --git a/tests/auto/blackbox/tst_blackboxjoblimits.cpp b/tests/auto/blackbox/tst_blackboxjoblimits.cpp index df6435a2c..acaf69a5b 100644 --- a/tests/auto/blackbox/tst_blackboxjoblimits.cpp +++ b/tests/auto/blackbox/tst_blackboxjoblimits.cpp @@ -178,7 +178,7 @@ void TestBlackboxJobLimits::jobLimits() else QVERIFY2(m_qbsStderr.contains("exclusive"), m_qbsStderr.constData()); if (exitCode == 0) - QCOMPARE(m_qbsStdout.count("Running tool"), 5); + QCOMPARE(m_qbsStdout.count("running tool"), 5); } QTEST_MAIN(TestBlackboxJobLimits) diff --git a/tests/auto/blackbox/tst_blackboxproviders.cpp b/tests/auto/blackbox/tst_blackboxproviders.cpp new file mode 100644 index 000000000..cf6594229 --- /dev/null +++ b/tests/auto/blackbox/tst_blackboxproviders.cpp @@ -0,0 +1,443 @@ +/**************************************************************************** +** +** Copyright (C) 2023 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "tst_blackboxproviders.h" + +#include "../shared.h" + +// #include <tools/hostosinfo.h> +// #include <tools/profile.h> +// #include <tools/qttools.h> + +// #include <QtCore/qdir.h> +// #include <QtCore/qregularexpression.h> + +// using qbs::Internal::HostOsInfo; +// using qbs::Profile; + +#define WAIT_FOR_NEW_TIMESTAMP() waitForNewTimestamp(testDataDir) + +TestBlackboxProviders::TestBlackboxProviders() + : TestBlackboxBase(SRCDIR "/testdata-providers", "blackbox-providers") +{ +} + +void TestBlackboxProviders::allowedValues() +{ + QFETCH(QStringList, arguments); + QFETCH(bool, expectFailure); + + QDir::setCurrent(testDataDir + "/allowed-values"); + rmDirR(relativeBuildDir()); + QbsRunParameters params; + params.arguments = arguments; + params.expectFailure = expectFailure; + + QVERIFY2(runQbs(params) == int(expectFailure), m_qbsStderr); +} + +void TestBlackboxProviders::allowedValues_data() +{ + QTest::addColumn<QStringList>("arguments"); + QTest::addColumn<bool>("expectFailure"); + + QTest::newRow("invalid js value") << QStringList{} << true; + QTest::newRow("invalid variant value") + << QStringList{"moduleProviders.provider.aProperty:three"} << true; + QTest::newRow("valid variant value") + << QStringList{"moduleProviders.provider.aProperty:one"} << false; +} + +void TestBlackboxProviders::brokenProvider() +{ + QDir::setCurrent(testDataDir + "/broken-provider"); + QbsRunParameters params; + params.expectFailure = true; + QVERIFY(runQbs(params) != 0); + + QVERIFY(m_qbsStderr.contains("Error executing provider for module 'qbsothermodule'")); + QVERIFY(m_qbsStderr.contains("Error executing provider for module 'qbsmetatestmodule'")); + QCOMPARE(m_qbsStderr.count("This provider is broken"), 2); +} + +void TestBlackboxProviders::conanProvider() +{ + QFETCH(bool, generateConanFiles); + QFETCH(bool, successExpected); + + const auto executable = findExecutable({"conan"}); + if (executable.isEmpty()) + QSKIP("conan is not installed or not available in PATH."); + + const auto generator = QDir::homePath() + "/.conan2/extensions/generators/qbsdeps.py"; + if (!QFileInfo(generator).exists()) { + QSKIP( + "qbsdeps.py is not installed, call 'conan config install src/conan/ from qbs source'."); + } + + const auto profilePath = QDir::homePath() + "/.conan2/profiles/qbs-test"; + if (!QFileInfo(profilePath).exists()) + QSKIP("conan profile is not installed, run './scripts/setup-conan-profiles.sh'."); + + // install testlibdep first + QProcess conan; + QDir::setCurrent(testDataDir + "/conan-provider/testlibdep"); + conan.start(executable, {"create", ".", "--profile:all=qbs-test"}); + QVERIFY(waitForProcessSuccess(conan)); + + // install testlib second + QDir::setCurrent(testDataDir + "/conan-provider/testlib"); + conan.start(executable, {"create", ".", "--profile:all=qbs-test"}); + QVERIFY(waitForProcessSuccess(conan)); + + // install header lib third + QDir::setCurrent(testDataDir + "/conan-provider/testlibheader"); + conan.start(executable, {"create", ".", "--profile:all=qbs-test"}); + QVERIFY(waitForProcessSuccess(conan)); + + // now build an app using those libs + QDir::setCurrent(testDataDir + "/conan-provider"); + + rmDirR(relativeBuildDir()); + rmDirR("build"); + + if (generateConanFiles) { + QStringList arguments{ + "install", ".", "-g=QbsDeps", "--profile:all=qbs-test", "--output-folder=build"}; + QProcess conan; + conan.start(executable, arguments); + QVERIFY(waitForProcessSuccess(conan)); + } + + QbsRunParameters buildParams( + "build", + {"--force-probe-execution", + "moduleProviders.conan.installDirectory:" + QDir::currentPath() + "/build"}); + buildParams.expectFailure = !successExpected; + QCOMPARE(runQbs(buildParams) == 0, successExpected); +} + +void TestBlackboxProviders::conanProvider_data() +{ + QTest::addColumn<bool>("generateConanFiles"); + QTest::addColumn<bool>("successExpected"); + + QTest::addRow("no conan files generated") << false << false; + QTest::addRow("conan files generated") << true << true; +} + +void TestBlackboxProviders::moduleProviders() +{ + QDir::setCurrent(testDataDir + "/module-providers"); + + // Resolving in dry-run mode must not leave any data behind. + QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("-n"))), 0); + if (m_qbsStdout.contains("targetPlatform differs from hostPlatform")) + QSKIP("Cannot run binaries in cross-compiled build"); + QCOMPARE(m_qbsStdout.count("Running setup script for mygenerator"), 2); + QVERIFY(!QFile::exists(relativeBuildDir())); + + // Initial build. + QCOMPARE(runQbs(QbsRunParameters("run", QStringList{"-p", "app1"})), 0); + QVERIFY(QFile::exists(relativeBuildDir())); + QCOMPARE(m_qbsStdout.count("Running setup script for mygenerator"), 2); + QVERIFY2(m_qbsStdout.contains("The letters are A and B"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("The MY_DEFINE is app1"), m_qbsStdout.constData()); + QCOMPARE(runQbs(QbsRunParameters("run", QStringList{"-p", "app2"})), 0); + QVERIFY2(m_qbsStdout.contains("The letters are Z and Y"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("The MY_DEFINE is app2"), m_qbsStdout.constData()); + + // Rebuild with overridden module provider config. The output for product 2 must change, + // but no setup script must be re-run, because both config values have already been + // handled in the first run. + const QStringList resolveArgs("moduleProviders.mygenerator.chooseLettersFrom:beginning"); + QCOMPARE(runQbs(QbsRunParameters("resolve", resolveArgs)), 0); + QVERIFY2(!m_qbsStdout.contains("Running setup script"), m_qbsStdout.constData()); + QCOMPARE(runQbs(QbsRunParameters("run", QStringList{"-p", "app1"})), 0); + QVERIFY2(m_qbsStdout.contains("The letters are A and B"), m_qbsStdout.constData()); + QCOMPARE(runQbs(QbsRunParameters("run", QStringList{"-p", "app2"})), 0); + QVERIFY2(m_qbsStdout.contains("The letters are A and B"), m_qbsStdout.constData()); + + // Forcing Probe execution triggers a re-run of the setup script. But only once, + // because the module provider config is the same now. + QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList(resolveArgs) + << "--force-probe-execution")), 0); + QCOMPARE(m_qbsStdout.count("Running setup script for mygenerator"), 1); + QCOMPARE(runQbs(QbsRunParameters("run", QStringList{"-p", "app1"})), 0); + QVERIFY2(m_qbsStdout.contains("The letters are A and B"), m_qbsStdout.constData()); + QCOMPARE(runQbs(QbsRunParameters("run", QStringList{"-p", "app2"})), 0); + QVERIFY2(m_qbsStdout.contains("The letters are A and B"), m_qbsStdout.constData()); + + // Now re-run without the module provider config override. Again, the setup script must + // run once, for the config value that was not present in the last run. + QCOMPARE(runQbs(QbsRunParameters("resolve")), 0); + QCOMPARE(m_qbsStdout.count("Running setup script for mygenerator"), 1); + QCOMPARE(runQbs(QbsRunParameters("run", QStringList{"-p", "app1"})), 0); + QVERIFY2(m_qbsStdout.contains("The letters are A and B"), m_qbsStdout.constData()); + QCOMPARE(runQbs(QbsRunParameters("run", QStringList{"-p", "app2"})), 0); + QVERIFY2(m_qbsStdout.contains("The letters are Z and Y"), m_qbsStdout.constData()); +} + +// Checks regression - when loading 2 modules from the same provider, the second module should +// come from provider cache +void TestBlackboxProviders::moduleProvidersCache() +{ + QDir::setCurrent(testDataDir + "/module-providers-cache"); + + QbsRunParameters params("resolve", {"-v"}); + QCOMPARE(runQbs(params), 0); + const auto qbsmetatestmoduleMessage = "Re-checking for module \"qbsmetatestmodule\" with " + "newly added search paths from module provider"; + const auto qbsothermoduleMessage = "Re-checking for module \"qbsothermodule\" with " + "newly added search paths from module provider"; + QCOMPARE(m_qbsStderr.count(qbsmetatestmoduleMessage), 1); + QCOMPARE(m_qbsStderr.count(qbsothermoduleMessage), 1); + QCOMPARE(m_qbsStderr.count("Re-using provider \"provider_a\" from cache"), 1); + + // We didn't change providers, so both modules should come from cache. + params.arguments << "project.dummyProp:value"; + QCOMPARE(runQbs(params), 0); + QCOMPARE(m_qbsStderr.count(qbsmetatestmoduleMessage), 1); + QCOMPARE(m_qbsStderr.count(qbsothermoduleMessage), 1); + QCOMPARE(m_qbsStderr.count("Re-using provider \"provider_a\" from cache"), 2); +} + +void TestBlackboxProviders::nonEagerModuleProvider() +{ + QDir::setCurrent(testDataDir + "/non-eager-provider"); + + QbsRunParameters params("resolve"); + QCOMPARE(runQbs(params), 0); + QVERIFY2(m_qbsStdout.contains(("Running setup script for qbsmetatestmodule")), m_qbsStdout); + QVERIFY2(m_qbsStdout.contains(("Running setup script for qbsothermodule")), m_qbsStdout); + QVERIFY2(!m_qbsStdout.contains(("Running setup script for nonexistentmodule")), m_qbsStdout); + + QVERIFY2(m_qbsStdout.contains(("p1.qbsmetatestmodule.prop: from_provider_a")), + m_qbsStdout); + QVERIFY2(m_qbsStdout.contains(("p1.qbsothermodule.prop: from_provider_a")), + m_qbsStdout); +} + +void TestBlackboxProviders::probeInModuleProvider() +{ + QDir::setCurrent(testDataDir + "/probe-in-module-provider"); + + QbsRunParameters params; + params.command = "build"; + params.arguments << "--force-probe-execution"; + QCOMPARE(runQbs(params), 0); + QVERIFY2(m_qbsStdout.contains("Running probe"), m_qbsStdout); + QVERIFY2(m_qbsStdout.contains("p.qbsmetatestmodule.boolProp: true"), m_qbsStdout); + WAIT_FOR_NEW_TIMESTAMP(); + touch("probe-in-module-provider.qbs"); + QCOMPARE(runQbs(), 0); + QVERIFY2(m_qbsStdout.contains("p.qbsmetatestmodule.boolProp: true"), m_qbsStdout); + QVERIFY2(m_qbsStdout.contains("p.qbsmetatestmodule.prop: \"value\""), m_qbsStdout); + QVERIFY2(!m_qbsStdout.contains("Running probe"), m_qbsStdout); +} + +// Tests whether it is possible to set providers properties in a Product or from command-line +void TestBlackboxProviders::providersProperties() +{ + QDir::setCurrent(testDataDir + "/providers-properties"); + + QbsRunParameters params("build"); + params.arguments = QStringList("moduleProviders.provider_b.someProp: \"first,second\""); + QCOMPARE(runQbs(params), 0); + QVERIFY2(m_qbsStdout.contains("p.qbsmetatestmodule.listProp: [\"someValue\"]"), m_qbsStdout); + QVERIFY2(m_qbsStdout.contains( + "p.qbsothermodule.listProp: [\"first\",\"second\"]"), m_qbsStdout); +} + +// checks that we can set qbs module properties in providers and provider cache works corectly +void TestBlackboxProviders::qbsModulePropertiesInProviders() +{ + QDir::setCurrent(testDataDir + "/qbs-module-properties-in-providers"); + + QbsRunParameters params("resolve"); + + QCOMPARE(runQbs(params), 0); + + // We have 2 products in 2 configurations, but second product should use the cached value + // so we should have only 2 copies of the module, not 4. + QCOMPARE(m_qbsStdout.count("Running setup script for qbsmetatestmodule"), 2); + + // Check that products get correct values from modules + QVERIFY2(m_qbsStdout.contains(("product1.qbsmetatestmodule.prop: /sysroot1")), m_qbsStdout); + QVERIFY2(m_qbsStdout.contains(("product1.qbsmetatestmodule.prop: /sysroot2")), m_qbsStdout); + + QVERIFY2(m_qbsStdout.contains(("product2.qbsmetatestmodule.prop: /sysroot1")), m_qbsStdout); + QVERIFY2(m_qbsStdout.contains(("product2.qbsmetatestmodule.prop: /sysroot2")), m_qbsStdout); +} + +void TestBlackboxProviders::qbsModuleProviders_data() +{ + QTest::addColumn<QStringList>("arguments"); + QTest::addColumn<QString>("firstProp"); + QTest::addColumn<QString>("secondProp"); + + QTest::newRow("default") << QStringList() << "from_provider_a" << "undefined"; + QTest::newRow("override") + << QStringList("projects.project.qbsModuleProviders:provider_b") + << "from_provider_b" + << "from_provider_b"; + QTest::newRow("override list a") + << QStringList("projects.project.qbsModuleProviders:provider_a,provider_b") + << "from_provider_a" + << "from_provider_b"; + QTest::newRow("override list b") + << QStringList("projects.project.qbsModuleProviders:provider_b,provider_a") + << "from_provider_b" + << "from_provider_b"; +} + +// Tests whether it is possible to set qbsModuleProviders in Product and Project items +// and that the order of providers results in correct priority +void TestBlackboxProviders::qbsModuleProviders() +{ + QFETCH(QStringList, arguments); + QFETCH(QString, firstProp); + QFETCH(QString, secondProp); + + QDir::setCurrent(testDataDir + "/qbs-module-providers"); + + QbsRunParameters params("resolve"); + params.arguments = arguments; + QCOMPARE(runQbs(params), 0); + QVERIFY2(m_qbsStdout.contains(("p1.qbsmetatestmodule.prop: " + firstProp).toUtf8()), + m_qbsStdout); + QVERIFY2(m_qbsStdout.contains(("p1.qbsothermodule.prop: " + secondProp).toUtf8()), + m_qbsStdout); + QVERIFY2(m_qbsStdout.contains(("p2.qbsmetatestmodule.prop: " + firstProp).toUtf8()), + m_qbsStdout); + QVERIFY2(m_qbsStdout.contains(("p2.qbsothermodule.prop: " + secondProp).toUtf8()), + m_qbsStdout); +} + +void TestBlackboxProviders::qbsModuleProvidersCliOverride_data() +{ + QTest::addColumn<QStringList>("arguments"); + QTest::addColumn<QString>("propertyValue"); + + QTest::newRow("default") << QStringList() << "undefined"; + QTest::newRow("project-wide") + << QStringList("project.qbsModuleProviders:provider_a") + << "from_provider_a"; + QTest::newRow("concrete project") + << QStringList("projects.innerProject.qbsModuleProviders:provider_a") + << "from_provider_a"; + QTest::newRow("concrete product") + << QStringList("products.product.qbsModuleProviders:provider_a") + << "from_provider_a"; + QTest::newRow("concrete project override project-wide") + << QStringList({ + "project.qbsModuleProviders:provider_a", + "projects.innerProject.qbsModuleProviders:provider_b"}) + << "from_provider_b"; + QTest::newRow("concrete product override project-wide") + << QStringList({ + "project.qbsModuleProviders:provider_a", + "products.product.qbsModuleProviders:provider_b"}) + << "from_provider_b"; +} + +// Tests possible use-cases how to override providers from command-line +void TestBlackboxProviders::qbsModuleProvidersCliOverride() +{ + QFETCH(QStringList, arguments); + QFETCH(QString, propertyValue); + + QDir::setCurrent(testDataDir + "/qbs-module-providers-cli-override"); + + QbsRunParameters params("resolve"); + params.arguments = arguments; + QCOMPARE(runQbs(params), 0); + QVERIFY2(m_qbsStdout.contains(("qbsmetatestmodule.prop: " + propertyValue).toUtf8()), + m_qbsStdout); +} + +void TestBlackboxProviders::qbsModuleProvidersCompatibility_data() +{ + QTest::addColumn<QStringList>("arguments"); + QTest::addColumn<QString>("propertyValue"); + + QTest::newRow("default") << QStringList() << "from_scoped_provider"; + QTest::newRow("scoped by name") << QStringList("project.qbsModuleProviders:qbsmetatestmodule") << "from_scoped_provider"; + QTest::newRow("named") << QStringList("project.qbsModuleProviders:named_provider") << "from_named_provider"; +} + +// Tests whether scoped providers can be used as named, i.e. new provider machinery +// is compatible with the old one +void TestBlackboxProviders::qbsModuleProvidersCompatibility() +{ + QFETCH(QStringList, arguments); + QFETCH(QString, propertyValue); + + QDir::setCurrent(testDataDir + "/qbs-module-providers-compatibility"); + + QbsRunParameters params("resolve"); + params.arguments = arguments; + QCOMPARE(runQbs(params), 0); + QVERIFY2(m_qbsStdout.contains(("qbsmetatestmodule.prop: " + propertyValue).toUtf8()), + m_qbsStdout); +} + +void TestBlackboxProviders::qbspkgconfigModuleProvider() +{ + QDir::setCurrent(testDataDir + "/qbspkgconfig-module-provider/libs"); + rmDirR(relativeBuildDir()); + + const auto commonParams = QbsRunParameters(QStringLiteral("install"), { + QStringLiteral("--install-root"), + QStringLiteral("install-root") + }); + auto dynamicParams = commonParams; + dynamicParams.arguments << "config:library" << "projects.libs.isBundle:false"; + QCOMPARE(runQbs(dynamicParams), 0); + + QDir::setCurrent(testDataDir + "/qbspkgconfig-module-provider"); + rmDirR(relativeBuildDir()); + + const auto sysroot = testDataDir + "/qbspkgconfig-module-provider/libs/install-root"; + + QbsRunParameters params; + params.arguments << "moduleProviders.qbspkgconfig.sysroot:" + sysroot; + QCOMPARE(runQbs(params), 0); +} + +void TestBlackboxProviders::removalVersion() +{ + QDir::setCurrent(testDataDir + "/removal-version"); + QCOMPARE(runQbs(), 0); + QVERIFY(m_qbsStderr.contains( + "Property 'deprecated' was scheduled for removal in version 2.2.0, but is still present")); +} + +QTEST_MAIN(TestBlackboxProviders) diff --git a/tests/auto/blackbox/tst_blackboxproviders.h b/tests/auto/blackbox/tst_blackboxproviders.h new file mode 100644 index 000000000..088cea6a3 --- /dev/null +++ b/tests/auto/blackbox/tst_blackboxproviders.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2023 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef TST_BLACKBOXPROVIDERS_H +#define TST_BLACKBOXPROVIDERS_H + +#include "tst_blackboxbase.h" + +class TestBlackboxProviders : public TestBlackboxBase +{ + Q_OBJECT + +public: + TestBlackboxProviders(); + +private slots: + void allowedValues(); + void allowedValues_data(); + void brokenProvider(); + void conanProvider(); + void conanProvider_data(); + void moduleProviders(); + void moduleProvidersCache(); + void nonEagerModuleProvider(); + void probeInModuleProvider(); + void providersProperties(); + void qbsModulePropertiesInProviders(); + void qbsModuleProviders_data(); + void qbsModuleProviders(); + void qbsModuleProvidersCliOverride(); + void qbsModuleProvidersCliOverride_data(); + void qbsModuleProvidersCompatibility(); + void qbsModuleProvidersCompatibility_data(); + void qbspkgconfigModuleProvider(); + void removalVersion(); +}; + +#endif // TST_BLACKBOXPROVIDERS_H diff --git a/tests/auto/blackbox/tst_blackboxqt.cpp b/tests/auto/blackbox/tst_blackboxqt.cpp index 53fadc490..b083a97e8 100644 --- a/tests/auto/blackbox/tst_blackboxqt.cpp +++ b/tests/auto/blackbox/tst_blackboxqt.cpp @@ -38,7 +38,6 @@ #define WAIT_FOR_NEW_TIMESTAMP() waitForNewTimestamp(testDataDir) using qbs::Internal::HostOsInfo; -using qbs::Profile; TestBlackboxQt::TestBlackboxQt() : TestBlackboxBase (SRCDIR "/testdata-qt", "blackbox-qt") { @@ -240,7 +239,7 @@ void TestBlackboxQt::mixedBuildVariants() { QDir::setCurrent(testDataDir + "/mixed-build-variants"); const SettingsPtr s = settings(); - Profile profile(profileName(), s.get()); + qbs::Profile profile(profileName(), s.get()); if (profileToolchain(profile).contains("msvc")) { QbsRunParameters params; params.arguments << "qbs.buildVariant:debug"; @@ -285,6 +284,57 @@ void TestBlackboxQt::mocSameFileName() QCOMPARE(m_qbsStdout.count("compiling moc_someclass.cpp"), 2); } +void TestBlackboxQt::noRelinkOnQDebug() +{ + QFETCH(QString, checkMode); + QFETCH(bool, expectRelink); + + QVERIFY(QDir::setCurrent(testDataDir + "/no-relink-on-qdebug")); + rmDirR("default"); + + // Target check. + QCOMPARE(runQbs(QbsRunParameters("resolve")), 0); + QVERIFY2(m_qbsStdout.contains("is GCC: "), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("is MinGW: "), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("is Darwin: "), m_qbsStdout.constData()); + const bool isGCCLike = m_qbsStdout.contains("is GCC: true"); + const bool isMingw = m_qbsStdout.contains("is MinGW: true"); + const bool isDarwin = m_qbsStdout.contains("is Darwin: true"); + if (!isGCCLike) + expectRelink = false; + else if (isMingw || isDarwin) + expectRelink = true; + + // Initial build. + QbsRunParameters params("resolve"); + if (isGCCLike && !checkMode.isEmpty()) + params.arguments << ("modules.cpp.exportedSymbolsCheckMode:" + checkMode); + QCOMPARE(runQbs(params), 0); + QCOMPARE(runQbs(), 0); + QCOMPARE(m_qbsStdout.count("linking"), 2); + + // Inserting the qDebug() statement will pull in weak symbols. + WAIT_FOR_NEW_TIMESTAMP(); + REPLACE_IN_FILE("lib.cpp", "// qDebug", "qDebug"); + QCOMPARE(runQbs(), 0); + QCOMPARE(m_qbsStdout.count("linking"), expectRelink ? 2 : 1); + + // Also check the opposite case. + WAIT_FOR_NEW_TIMESTAMP(); + REPLACE_IN_FILE("lib.cpp", "qDebug", "// qDebug"); + QCOMPARE(runQbs(), 0); + QCOMPARE(m_qbsStdout.count("linking"), expectRelink ? 2 : 1); +} + +void TestBlackboxQt::noRelinkOnQDebug_data() +{ + QTest::addColumn<QString>("checkMode"); + QTest::addColumn<bool>("expectRelink"); + QTest::newRow("default") << QString() << false; + QTest::newRow("relaxed") << QString("ignore-undefined") << false; + QTest::newRow("strict") << QString("strict") << true; +} + void TestBlackboxQt::pkgconfig() { QDir::setCurrent(testDataDir + "/pkgconfig"); @@ -298,6 +348,68 @@ 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()); + auto prefix = QFileInfo(libPath).path(); + if (prefix.endsWith("/lib") && !prefix.startsWith("/lib")) + prefix = QFileInfo(prefix).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.environment.insert("PKG_CONFIG_QT6CORE_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; + QTest::newRow("cross-compiling") + << QStringList({"moduleProviders.qbspkgconfig.sysroot:/some/fake/sysroot"}) << false; +} + +void TestBlackboxQt::pkgconfigNoQt() +{ + QDir::setCurrent(testDataDir + "/pkgconfig-qt"); + rmDirR(relativeBuildDir()); + QbsRunParameters params("build", {"-f", "pkgconfig-qt.qbs"}); + params.arguments << "moduleProviders.qbspkgconfig.libDirs:nonexistent"; + params.expectFailure = true; + + QCOMPARE(runQbs(params) == 0, false); + QVERIFY2(m_qbsStderr.contains("Dependency 'Qt.core' not found for product 'p'"), m_qbsStderr); + // QBS-1777: basic check for JS exceptions in case of missing Qt + QVERIFY2(!m_qbsStderr.contains("Error executing provider for module 'Qt.core'"), m_qbsStderr); +} + void TestBlackboxQt::pluginMetaData() { QDir::setCurrent(testDataDir + "/plugin-meta-data"); @@ -371,22 +483,36 @@ void TestBlackboxQt::pluginSupport() } } +void TestBlackboxQt::qdoc() +{ + QDir::setCurrent(testDataDir + "/qdoc"); + QCOMPARE(runQbs(QbsRunParameters("resolve")), 0); + if (m_qbsStdout.contains("Qt is too old")) + QSKIP("Skip test since qdoc3 does not work properly"); + QCOMPARE(runQbs(), 0); + QVERIFY(QFileInfo(relativeProductBuildDir("QDoc Test") + "/qdoctest.qch").exists()); +} + void TestBlackboxQt::qmlDebugging() { QDir::setCurrent(testDataDir + "/qml-debugging"); QCOMPARE(runQbs(), 0); - const SettingsPtr s = settings(); - Profile profile(profileName(), s.get()); - if (!profileToolchain(profile).contains("gcc")) - return; + + const bool isGcc = m_qbsStdout.contains("is gcc: true"); + const bool isNotGcc = m_qbsStdout.contains("is gcc: false"); + if (isNotGcc) + QSKIP("The remainder of this test only applies to gcc"); + QVERIFY(isGcc); + QProcess nm; nm.start("nm", QStringList(relativeExecutableFilePath("debuggable-app"))); - if (nm.waitForStarted()) { // Let's ignore hosts without nm. - QVERIFY2(nm.waitForFinished(), qPrintable(nm.errorString())); - QVERIFY2(nm.exitCode() == 0, nm.readAllStandardError().constData()); - const QByteArray output = nm.readAllStandardOutput(); - QVERIFY2(output.toLower().contains("debugginghelper"), output.constData()); - } + if (!nm.waitForStarted()) + QSKIP("The remainder of this test requires nm"); + + QVERIFY2(nm.waitForFinished(), qPrintable(nm.errorString())); + QVERIFY2(nm.exitCode() == 0, nm.readAllStandardError().constData()); + const QByteArray output = nm.readAllStandardOutput(); + QVERIFY2(output.toLower().contains("debugginghelper"), output.constData()); } void TestBlackboxQt::qobjectInObjectiveCpp() @@ -515,10 +641,10 @@ void TestBlackboxQt::staticQtPluginLinking() QDir::setCurrent(testDataDir + "/static-qt-plugin-linking"); QCOMPARE(runQbs(QStringList("products.p.type:application")), 0); const bool isStaticQt = m_qbsStdout.contains("Qt is static"); - QVERIFY2(m_qbsStdout.contains("Creating static import") == isStaticQt, m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("creating static import") == isStaticQt, m_qbsStdout.constData()); QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("products.p.type:staticlibrary"))), 0); QCOMPARE(runQbs(), 0); - QVERIFY2(!m_qbsStdout.contains("Creating static import"), m_qbsStdout.constData()); + QVERIFY2(!m_qbsStdout.contains("creating static import"), m_qbsStdout.constData()); } void TestBlackboxQt::trackAddMocInclude() diff --git a/tests/auto/blackbox/tst_blackboxqt.h b/tests/auto/blackbox/tst_blackboxqt.h index 820df26d9..da395b7d4 100644 --- a/tests/auto/blackbox/tst_blackboxqt.h +++ b/tests/auto/blackbox/tst_blackboxqt.h @@ -57,10 +57,16 @@ private slots: void mocFlags(); void mocCompilerDefines(); void mocSameFileName(); + void noRelinkOnQDebug(); + void noRelinkOnQDebug_data(); void pkgconfig(); + void pkgconfigQt(); + void pkgconfigQt_data(); + void pkgconfigNoQt(); void pluginMetaData(); void pluginSupport_data(); void pluginSupport(); + void qdoc(); void qmlDebugging(); void qobjectInObjectiveCpp(); void qmlTypeRegistrar_data(); diff --git a/tests/auto/blackbox/tst_blackboxtutorial.cpp b/tests/auto/blackbox/tst_blackboxtutorial.cpp new file mode 100644 index 000000000..49de448a1 --- /dev/null +++ b/tests/auto/blackbox/tst_blackboxtutorial.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2024 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "tst_blackboxtutorial.h" + +#include <QtCore/qdir.h> +#include <QtCore/qdiriterator.h> + +static QStringList collectProjects(const QString &dirPath) +{ + QStringList result; + QDir dir(dirPath); + const auto subDirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); + for (const auto &subDir : subDirs) { + const auto path = dir.filePath(subDir); + if (!QFileInfo::exists(path + "/myproject.qbs")) + continue; + result.append(dir.relativeFilePath(path)); + } + return result; +} + +TestBlackboxTutorial::TestBlackboxTutorial() + : TestBlackboxBase(SRCDIR "/../../../tutorial/", "blackbox-tutorial") +{} + +void TestBlackboxTutorial::tutorial_data() +{ + QTest::addColumn<QString>("project"); + + const auto projects = collectProjects(testDataDir); + for (const auto &project : projects) { + QTest::newRow(project.toUtf8().data()) << project; + } +} + +void TestBlackboxTutorial::tutorial() +{ + QFETCH(QString, project); + + QVERIFY(QDir::setCurrent(testDataDir + "/" + project)); + QCOMPARE(runQbs(), 0); +} + +QTEST_MAIN(TestBlackboxTutorial) diff --git a/tests/auto/blackbox/tst_blackboxtutorial.h b/tests/auto/blackbox/tst_blackboxtutorial.h new file mode 100644 index 000000000..2e84d6a96 --- /dev/null +++ b/tests/auto/blackbox/tst_blackboxtutorial.h @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2024 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef TST_BLACKBOXTUTORIAL_H +#define TST_BLACKBOXTUTORIAL_H + +#include "tst_blackboxbase.h" + +class TestBlackboxTutorial : public TestBlackboxBase +{ + Q_OBJECT + +public: + TestBlackboxTutorial(); + +private slots: + void tutorial_data(); + void tutorial(); +}; + +#endif // TST_BLACKBOXTUTORIAL_H diff --git a/tests/auto/blackbox/tst_blackboxwindows.cpp b/tests/auto/blackbox/tst_blackboxwindows.cpp index 94257c062..57bd7f947 100644 --- a/tests/auto/blackbox/tst_blackboxwindows.cpp +++ b/tests/auto/blackbox/tst_blackboxwindows.cpp @@ -228,9 +228,9 @@ static bool haveWiX(const Profile &profile) << QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Installer XML\\"); QStringList paths = QProcessEnvironment::systemEnvironment().value("PATH") - .split(HostOsInfo::pathListSeparator(), QBS_SKIP_EMPTY_PARTS); + .split(HostOsInfo::pathListSeparator(), Qt::SkipEmptyParts); - for (const QString &key : qAsConst(regKeys)) { + for (const QString &key : std::as_const(regKeys)) { const QStringList versions = QSettings(key, QSettings::NativeFormat).childGroups(); for (const QString &version : versions) { QSettings settings(key + version, QSettings::NativeFormat); @@ -240,7 +240,7 @@ static bool haveWiX(const Profile &profile) } } - for (const QString &path : qAsConst(paths)) { + for (const QString &path : std::as_const(paths)) { if (regularFileExists(QDir::fromNativeSeparators(path) + HostOsInfo::appendExecutableSuffix(QStringLiteral("/candle"))) && regularFileExists(QDir::fromNativeSeparators(path) + |