diff options
author | Christian Kandeler <christian.kandeler@digia.com> | 2014-06-20 16:41:42 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@digia.com> | 2014-07-02 11:16:21 +0200 |
commit | e655304fed77ad45cb083a4f62ba308d734025a3 (patch) | |
tree | 0a94d7c7372d37d81e82d0bbcd68bfd765e35048 /tests/auto/blackbox | |
parent | 7c975c2fda2ef06af0532a73dc287657447e20d6 (diff) |
Do not lose rescuable artifact data after an incomplete build.
Task-number: QBS-630
Change-Id: Ib69c541a6c1e228b1ad3c06da51d905194ed10d8
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'tests/auto/blackbox')
5 files changed, 113 insertions, 0 deletions
diff --git a/tests/auto/blackbox/testdata/rad-after-incomplete-build/dummy.txt b/tests/auto/blackbox/testdata/rad-after-incomplete-build/dummy.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/auto/blackbox/testdata/rad-after-incomplete-build/dummy.txt diff --git a/tests/auto/blackbox/testdata/rad-after-incomplete-build/project_with_rule.qbs b/tests/auto/blackbox/testdata/rad-after-incomplete-build/project_with_rule.qbs new file mode 100644 index 000000000..8d36c6d11 --- /dev/null +++ b/tests/auto/blackbox/testdata/rad-after-incomplete-build/project_with_rule.qbs @@ -0,0 +1,26 @@ +import qbs +import qbs.TextFile + +Product { + type: "custom" + Group { + files: "dummy.txt" + fileTags: "input" + } + Rule { + inputs: "input" + Artifact { + fileTags: "custom" + fileName: "oldfile" + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "creating file"; + cmd.sourceCode = function() { + var f = new TextFile(output.filePath, TextFile.WriteOnly); + f.close(); + } + return cmd; + } + } +} diff --git a/tests/auto/blackbox/testdata/rad-after-incomplete-build/project_with_transformer.qbs b/tests/auto/blackbox/testdata/rad-after-incomplete-build/project_with_transformer.qbs new file mode 100644 index 000000000..a36bd108f --- /dev/null +++ b/tests/auto/blackbox/testdata/rad-after-incomplete-build/project_with_transformer.qbs @@ -0,0 +1,21 @@ +import qbs +import qbs.TextFile + +Product { + type: "custom" + Transformer { + Artifact { + fileTags: "custom" + fileName: "oldfile" + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "creating file"; + cmd.sourceCode = function() { + var f = new TextFile(output.filePath, TextFile.WriteOnly); + f.close(); + } + return cmd; + } + } +} diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index f6a8f0818..d879245b3 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -1828,6 +1828,70 @@ void TestBlackbox::propertiesBlocks() QCOMPARE(runQbs(), 0); } +void TestBlackbox::radAfterIncompleteBuild_data() +{ + QTest::addColumn<QString>("projectFileName"); + QTest::newRow("Project with Rule") << "project_with_rule.qbs"; + QTest::newRow("Project with Transformer") << "project_with_transformer.qbs"; +} + +void TestBlackbox::radAfterIncompleteBuild() +{ + QDir::setCurrent(testDataDir + "/rad-after-incomplete-build"); + rmDirR(buildDir); + QFETCH(QString, projectFileName); + + // Step 1: Have a directory where a file used to be. + QbsRunParameters params(QStringList() << "-f" << projectFileName); + QCOMPARE(runQbs(params), 0); + waitForNewTimestamp(); + QFile projectFile(projectFileName); + QVERIFY(projectFile.open(QIODevice::ReadWrite)); + QByteArray content = projectFile.readAll(); + content.replace("oldfile", "oldfile/newfile"); + projectFile.resize(0); + projectFile.write(content); + projectFile.flush(); + params.expectFailure = true; + QVERIFY(runQbs(params) != 0); + waitForNewTimestamp(); + content.replace("oldfile/newfile", "newfile"); + projectFile.resize(0); + projectFile.write(content); + projectFile.flush(); + params.expectFailure = false; + QCOMPARE(runQbs(params), 0); + waitForNewTimestamp(); + content.replace("newfile", "oldfile/newfile"); + projectFile.resize(0); + projectFile.write(content); + projectFile.flush(); + QCOMPARE(runQbs(params), 0); + + // Step 2: Have a file where a directory used to be. + waitForNewTimestamp(); + content.replace("oldfile/newfile", "oldfile"); + projectFile.resize(0); + projectFile.write(content); + projectFile.flush(); + params.expectFailure = true; + QVERIFY(runQbs(params) != 0); + waitForNewTimestamp(); + content.replace("oldfile", "newfile"); + projectFile.resize(0); + projectFile.write(content); + projectFile.flush(); + params.expectFailure = false; + QCOMPARE(runQbs(params), 0); + waitForNewTimestamp(); + content.replace("newfile", "oldfile"); + projectFile.resize(0); + projectFile.write(content); + projectFile.flush(); + QEXPECT_FAIL("", "QBS-630", Abort); + QCOMPARE(runQbs(params), 0); +} + void TestBlackbox::installedApp() { QDir::setCurrent(testDataDir + "/installed_artifact"); diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index 9b16e7e82..9be7bef22 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -132,6 +132,8 @@ private slots: void projectWithPropertiesItem(); void properQuoting(); void propertiesBlocks(); + void radAfterIncompleteBuild_data(); + void radAfterIncompleteBuild(); void resolve_project_data(); void resolve_project(); void resolve_project_dry_run_data(); |