aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/corelib/buildgraph/processcommandexecutor.cpp10
-rw-r--r--tests/auto/blackbox/testdata/erroneous/nonexistentWorkingDir/project.qbs18
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp22
-rw-r--r--tests/auto/blackbox/tst_blackbox.h2
4 files changed, 52 insertions, 0 deletions
diff --git a/src/lib/corelib/buildgraph/processcommandexecutor.cpp b/src/lib/corelib/buildgraph/processcommandexecutor.cpp
index cb1d9604a..b267a51aa 100644
--- a/src/lib/corelib/buildgraph/processcommandexecutor.cpp
+++ b/src/lib/corelib/buildgraph/processcommandexecutor.cpp
@@ -116,6 +116,16 @@ void ProcessCommandExecutor::doStart()
return;
}
+ if (!cmd->workingDir().isEmpty()) {
+ FileInfo fi(cmd->workingDir());
+ if (!fi.exists() || !fi.isDir()) {
+ emit finished(ErrorInfo(Tr::tr("The working directory '%1' for process '%2' "
+ "is invalid.").arg(cmd->workingDir(), program),
+ cmd->codeLocation()));
+ return;
+ }
+ }
+
// Automatically use response files, if the command line gets to long.
if (!cmd->responseFileUsagePrefix().isEmpty()) {
const int commandLineLength = program.length() + argString.length();
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 eb3e01394..5ffb43961 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -1553,6 +1553,28 @@ void TestBlackbox::dynamicRuleOutputs()
QVERIFY(!QFile::exists(sourceFile2));
}
+void TestBlackbox::erroneousFiles_data()
+{
+ QTest::addColumn<QString>("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 844d01ff8..fc9ae76b5 100644
--- a/tests/auto/blackbox/tst_blackbox.h
+++ b/tests/auto/blackbox/tst_blackbox.h
@@ -114,6 +114,8 @@ private slots:
void duplicateProductNames_data();
void dynamicLibs();
void dynamicRuleOutputs();
+ void erroneousFiles_data();
+ void erroneousFiles();
void explicitlyDependsOn();
void fileDependencies();
void jsExtensionsFile();