aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2018-04-26 17:16:15 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2018-06-04 07:56:53 +0000
commit400d9e1d66aacb2760b2190a5f10cfc3d5d359d2 (patch)
tree0c7ac294927572b38b268c3fe7d560dc652efa46
parent7a46541d7885b07cb80fab3b8ab861ae369e4438 (diff)
Make sure probe results are also cached for shadow products
Because we don't turn shadow products into actual products in the ProjectResolver, the results of probes run in their context did not end up in the build graph and the configure scripts were therefore needlessly re-executed on the next project resolving. Fix this by storing these probe results along with the project-level ones. Change-Id: I647bbedbbe3fa6f36b536fd1b80fd321894362f8 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r--src/lib/corelib/language/moduleloader.cpp5
-rw-r--r--tests/auto/blackbox/testdata/probes-and-shadow-products/probes-and-shadow-products.qbs13
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp13
-rw-r--r--tests/auto/blackbox/tst_blackbox.h1
4 files changed, 31 insertions, 1 deletions
diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp
index 933c49abc..df47e36ea 100644
--- a/src/lib/corelib/language/moduleloader.cpp
+++ b/src/lib/corelib/language/moduleloader.cpp
@@ -581,6 +581,8 @@ void ModuleLoader::handleTopLevelProject(ModuleLoaderResult *loadResult, Item *p
for (ProductContext * const p : productSorter.sortedProducts()) {
try {
handleProduct(p);
+ if (p->name.startsWith(shadowProductPrefix()))
+ tlp.probes << p->info.probes;
} catch (const ErrorInfo &err) {
handleProductError(err, p);
}
@@ -3418,7 +3420,8 @@ void ModuleLoader::resolveProbe(ProductContext *productContext, Item *parent, It
const bool condition = m_evaluator->boolValue(probe, StringConstants::conditionProperty());
const QString &sourceCode = configureScript->sourceCode().toString();
ProbeConstPtr resolvedProbe;
- if (parent->type() == ItemType::Project) {
+ if (parent->type() == ItemType::Project
+ || productContext->name.startsWith(shadowProductPrefix())) {
resolvedProbe = findOldProjectProbe(probeId, condition, initialProperties, sourceCode);
} else {
const QString &uniqueProductName = productContext->uniqueName();
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/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index 844b421c4..4f59eeeed 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -2741,6 +2741,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");
diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h
index 6562e8cbc..44c2e9ca0 100644
--- a/tests/auto/blackbox/tst_blackbox.h
+++ b/tests/auto/blackbox/tst_blackbox.h
@@ -193,6 +193,7 @@ private slots:
void preventFloatingPointValues();
void probeChangeTracking();
void probeProperties();
+ void probesAndShadowProducts();
void probeInExportedModule();
void probesAndArrayProperties();
void probesInNestedModules();