diff options
author | Ivan Komissarov <abbapoh@gmail.com> | 2020-08-10 22:22:35 +0200 |
---|---|---|
committer | Ivan Komissarov <ABBAPOH@gmail.com> | 2020-08-13 17:59:29 +0000 |
commit | a15e25ac5d5888d9e2dde13df0b7b21a37ba4e56 (patch) | |
tree | c07f9c63e83e832fc536304bde5db98b36d7c21e /tests | |
parent | d03135c9509821270c541fe0725d7365c7a19d55 (diff) |
Tune search order of path probes
Within the groups of user-provided and system-provided paths,
environment variables need to take precedence over properties, because
there is currently no other way to override the search paths of probes
from the outside if the probe-using code did not explicitly bind them to
Product/Module properties.
We search directly user-provided paths before ones from system-provided
environment variables to minimize the risk of surprises due to outside
influence.
[ChangeLog][Behavior Changes] The lookup order in PathProbe changed to
[environmentPaths, searchPaths, platformEnvironmentPaths,
platformSearchPaths]
Change-Id: Ib0c3bc44e5a8efaaaa073f28f1f3a53feb0f78db
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'tests')
4 files changed, 14 insertions, 0 deletions
diff --git a/tests/auto/blackbox/testdata/path-probe/BaseApp.qbs b/tests/auto/blackbox/testdata/path-probe/BaseApp.qbs index 93172579f..2fe232baf 100644 --- a/tests/auto/blackbox/testdata/path-probe/BaseApp.qbs +++ b/tests/auto/blackbox/testdata/path-probe/BaseApp.qbs @@ -39,6 +39,7 @@ CppApplication { property pathList inputSearchPaths property var inputNameFilter property var inputCandidateFilter + property stringList inputEnvironmentPaths property stringList outputFilePaths property var outputCandidatePaths @@ -52,6 +53,7 @@ CppApplication { candidateFilter: inputCandidateFilter searchPaths: inputSearchPaths platformSearchPaths: [] + environmentPaths: inputEnvironmentPaths } property bool validate: { diff --git a/tests/auto/blackbox/testdata/path-probe/environment-paths.qbs b/tests/auto/blackbox/testdata/path-probe/environment-paths.qbs new file mode 100644 index 000000000..fca824bfb --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/environment-paths.qbs @@ -0,0 +1,10 @@ +import qbs.FileInfo + +BaseApp { + inputNames: "tool" + inputSearchPaths: ["bin", "usr/bin"] + // env takes precedence + inputEnvironmentPaths: "SEARCH_PATH" + outputFilePaths: ["usr/bin/tool"] + outputCandidatePaths: [["usr/bin/tool"]] +} diff --git a/tests/auto/blackbox/testdata/path-probe/usr/bin/tool b/tests/auto/blackbox/testdata/path-probe/usr/bin/tool new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/usr/bin/tool diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 366a618c0..ba07b632f 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -2961,6 +2961,7 @@ void TestBlackbox::pathProbe_data() QTest::newRow("mult-files-mult-suffixes") << QString("mult-files-mult-suffixes.qbs") << true; QTest::newRow("name-filter") << QString("name-filter.qbs") << true; QTest::newRow("candidate-filter") << QString("candidate-filter.qbs") << true; + QTest::newRow("environment-paths") << QString("environment-paths.qbs") << true; } void TestBlackbox::pathProbe() @@ -2972,6 +2973,7 @@ void TestBlackbox::pathProbe() QbsRunParameters buildParams("build", QStringList{"-f", projectFile}); buildParams.expectFailure = !successExpected; + buildParams.environment.insert("SEARCH_PATH", "usr/bin"); QCOMPARE(runQbs(buildParams) == 0, successExpected); if (!successExpected) QVERIFY2(m_qbsStderr.contains("Probe failed to find files"), m_qbsStderr); |