diff options
Diffstat (limited to 'tests/auto/blackbox')
22 files changed, 375 insertions, 1 deletions
diff --git a/tests/auto/blackbox/testdata-qt/cached-qml/cached-qml.qbs b/tests/auto/blackbox/testdata-qt/cached-qml/cached-qml.qbs index db9dcae0c..397c2a691 100644 --- a/tests/auto/blackbox/testdata-qt/cached-qml/cached-qml.qbs +++ b/tests/auto/blackbox/testdata-qt/cached-qml/cached-qml.qbs @@ -1,4 +1,5 @@ import qbs +import qbs.Utilities CppApplication { name: "app" @@ -26,4 +27,13 @@ CppApplication { qbs.install: true qbs.installDir: "data" } + + Probe { + id: qtVersionProbe + property string qtVersion: Qt.core.version + configure: { + console.info("qmlcachegen must work: " + + (Utilities.versionCompare(qtVersion, "5.11") >= 0)) + } + } } diff --git a/tests/auto/blackbox/testdata/changed-rule-inputs/changed-rule-inputs.qbs b/tests/auto/blackbox/testdata/changed-rule-inputs/changed-rule-inputs.qbs new file mode 100644 index 000000000..8aef7b9b6 --- /dev/null +++ b/tests/auto/blackbox/testdata/changed-rule-inputs/changed-rule-inputs.qbs @@ -0,0 +1,42 @@ +import qbs + +Project { + Product { + name: "p1" + type: "p1" + Rule { + alwaysRun: true + multiplex: true + Artifact { + fileTags: "p1" + filePath: "p1-dummy" + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "generating " + output.fileName; + cmd.sourceCode = function() {}; + return cmd; + } + } + } + Product { + name: "p2" + type: "p2" + Depends { name: "p1" } + Rule { + requiresInputs: false + multiplex: true + inputsFromDependencies: "p1" + Artifact { + fileTags: "p2" + filePath: "p2-dummy" + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "generating " + output.fileName; + cmd.sourceCode = function() {}; + return cmd; + } + } + } +} diff --git a/tests/auto/blackbox/testdata/exports-pkgconfig/TheFirstLib.pc b/tests/auto/blackbox/testdata/exports-pkgconfig/TheFirstLib.pc new file mode 100644 index 000000000..6a83a6b37 --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-pkgconfig/TheFirstLib.pc @@ -0,0 +1,10 @@ +prefix=/opt/the firstlib + +Name: TheFirstLib +Description: TheFirstLib +Version: 1.0 +URL: http://www.example.com/thefirstlib +Cflags: -DTheFirstLib -I"${prefix}/include" -pthread -DHAVE_INDUSTRIAL_STRENGTH_HAIR_DRYER -I/otherdir/include1 -I/otherdir/include2 +Libs: -L"${prefix}/lib" -lTheFirstLib -pthread +Requires: Qt5Core +Requires.private: SomeHelper diff --git a/tests/auto/blackbox/testdata/exports-pkgconfig/TheFirstLib_windows.pc b/tests/auto/blackbox/testdata/exports-pkgconfig/TheFirstLib_windows.pc new file mode 100644 index 000000000..3c730a0ad --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-pkgconfig/TheFirstLib_windows.pc @@ -0,0 +1,10 @@ +prefix=/opt/the firstlib + +Name: TheFirstLib +Description: TheFirstLib +Version: 1.0 +URL: http://www.example.com/thefirstlib +Cflags: -DTheFirstLib -I"${prefix}/include" -DHAVE_INDUSTRIAL_STRENGTH_HAIR_DRYER -I/otherdir/include1 -I/otherdir/include2 +Libs: -L"${prefix}/lib" -lTheFirstLib +Requires: Qt5Core +Requires.private: SomeHelper diff --git a/tests/auto/blackbox/testdata/exports-pkgconfig/TheSecondLib.pc b/tests/auto/blackbox/testdata/exports-pkgconfig/TheSecondLib.pc new file mode 100644 index 000000000..6c54b451e --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-pkgconfig/TheSecondLib.pc @@ -0,0 +1,9 @@ +config1=a b +config2=c + +Name: TheSecondLib +Description: The second lib +Version: 2.0 +Cflags: -I/opt/thesecondlib/include +Libs: -L/opt/thesecondlib/lib -lTheSecondLib +Requires: TheFirstLib diff --git a/tests/auto/blackbox/testdata/exports-pkgconfig/boringstaticlib.cpp b/tests/auto/blackbox/testdata/exports-pkgconfig/boringstaticlib.cpp new file mode 100644 index 000000000..559a0ecfa --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-pkgconfig/boringstaticlib.cpp @@ -0,0 +1 @@ +int calculateLuckyNumber() { return 12 * 13; } diff --git a/tests/auto/blackbox/testdata/exports-pkgconfig/exports-pkgconfig.qbs b/tests/auto/blackbox/testdata/exports-pkgconfig/exports-pkgconfig.qbs new file mode 100644 index 000000000..674f78c94 --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-pkgconfig/exports-pkgconfig.qbs @@ -0,0 +1,124 @@ +import qbs +import qbs.FileInfo + +Project { + Product { + name: "dummy" + Export { Depends { name: "TheFirstLib" } } + } + + Product { + name: "SomeHelper" + Depends { name: "Exporter.pkgconfig" } + Exporter.pkgconfig.versionEntry: "1.0" + } + StaticLibrary { + Depends { name: "cpp" } + name: "BoringStaticLib" + files: ["boringstaticlib.cpp"] + Export { + Depends { name: "cpp" } + cpp.defines: ["HAVE_INDUSTRIAL_STRENGTH_HAIR_DRYER"] + } + } + DynamicLibrary { + name: "TheFirstLib" + version: "1.0" + + Depends { name: "SomeHelper" } + Depends { name: "Exporter.pkgconfig" } + Exporter.pkgconfig.excludedDependencies: ["Qt.core", "helper3"] + Exporter.pkgconfig.requiresEntry: "Qt5Core" + Exporter.pkgconfig.urlEntry: "http://www.example.com/thefirstlib" + + Depends { name: "cpp" } + cpp.defines: ["FIRSTLIB"] + + qbs.installPrefix: "/opt/the firstlib" + + Export { + prefixMapping: [{prefix: "/somedir", replacement: "/otherdir"}] + Depends { name: "BoringStaticLib" } + Depends { name: "cpp" } + 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 someOtherCondition: someCondition + Properties { + condition: !someOtherCondition + cpp.driverFlags: ["-pthread"] + } + cpp.defines: product.name + cpp.includePaths: [FileInfo.joinPaths(product.qbs.installPrefix, "include")] + Qt.core.mocName: "muck" + } + + Group { + fileTagsFilter: ["dynamiclibrary", "dynamiclibrary_import"] + qbs.install: true + qbs.installDir: "lib" + } + + Group { + name: "api_headers" + files: ["firstlib.h"] + qbs.install: true + qbs.installDir: "include" + } + + files: ["firstlib.cpp"] + } + DynamicLibrary { + name: "TheSecondLib" + version: "2.0" + + Depends { name: "Exporter.pkgconfig" } + Exporter.pkgconfig.descriptionEntry: "The second lib" + Exporter.pkgconfig.transformFunction: (function(product, moduleName, propertyName, value) { + if (moduleName === "cpp" && propertyName === "includePaths") + return value.filter(function(p) { return p !== product.sourceDirectory; }); + return value; + }) + Exporter.pkgconfig.customVariables: ({config1: "a b", config2: "c"}) + + Depends { name: "cpp" } + cpp.defines: ["SECONDLIB"] + + qbs.installPrefix: "" + + Depends { name: "TheFirstLib" } + + Export { + Depends { name: "TheFirstLib" } + Depends { name: "dummy" } + Depends { name: "cpp" } + cpp.includePaths: ["/opt/thesecondlib/include", product.sourceDirectory] + property string hurz: importingProduct.name + + Rule { + property int n: 5 + Artifact { + filePath: "dummy" + fileTags: ["d1", "d2"] + cpp.warningsAreErrors: true + } + } + } + + Group { + fileTagsFilter: ["dynamiclibrary", "dynamiclibrary_import"] + qbs.install: true + qbs.installDir: "/opt/thesecondlib/lib" + } + + Group { + name: "api_headers" + files: ["secondlib.h"] + qbs.install: true + qbs.installDir: "/opt/thesecondlib/include" + } + + files: ["secondlib.cpp"] + } +} diff --git a/tests/auto/blackbox/testdata/exports-pkgconfig/firstlib.cpp b/tests/auto/blackbox/testdata/exports-pkgconfig/firstlib.cpp new file mode 100644 index 000000000..ab48afc94 --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-pkgconfig/firstlib.cpp @@ -0,0 +1,3 @@ +#include "firstlib.h" + +void firstLib() { } diff --git a/tests/auto/blackbox/testdata/exports-pkgconfig/firstlib.h b/tests/auto/blackbox/testdata/exports-pkgconfig/firstlib.h new file mode 100644 index 000000000..1ccfb0868 --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-pkgconfig/firstlib.h @@ -0,0 +1,9 @@ +#include "../dllexport.h" + +#ifdef FIRSTLIB +# define FIRSTLIB_EXPORT DLL_EXPORT +#else +# define FIRSTLIB_EXPORT DLL_IMPORT +#endif + +FIRSTLIB_EXPORT void firstLib(); diff --git a/tests/auto/blackbox/testdata/exports-pkgconfig/modules/helper1/helper1.qbs b/tests/auto/blackbox/testdata/exports-pkgconfig/modules/helper1/helper1.qbs new file mode 100644 index 000000000..b753ec295 --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-pkgconfig/modules/helper1/helper1.qbs @@ -0,0 +1,7 @@ +import qbs + +Module { + Depends { name: "cpp" } + Depends { name: "helper2" } + cpp.includePaths: "/somedir/include1" +} diff --git a/tests/auto/blackbox/testdata/exports-pkgconfig/modules/helper2/helper2.qbs b/tests/auto/blackbox/testdata/exports-pkgconfig/modules/helper2/helper2.qbs new file mode 100644 index 000000000..9d24a812d --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-pkgconfig/modules/helper2/helper2.qbs @@ -0,0 +1,6 @@ +import qbs + +Module { + Depends { name: "cpp" } + cpp.includePaths: "/somedir/include2" +} diff --git a/tests/auto/blackbox/testdata/exports-pkgconfig/modules/helper3/helper3.qbs b/tests/auto/blackbox/testdata/exports-pkgconfig/modules/helper3/helper3.qbs new file mode 100644 index 000000000..452191994 --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-pkgconfig/modules/helper3/helper3.qbs @@ -0,0 +1,6 @@ +import qbs + +Module { + Depends { name: "cpp" } + cpp.includePaths: "/somedir/include3" +} diff --git a/tests/auto/blackbox/testdata/exports-pkgconfig/secondlib.cpp b/tests/auto/blackbox/testdata/exports-pkgconfig/secondlib.cpp new file mode 100644 index 000000000..e1782f576 --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-pkgconfig/secondlib.cpp @@ -0,0 +1,7 @@ +#include "secondlib.h" + +#ifndef HAVE_INDUSTRIAL_STRENGTH_HAIR_DRYER +# error I CANT LIVE WITHOUT IT! +#endif + +void secondLib() { } diff --git a/tests/auto/blackbox/testdata/exports-pkgconfig/secondlib.h b/tests/auto/blackbox/testdata/exports-pkgconfig/secondlib.h new file mode 100644 index 000000000..78b52f7fe --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-pkgconfig/secondlib.h @@ -0,0 +1,9 @@ +#include "../dllexport.h" + +#ifdef SECONDLIB +# define SECONDLIB_EXPORT DLL_EXPORT +#else +# define SECONDLIB_EXPORT DLL_IMPORT +#endif + +SECONDLIB_EXPORT void secondLib(); diff --git a/tests/auto/blackbox/testdata/import-assignment/import-assignment.qbs b/tests/auto/blackbox/testdata/import-assignment/import-assignment.qbs new file mode 100644 index 000000000..2bff00f35 --- /dev/null +++ b/tests/auto/blackbox/testdata/import-assignment/import-assignment.qbs @@ -0,0 +1,23 @@ +import qbs +import MyImport + +Product { + type: "outtype" + property var importValue: MyImport + Rule { + multiplex: true + Artifact { + fileTags: "outtype" + filePath: "dummy" + } + prepare: { + var cmd = new JavaScriptCommand; + cmd.silent = true; + cmd.sourceCode = function() { + console.info("key 1 = " + product.importValue.key1); + console.info("key 2 = " + product.importValue.key2); + }; + return cmd; + } + } +} diff --git a/tests/auto/blackbox/testdata/import-assignment/imports/MyImport/myimport.js b/tests/auto/blackbox/testdata/import-assignment/imports/MyImport/myimport.js new file mode 100644 index 000000000..5befd5151 --- /dev/null +++ b/tests/auto/blackbox/testdata/import-assignment/imports/MyImport/myimport.js @@ -0,0 +1,2 @@ +var key1 = "value1"; +var key2 = "value2"; diff --git a/tests/auto/blackbox/testdata/probes-and-shadow-products/probes-and-shadow-products.qbs b/tests/auto/blackbox/testdata/probes-and-shadow-products/probes-and-shadow-products.qbs new file mode 100644 index 000000000..660c088a0 --- /dev/null +++ b/tests/auto/blackbox/testdata/probes-and-shadow-products/probes-and-shadow-products.qbs @@ -0,0 +1,13 @@ +import qbs + +Product { + name: "p" + multiplexByQbsProperties: "buildVariants" + qbs.buildVariants: ["debug", "release"] + Export { + Probe { + id: dummy + configure: { 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 049ade899..44d8013b9 100644 --- a/tests/auto/blackbox/testdata/smart-relinking/smart-relinking.qbs +++ b/tests/auto/blackbox/testdata/smart-relinking/smart-relinking.qbs @@ -25,6 +25,14 @@ Project { condition: tcProbe.found name:"app" Depends { name: "lib" } + Depends { name: "staticlib" } files: ["main.cpp"] } + StaticLibrary { + condition: tcProbe.found + name: "staticlib" + Depends { name: "lib" } + Depends { name: "cpp" } + files: "staticlib.cpp" + } } diff --git a/tests/auto/blackbox/testdata/smart-relinking/staticlib.cpp b/tests/auto/blackbox/testdata/smart-relinking/staticlib.cpp new file mode 100644 index 000000000..24fd8c6e9 --- /dev/null +++ b/tests/auto/blackbox/testdata/smart-relinking/staticlib.cpp @@ -0,0 +1 @@ +static void myFunc() {} diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 41ce32e40..9022bd975 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -716,6 +716,35 @@ void TestBlackbox::changedFiles() QVERIFY2(m_qbsStdout.contains("file1.cpp"), m_qbsStdout.constData()); } +void TestBlackbox::changedRuleInputs() +{ + QDir::setCurrent(testDataDir + "/changed-rule-inputs"); + + // Initial build. + QCOMPARE(runQbs(), 0); + QVERIFY2(m_qbsStdout.contains("generating p1-dummy"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("generating p2-dummy"), m_qbsStdout.constData()); + + // Re-build: p1 is always regenerated, and p2 has a dependency on it. + QCOMPARE(runQbs(), 0); + QVERIFY2(m_qbsStdout.contains("generating p1-dummy"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("generating p2-dummy"), m_qbsStdout.constData()); + + // Remove the dependency. p2 gets re-generated one last time, because its set of + // inputs changed. + WAIT_FOR_NEW_TIMESTAMP(); + REPLACE_IN_FILE("changed-rule-inputs.qbs", "inputsFromDependencies: \"p1\"", + "inputsFromDependencies: \"p3\""); + QCOMPARE(runQbs(), 0); + QVERIFY2(m_qbsStdout.contains("generating p1-dummy"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("generating p2-dummy"), m_qbsStdout.constData()); + + // Now the artifacts are no longer connected, and p2 must not get rebuilt anymore. + QCOMPARE(runQbs(), 0); + QVERIFY2(m_qbsStdout.contains("generating p1-dummy"), m_qbsStdout.constData()); + QVERIFY2(!m_qbsStdout.contains("generating p2-dummy"), m_qbsStdout.constData()); +} + void TestBlackbox::changeInDisabledProduct() { QDir::setCurrent(testDataDir + "/change-in-disabled-product"); @@ -2750,6 +2779,19 @@ void TestBlackbox::probeProperties() QVERIFY2(m_qbsStdout.contains("probe2.filePath=" + dir + "/bin/tool"), m_qbsStdout.constData()); } +void TestBlackbox::probesAndShadowProducts() +{ + QDir::setCurrent(testDataDir + "/probes-and-shadow-products"); + QCOMPARE(runQbs(QStringList("--log-time")), 0); + QVERIFY2(m_qbsStdout.contains("2 probes encountered, 1 configure scripts executed"), + m_qbsStdout.constData()); + WAIT_FOR_NEW_TIMESTAMP(); + touch("probes-and-shadow-products.qbs"); + QCOMPARE(runQbs(QStringList("--log-time")), 0); + QVERIFY2(m_qbsStdout.contains("2 probes encountered, 0 configure scripts executed"), + m_qbsStdout.constData()); +} + void TestBlackbox::probeInExportedModule() { QDir::setCurrent(testDataDir + "/probe-in-exported-module"); @@ -3330,6 +3372,22 @@ void TestBlackbox::exportToOutsideSearchPath() m_qbsStderr.constData()); } +void TestBlackbox::exportsPkgconfig() +{ + QDir::setCurrent(testDataDir + "/exports-pkgconfig"); + QCOMPARE(runQbs(), 0); + QFile sourcePcFile(HostOsInfo::isWindowsHost() ? "TheFirstLib_windows.pc" : "TheFirstLib.pc"); + QString generatedPcFilePath = relativeProductBuildDir("TheFirstLib") + "/TheFirstLib.pc"; + QFile generatedPcFile(generatedPcFilePath); + QVERIFY2(sourcePcFile.open(QIODevice::ReadOnly), qPrintable(sourcePcFile.errorString())); + QVERIFY2(generatedPcFile.open(QIODevice::ReadOnly), qPrintable(generatedPcFile.errorString())); + QCOMPARE(generatedPcFile.readAll().replace("\r", ""), sourcePcFile.readAll().replace("\r", "")); + sourcePcFile.close(); + generatedPcFile.close(); + TEXT_FILE_COMPARE(relativeProductBuildDir("TheSecondLib") + "/TheSecondLib.pc", + "TheSecondLib.pc"); +} + void TestBlackbox::exportsQbs() { QDir::setCurrent(testDataDir + "/exports-qbs"); @@ -6260,6 +6318,14 @@ void TestBlackbox::ico() } } +void TestBlackbox::importAssignment() +{ + QDir::setCurrent(testDataDir + "/import-assignment"); + QCOMPARE(runQbs(QStringList("project.qbsSearchPaths:" + QDir::currentPath())), 0); + QVERIFY2(m_qbsStdout.contains("key 1 = value1") && m_qbsStdout.contains("key 2 = value2"), + m_qbsStdout.constData()); +} + void TestBlackbox::importChangeTracking() { QDir::setCurrent(testDataDir + "/import-change-tracking"); diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index 3784a03b1..a2c021140 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -59,6 +59,7 @@ private slots: void buildGraphVersions(); void changedFiles_data(); void changedFiles(); + void changedRuleInputs(); void changeInDisabledProduct(); void changeInImportedFile(); void changeTrackingAndMultiplexing(); @@ -108,6 +109,7 @@ private slots: void exportedPropertyInDisabledProduct_data(); void exportRule(); void exportToOutsideSearchPath(); + void exportsPkgconfig(); void exportsQbs(); void externalLibs(); void fileDependencies(); @@ -117,6 +119,7 @@ private slots: void generator_data(); void groupsInModules(); void ico(); + void importAssignment(); void importChangeTracking(); void importInPropertiesCondition(); void importSearchPath(); @@ -198,6 +201,7 @@ private slots: void preventFloatingPointValues(); void probeChangeTracking(); void probeProperties(); + void probesAndShadowProducts(); void probeInExportedModule(); void probesAndArrayProperties(); void probesInNestedModules(); diff --git a/tests/auto/blackbox/tst_blackboxqt.cpp b/tests/auto/blackbox/tst_blackboxqt.cpp index 93eb68f80..03e52590b 100644 --- a/tests/auto/blackbox/tst_blackboxqt.cpp +++ b/tests/auto/blackbox/tst_blackboxqt.cpp @@ -77,7 +77,11 @@ void TestBlackboxQt::cachedQml() QDir::setCurrent(testDataDir + "/cached-qml"); QCOMPARE(runQbs(), 0); QString dataDir = relativeBuildDir() + "/install-root/data"; - if (QFile::exists(dataDir + "/main.cpp")) { + QVERIFY2(m_qbsStdout.contains("qmlcachegen must work: true") + || m_qbsStdout.contains("qmlcachegen must work: false"), + m_qbsStdout.constData()); + if (m_qbsStdout.contains("qmlcachegen must work: false") + && QFile::exists(dataDir + "/main.cpp")) { // If C++ source files were installed then Qt.qmlcache is not available. See project file. QSKIP("No QML cache files generated."); } |