summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2013-07-15 10:50:15 +0200
committerChristian Kandeler <christian.kandeler@digia.com>2013-07-16 10:17:51 +0200
commit7aff31171eb3e756fc6ac6ff4bb4db6dcc96e42a (patch)
tree28ab89b930aa173a9e88980095f25abc2348709f /tests
parente8899e40aa9c00329e59bfc784935bab16d0cafc (diff)
downloadqbs-7aff31171eb3e756fc6ac6ff4bb4db6dcc96e42a.tar.gz
Handle "indirect" changes to a product's file list.
If the list of source files in a product changed without the respective file having been touched (e.g. because the list was dependent on an environment variable), we re-resolved the product, but we did not touch the build data, so the new file was not compiled. Change-Id: Ib63020339aa0bbc2a858ed22f938ab76fb0611c5 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/blackbox/testdata/trackExternalProductChanges/environmentChange.cpp1
-rw-r--r--tests/auto/blackbox/testdata/trackExternalProductChanges/fileList.js1
-rw-r--r--tests/auto/blackbox/testdata/trackExternalProductChanges/jsFileChange.cpp1
-rw-r--r--tests/auto/blackbox/testdata/trackExternalProductChanges/main.cpp1
-rw-r--r--tests/auto/blackbox/testdata/trackExternalProductChanges/project.qbs6
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp35
-rw-r--r--tests/auto/blackbox/tst_blackbox.h1
7 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/blackbox/testdata/trackExternalProductChanges/environmentChange.cpp b/tests/auto/blackbox/testdata/trackExternalProductChanges/environmentChange.cpp
new file mode 100644
index 000000000..dd3c37880
--- /dev/null
+++ b/tests/auto/blackbox/testdata/trackExternalProductChanges/environmentChange.cpp
@@ -0,0 +1 @@
+void environmentChange() { }
diff --git a/tests/auto/blackbox/testdata/trackExternalProductChanges/fileList.js b/tests/auto/blackbox/testdata/trackExternalProductChanges/fileList.js
new file mode 100644
index 000000000..0d540d82e
--- /dev/null
+++ b/tests/auto/blackbox/testdata/trackExternalProductChanges/fileList.js
@@ -0,0 +1 @@
+function fileList() { return []; }
diff --git a/tests/auto/blackbox/testdata/trackExternalProductChanges/jsFileChange.cpp b/tests/auto/blackbox/testdata/trackExternalProductChanges/jsFileChange.cpp
new file mode 100644
index 000000000..a23a409ae
--- /dev/null
+++ b/tests/auto/blackbox/testdata/trackExternalProductChanges/jsFileChange.cpp
@@ -0,0 +1 @@
+void jsFileChange() { }
diff --git a/tests/auto/blackbox/testdata/trackExternalProductChanges/main.cpp b/tests/auto/blackbox/testdata/trackExternalProductChanges/main.cpp
new file mode 100644
index 000000000..8b8d58de0
--- /dev/null
+++ b/tests/auto/blackbox/testdata/trackExternalProductChanges/main.cpp
@@ -0,0 +1 @@
+int main() { }
diff --git a/tests/auto/blackbox/testdata/trackExternalProductChanges/project.qbs b/tests/auto/blackbox/testdata/trackExternalProductChanges/project.qbs
new file mode 100644
index 000000000..cfd897447
--- /dev/null
+++ b/tests/auto/blackbox/testdata/trackExternalProductChanges/project.qbs
@@ -0,0 +1,6 @@
+import qbs
+import "fileList.js" as FileList
+
+CppApplication {
+ files: ["main.cpp"].concat(FileList.fileList()).concat(qbs.getenv("QBS_TEST_PULL_IN_FILE_VIA_ENV") ? ["environmentChange.cpp"] : [])
+}
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index dd9719b09..8d2f6dbdb 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -589,6 +589,41 @@ void TestBlackbox::trackAddFile()
QCOMPARE(unchangedObjectFileTime1, unchangedObjectFileTime2);
}
+void TestBlackbox::trackExternalProductChanges()
+{
+ QDir::setCurrent(testDataDir + "/trackExternalProductChanges");
+ QCOMPARE(runQbs(), 0);
+ QVERIFY(m_qbsStdout.contains("compiling main.cpp"));
+ QVERIFY(!m_qbsStdout.contains("compiling environmentChange.cpp"));
+ QVERIFY(!m_qbsStdout.contains("compiling jsFileChange.cpp"));
+
+ QbsRunParameters params;
+ params.environment.insert("QBS_TEST_PULL_IN_FILE_VIA_ENV", "1");
+ QCOMPARE(runQbs(params), 0);
+ QVERIFY(!m_qbsStdout.contains("compiling main.cpp"));
+ QVERIFY(m_qbsStdout.contains("compiling environmentChange.cpp"));
+ QVERIFY(!m_qbsStdout.contains("compiling jsFileChange.cpp"));
+
+ rmDirR(buildDir);
+ QCOMPARE(runQbs(), 0);
+ QVERIFY(m_qbsStdout.contains("compiling main.cpp"));
+ QVERIFY(!m_qbsStdout.contains("compiling environmentChange.cpp"));
+ QVERIFY(!m_qbsStdout.contains("compiling jsFileChange.cpp"));
+
+ waitForNewTimestamp();
+ QFile jsFile("fileList.js");
+ QVERIFY(jsFile.open(QIODevice::ReadWrite));
+ QByteArray jsCode = jsFile.readAll();
+ jsCode.replace("[]", "['jsFileChange.cpp']");
+ jsFile.resize(0);
+ jsFile.write(jsCode);
+ jsFile.close();
+ QCOMPARE(runQbs(), 0);
+ QVERIFY(!m_qbsStdout.contains("compiling main.cpp"));
+ QVERIFY(!m_qbsStdout.contains("compiling environmentChange.cpp"));
+ QVERIFY(m_qbsStdout.contains("compiling jsFileChange.cpp"));
+}
+
void TestBlackbox::trackRemoveFile()
{
QProcess process;
diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h
index b9d19da96..153e0aae6 100644
--- a/tests/auto/blackbox/tst_blackbox.h
+++ b/tests/auto/blackbox/tst_blackbox.h
@@ -111,6 +111,7 @@ private slots:
void track_qrc();
void track_qobject_change();
void trackAddFile();
+ void trackExternalProductChanges();
void trackRemoveFile();
void trackAddFileTag();
void trackRemoveFileTag();