From a52f265fcd70b51acc15b0fc5000014f1b1fed29 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 5 Jun 2014 11:20:20 +0200 Subject: yield error if Command.workingDirectory doesn't exist Otherwise some command might clutter the user's current working dir. Task-number: QBS-607 Change-Id: Id263481d1a615b9c66753e11b271441d4bd004b1 Reviewed-by: Christian Kandeler --- .../erroneous/nonexistentWorkingDir/project.qbs | 18 ++++++++++++++++++ tests/auto/blackbox/tst_blackbox.cpp | 22 ++++++++++++++++++++++ tests/auto/blackbox/tst_blackbox.h | 2 ++ 3 files changed, 42 insertions(+) create mode 100644 tests/auto/blackbox/testdata/erroneous/nonexistentWorkingDir/project.qbs (limited to 'tests/auto/blackbox') diff --git a/tests/auto/blackbox/testdata/erroneous/nonexistentWorkingDir/project.qbs b/tests/auto/blackbox/testdata/erroneous/nonexistentWorkingDir/project.qbs new file mode 100644 index 000000000..db0b0d607 --- /dev/null +++ b/tests/auto/blackbox/testdata/erroneous/nonexistentWorkingDir/project.qbs @@ -0,0 +1,18 @@ +import qbs + +Application { + name: "kaputt" + Transformer { + Artifact { + fileName: "Stulle" + fileTags: ["nutritious"] + } + prepare: { + var cmd = new Command("ls"); + cmd.workingDirectory = "/does/not/exist"; + cmd.silent = true; + return [cmd]; + } + } +} + diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index cc68a57d4..d185dbdde 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -1521,6 +1521,28 @@ void TestBlackbox::dynamicRuleOutputs() QVERIFY(!QFile::exists(sourceFile2)); } +void TestBlackbox::erroneousFiles_data() +{ + QTest::addColumn("errorMessage"); + QTest::newRow("nonexistentWorkingDir") + << "The working directory '/does/not/exist' for process 'ls' is invalid."; +} + +void TestBlackbox::erroneousFiles() +{ + QFETCH(QString, errorMessage); + QDir::setCurrent(testDataDir + "/erroneous/" + QTest::currentDataTag()); + QbsRunParameters params; + params.expectFailure = true; + QVERIFY(runQbs(params) != 0); + QString err = QString::fromLocal8Bit(m_qbsStderr); + if (!err.contains(errorMessage)) { + qDebug() << "Output: " << err; + qDebug() << "Expected: " << errorMessage; + QFAIL("Unexpected error message."); + } +} + void TestBlackbox::explicitlyDependsOn() { QDir::setCurrent(testDataDir + "/explicitlyDependsOn"); diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index 87008e266..7a52a9bd3 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -113,6 +113,8 @@ private slots: void duplicateProductNames_data(); void dynamicLibs(); void dynamicRuleOutputs(); + void erroneousFiles_data(); + void erroneousFiles(); void explicitlyDependsOn(); void fileDependencies(); void jsExtensionsFile(); -- cgit v1.2.3