diff options
author | Ivan Komissarov <ABBAPOH@gmail.com> | 2019-05-29 20:53:08 +0200 |
---|---|---|
committer | Ivan Komissarov <ABBAPOH@gmail.com> | 2019-06-25 17:01:11 +0000 |
commit | d214864b666d3551fe25a648b82832fcbd241b2e (patch) | |
tree | 855d473b8b8f8ccb5dbed42fed1410777ad6f5ad /tests | |
parent | 636ee64eea7461e09070b34ec80ee193dd46767f (diff) |
Allow PathProbe to search multiple files
Change-Id: I6ae2dd130cbafb03e51bc6e8e8a3e262d6d45fc6
Reviewed-by: Qbs CI Bot <travis-bot@weickelt.de>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'tests')
22 files changed, 190 insertions, 0 deletions
diff --git a/tests/auto/blackbox/testdata/path-probe/BaseApp.qbs b/tests/auto/blackbox/testdata/path-probe/BaseApp.qbs new file mode 100644 index 000000000..944a95a93 --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/BaseApp.qbs @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Ivan Komissarov (abbapoh@gmail.com). +** Contact: http://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. +** +****************************************************************************/ + +import qbs.Probes + +CppApplication { + + property varList inputSelectors + property varList inputNames + property varList inputNameSuffixes + property pathList inputSearchPaths + property var inputNameFilter + + property stringList outputFilePaths + + Probes.PathProbe { + id: probe + selectors: inputSelectors + names: inputNames + nameSuffixes: inputNameSuffixes + nameFilter: inputNameFilter + searchPaths: inputSearchPaths + } + + property bool validate: { + var compareArrays = function(lhs, rhs) { + if (lhs.length !== rhs.length) + return false; + for (var i = 0; i < lhs.length; ++i) { + if (lhs[i] !== rhs[i]) + return false; + } + return true; + }; + + if (!probe.found) + throw "Probe failed to find files"; + + if (outputFilePaths) { + var actual = probe.allResults.map(function(file) { return file.filePath; }); + if (!compareArrays(actual, outputFilePaths)) + throw "Invalid filePaths: actual = " + actual + ", expected = " + outputFilePaths; + } + } + + files: ["main.cpp"] +} diff --git a/tests/auto/blackbox/testdata/path-probe/bin/super-tool.1 b/tests/auto/blackbox/testdata/path-probe/bin/super-tool.1 new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/bin/super-tool.1 diff --git a/tests/auto/blackbox/testdata/path-probe/bin/tool b/tests/auto/blackbox/testdata/path-probe/bin/tool new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/bin/tool diff --git a/tests/auto/blackbox/testdata/path-probe/bin/tool.1 b/tests/auto/blackbox/testdata/path-probe/bin/tool.1 new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/bin/tool.1 diff --git a/tests/auto/blackbox/testdata/path-probe/bin/tool.2 b/tests/auto/blackbox/testdata/path-probe/bin/tool.2 new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/bin/tool.2 diff --git a/tests/auto/blackbox/testdata/path-probe/bin/tool.3 b/tests/auto/blackbox/testdata/path-probe/bin/tool.3 new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/bin/tool.3 diff --git a/tests/auto/blackbox/testdata/path-probe/bin/tool.4 b/tests/auto/blackbox/testdata/path-probe/bin/tool.4 new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/bin/tool.4 diff --git a/tests/auto/blackbox/testdata/path-probe/main.cpp b/tests/auto/blackbox/testdata/path-probe/main.cpp new file mode 100644 index 000000000..76e819701 --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/main.cpp @@ -0,0 +1 @@ +int main() { return 0; } diff --git a/tests/auto/blackbox/testdata/path-probe/mult-files-mult-suffixes.qbs b/tests/auto/blackbox/testdata/path-probe/mult-files-mult-suffixes.qbs new file mode 100644 index 000000000..b112db44d --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/mult-files-mult-suffixes.qbs @@ -0,0 +1,8 @@ +BaseApp { + inputSelectors: [ + {names : "tool", nameSuffixes: [".1", ".2"]}, + {names : "super-tool", nameSuffixes: [".1"]}, + ] + inputSearchPaths: "bin" + outputFilePaths: ["bin/tool.1", "bin/super-tool.1"] +} diff --git a/tests/auto/blackbox/testdata/path-probe/mult-files-mult-variants.qbs b/tests/auto/blackbox/testdata/path-probe/mult-files-mult-variants.qbs new file mode 100644 index 000000000..60c56e6b4 --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/mult-files-mult-variants.qbs @@ -0,0 +1,9 @@ +BaseApp { + inputSelectors: [ + "tool", + ["tool.1", "tool.2"], + {names : ["tool.3", "tool.4"]}, + ] + inputSearchPaths: "bin" + outputFilePaths: ["bin/tool", "bin/tool.1", "bin/tool.3"] +} diff --git a/tests/auto/blackbox/testdata/path-probe/mult-files-suffixes.qbs b/tests/auto/blackbox/testdata/path-probe/mult-files-suffixes.qbs new file mode 100644 index 000000000..5e4fc27ca --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/mult-files-suffixes.qbs @@ -0,0 +1,8 @@ +BaseApp { + inputSelectors: [ + {names : "tool", nameSuffixes: ".2"}, + {names : "super-tool", nameSuffixes: ".1"}, + ] + inputSearchPaths: "bin" + outputFilePaths: ["bin/tool.2", "bin/super-tool.1"] +} diff --git a/tests/auto/blackbox/testdata/path-probe/mult-files.qbs b/tests/auto/blackbox/testdata/path-probe/mult-files.qbs new file mode 100644 index 000000000..08727ac01 --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/mult-files.qbs @@ -0,0 +1,10 @@ +BaseApp { + inputSelectors: [ + "tool.1", + ["tool.2"], + {names : "tool.3"}, + {names : ["tool.4"]} + ] + inputSearchPaths: "bin" + outputFilePaths: ["bin/tool.1", "bin/tool.2", "bin/tool.3", "bin/tool.4"] +} diff --git a/tests/auto/blackbox/testdata/path-probe/name-filter.qbs b/tests/auto/blackbox/testdata/path-probe/name-filter.qbs new file mode 100644 index 000000000..406988fed --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/name-filter.qbs @@ -0,0 +1,10 @@ +BaseApp { + inputNames: "tool" + inputSearchPaths: "bin" + inputNameFilter: { + return function(n) { + return n + ".2" + }; + } + outputFilePaths: ["bin/tool.2"] +} diff --git a/tests/auto/blackbox/testdata/path-probe/non-existent-selector.qbs b/tests/auto/blackbox/testdata/path-probe/non-existent-selector.qbs new file mode 100644 index 000000000..aaa27042c --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/non-existent-selector.qbs @@ -0,0 +1,8 @@ +BaseApp { + inputSelectors: [ + "tool.1", + "nonexistent", + "tool.2", + ] + inputSearchPaths: "bin" +} diff --git a/tests/auto/blackbox/testdata/path-probe/non-existent.qbs b/tests/auto/blackbox/testdata/path-probe/non-existent.qbs new file mode 100644 index 000000000..f0c58fa6c --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/non-existent.qbs @@ -0,0 +1,4 @@ +BaseApp { + inputNames: "nonexistent" + inputSearchPaths: "bin" +} diff --git a/tests/auto/blackbox/testdata/path-probe/single-file-mult-variants.qbs b/tests/auto/blackbox/testdata/path-probe/single-file-mult-variants.qbs new file mode 100644 index 000000000..992a0bea4 --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/single-file-mult-variants.qbs @@ -0,0 +1,5 @@ +BaseApp { + inputNames: ["tool.1", "tool.2"] + inputSearchPaths: "bin" + outputFilePaths: ["bin/tool.1"] +} diff --git a/tests/auto/blackbox/testdata/path-probe/single-file-selector-array.qbs b/tests/auto/blackbox/testdata/path-probe/single-file-selector-array.qbs new file mode 100644 index 000000000..697665242 --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/single-file-selector-array.qbs @@ -0,0 +1,5 @@ +BaseApp { + inputSelectors: ["tool"] + inputSearchPaths: "bin" + outputFilePaths: ["bin/tool"] +} diff --git a/tests/auto/blackbox/testdata/path-probe/single-file-selector.qbs b/tests/auto/blackbox/testdata/path-probe/single-file-selector.qbs new file mode 100644 index 000000000..d57700baf --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/single-file-selector.qbs @@ -0,0 +1,5 @@ +BaseApp { + inputSelectors: "tool" + inputSearchPaths: "bin" + outputFilePaths: ["bin/tool"] +} diff --git a/tests/auto/blackbox/testdata/path-probe/single-file-suffixes.qbs b/tests/auto/blackbox/testdata/path-probe/single-file-suffixes.qbs new file mode 100644 index 000000000..4442e719a --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/single-file-suffixes.qbs @@ -0,0 +1,6 @@ +BaseApp { + inputNames: "tool" + inputSearchPaths: "bin" + inputNameSuffixes: [".1", ".2"] + outputFilePaths: ["bin/tool.1"] +} diff --git a/tests/auto/blackbox/testdata/path-probe/single-file.qbs b/tests/auto/blackbox/testdata/path-probe/single-file.qbs new file mode 100644 index 000000000..3590e7664 --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/single-file.qbs @@ -0,0 +1,5 @@ +BaseApp { + inputNames: "tool" + inputSearchPaths: "bin" + outputFilePaths: ["bin/tool"] +} diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 84322a7c7..c6acffcc9 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -2719,6 +2719,36 @@ void TestBlackbox::overrideProjectProperties() QCOMPARE(runQbs(params), 0); } +void TestBlackbox::pathProbe_data() +{ + QTest::addColumn<QString>("projectFile"); + QTest::addColumn<bool>("successExpected"); + QTest::newRow("non-existent") << QString("non-existent.qbs") << false; + QTest::newRow("non-existent-selector.qbs") << QString("non-existent-selector.qbs") << false; + QTest::newRow("single-file") << QString("single-file.qbs") << true; + QTest::newRow("single-file-selector") << QString("single-file-selector.qbs") << true; + QTest::newRow("single-file-selector-array") << QString("single-file-selector-array.qbs") << true; + QTest::newRow("single-file-mult-variants") << QString("single-file-mult-variants.qbs") << true; + QTest::newRow("mult-files") << QString("mult-files.qbs") << true; + QTest::newRow("mult-files-mult-variants") << QString("mult-files-mult-variants.qbs") << true; + QTest::newRow("single-file-suffixes") << QString("single-file-suffixes.qbs") << true; + QTest::newRow("mult-files-suffixes") << QString("mult-files-suffixes.qbs") << true; + QTest::newRow("mult-files-mult-suffixes") << QString("mult-files-mult-suffixes.qbs") << true; + QTest::newRow("name-filter") << QString("name-filter.qbs") << true; +} + +void TestBlackbox::pathProbe() +{ + QDir::setCurrent(testDataDir + "/path-probe"); + QFETCH(QString, projectFile); + QFETCH(bool, successExpected); + rmDirR(relativeBuildDir()); + + QbsRunParameters buildParams("build", QStringList{"-f", projectFile}); + buildParams.expectFailure = !successExpected; + QCOMPARE(runQbs(buildParams) == 0, successExpected); +} + void TestBlackbox::pchChangeTracking() { QDir::setCurrent(testDataDir + "/pch-change-tracking"); diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index 5b3adcbe2..e8c456b1e 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -205,6 +205,8 @@ private slots: void outOfDateMarking(); void outputArtifactAutoTagging(); void overrideProjectProperties(); + void pathProbe_data(); + void pathProbe(); void pchChangeTracking(); void perGroupDefineInExportItem(); void pkgConfigProbe(); |