aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/api/testdata/infinite-loop-process/infinite-loop.qbs9
-rw-r--r--tests/auto/api/testdata/link-staticlibs-dynamiclibs/link-staticlibs-dynamiclibs.qbs7
-rw-r--r--tests/auto/api/testdata/timeout-js/timeout.qbs20
-rw-r--r--tests/auto/api/testdata/timeout-process/main.cpp37
-rw-r--r--tests/auto/api/testdata/timeout-process/timeout.qbs34
-rw-r--r--tests/auto/api/tst_api.cpp54
-rw-r--r--tests/auto/api/tst_api.h3
-rw-r--r--tests/auto/blackbox/testdata-joblimits/job-limits/job-limits.qbs2
-rw-r--r--tests/auto/blackbox/testdata-joblimits/job-limits/main.cpp2
-rw-r--r--tests/auto/blackbox/testdata/autotest-timeout/autotests-timeout.qbs20
-rw-r--r--tests/auto/blackbox/testdata/autotest-timeout/test-main.cpp37
-rw-r--r--tests/auto/blackbox/testdata/autotest-with-dependencies/autotest-with-dependencies.qbs4
-rw-r--r--tests/auto/blackbox/testdata/autotests/autotests.qbs7
-rw-r--r--tests/auto/blackbox/testdata/lexyacc/one-grammar/one-grammar.qbs17
-rw-r--r--tests/auto/blackbox/testdata/separate-debug-info/separate-debug-info.qbs9
-rw-r--r--tests/auto/blackbox/testdata/setup-run-environment/setup-run-environment.qbs15
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp53
-rw-r--r--tests/auto/blackbox/tst_blackbox.h3
-rw-r--r--tests/auto/blackbox/tst_blackboxjoblimits.cpp2
19 files changed, 318 insertions, 17 deletions
diff --git a/tests/auto/api/testdata/infinite-loop-process/infinite-loop.qbs b/tests/auto/api/testdata/infinite-loop-process/infinite-loop.qbs
index f0de12df1..f4ea8bf83 100644
--- a/tests/auto/api/testdata/infinite-loop-process/infinite-loop.qbs
+++ b/tests/auto/api/testdata/infinite-loop-process/infinite-loop.qbs
@@ -4,12 +4,21 @@ Project {
consoleApplication: true // suppress bundle generation
files: "main.cpp"
name: "infinite-loop"
+ cpp.cxxLanguageVersion: "c++11"
+ Properties {
+ condition: qbs.toolchain.contains("gcc")
+ cpp.driverFlags: "-pthread"
+ }
}
Product {
type: "mytype"
name: "caller"
Depends { name: "infinite-loop" }
+ Depends {
+ name: "cpp" // Make sure build environment is set up properly.
+ condition: qbs.hostOS.contains("windows") && qbs.toolchain.contains("gcc")
+ }
Rule {
inputsFromDependencies: "application"
outputFileTags: "mytype"
diff --git a/tests/auto/api/testdata/link-staticlibs-dynamiclibs/link-staticlibs-dynamiclibs.qbs b/tests/auto/api/testdata/link-staticlibs-dynamiclibs/link-staticlibs-dynamiclibs.qbs
index eade97126..d7ed6c862 100644
--- a/tests/auto/api/testdata/link-staticlibs-dynamiclibs/link-staticlibs-dynamiclibs.qbs
+++ b/tests/auto/api/testdata/link-staticlibs-dynamiclibs/link-staticlibs-dynamiclibs.qbs
@@ -11,6 +11,13 @@ Project {
files: [ "static1.cpp" ]
Depends { name: "cpp" }
Depends { name: "dynamic1" }
+
+ Probe {
+ id: osCheck
+ property bool isNormalUnix: qbs.targetOS.contains("unix")
+ && !qbs.targetOS.contains("darwin")
+ configure: { console.info("is normal unix: " + (isNormalUnix ? "yes" : "no")); }
+ }
}
DynamicLibrary {
diff --git a/tests/auto/api/testdata/timeout-js/timeout.qbs b/tests/auto/api/testdata/timeout-js/timeout.qbs
new file mode 100644
index 000000000..26aa4ce87
--- /dev/null
+++ b/tests/auto/api/testdata/timeout-js/timeout.qbs
@@ -0,0 +1,20 @@
+Product {
+ type: "product-under-test"
+ Rule {
+ multiplex: true
+ Artifact {
+ filePath: "output.txt"
+ fileTags: "product-under-test"
+ }
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.description = "Running infinite loop";
+ cmd.sourceCode = function() {
+ while (true)
+ ;
+ }
+ cmd.timeout = 3;
+ return cmd;
+ }
+ }
+}
diff --git a/tests/auto/api/testdata/timeout-process/main.cpp b/tests/auto/api/testdata/timeout-process/main.cpp
new file mode 100644
index 000000000..f9b9336ba
--- /dev/null
+++ b/tests/auto/api/testdata/timeout-process/main.cpp
@@ -0,0 +1,37 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Jochen Ulrich <jochenulrich@t-online.de>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qbs.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <chrono>
+#include <thread>
+
+int main()
+{
+ std::this_thread::sleep_for(std::chrono::seconds(700));
+ return 0;
+}
+
diff --git a/tests/auto/api/testdata/timeout-process/timeout.qbs b/tests/auto/api/testdata/timeout-process/timeout.qbs
new file mode 100644
index 000000000..bb8deac9b
--- /dev/null
+++ b/tests/auto/api/testdata/timeout-process/timeout.qbs
@@ -0,0 +1,34 @@
+Project {
+ CppApplication {
+ type: "application"
+ consoleApplication: true // suppress bundle generation
+ files: "main.cpp"
+ name: "infinite-loop"
+ cpp.cxxLanguageVersion: "c++11"
+ cpp.minimumOsxVersion: "10.8" // For <chrono>
+ Properties {
+ condition: qbs.toolchain.contains("gcc")
+ cpp.driverFlags: "-pthread"
+ }
+ }
+
+ Product {
+ type: "product-under-test"
+ name: "caller"
+ Depends { name: "infinite-loop" }
+ Depends {
+ name: "cpp" // Make sure build environment is set up properly.
+ condition: qbs.hostOS.contains("windows") && qbs.toolchain.contains("gcc")
+ }
+ Rule {
+ inputsFromDependencies: "application"
+ outputFileTags: "product-under-test"
+ prepare: {
+ var cmd = new Command(inputs["application"][0].filePath);
+ cmd.description = "Calling application that runs forever";
+ cmd.timeout = 3;
+ return cmd;
+ }
+ }
+ }
+}
diff --git a/tests/auto/api/tst_api.cpp b/tests/auto/api/tst_api.cpp
index aac0f3e7e..36a98fdaa 100644
--- a/tests/auto/api/tst_api.cpp
+++ b/tests/auto/api/tst_api.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 Jochen Ulrich <jochenulrich@t-online.de>
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qbs.
@@ -1555,9 +1556,13 @@ void TestApi::linkStaticAndDynamicLibs()
BuildDescriptionReceiver bdr;
qbs::BuildOptions options;
options.setEchoMode(qbs::CommandEchoModeCommandLine);
+ m_logSink->output.clear();
const qbs::ErrorInfo errorInfo = doBuildProject("link-staticlibs-dynamiclibs", &bdr, nullptr,
nullptr, options);
VERIFY_NO_ERROR(errorInfo);
+ const bool isNormalUnix = m_logSink->output.contains("is normal unix: yes");
+ const bool isNotNormalUnix = m_logSink->output.contains("is normal unix: no");
+ QVERIFY2(isNormalUnix != isNotNormalUnix, qPrintable(m_logSink->output));
// The dependencies libdynamic1.so and libstatic2.a must not appear in the link command for the
// executable. The -rpath-link line for libdynamic1.so must be there.
@@ -1574,12 +1579,7 @@ void TestApi::linkStaticAndDynamicLibs()
}
}
QVERIFY(!appLinkCmd.isEmpty());
- std::string targetPlatform = buildProfile.value("qbs.targetPlatform")
- .toString().toStdString();
- std::vector<std::string> targetOS = qbs::Internal::HostOsInfo::canonicalOSIdentifiers(
- targetPlatform);
- if (!qbs::Internal::contains(targetOS, "darwin")
- && !qbs::Internal::contains(targetOS, "windows")) {
+ if (isNormalUnix) {
const std::regex rpathLinkRex("-rpath-link=\\S*/"
+ relativeProductBuildDir("dynamic2").toStdString());
const auto ln = appLinkCmd.toStdString();
@@ -2829,6 +2829,48 @@ void TestApi::targetArtifactStatus()
QCOMPARE(product.targetArtifacts().size(), enableTagging ? 2 : 1);
}
+void TestApi::timeout()
+{
+ QFETCH(QString, projectDirName);
+ const auto setupParams = defaultSetupParameters(projectDirName + "/timeout.qbs");
+ std::unique_ptr<qbs::SetupProjectJob> setupJob{
+ qbs::Project().setupProject(setupParams, m_logSink, nullptr)};
+ waitForFinished(setupJob.get());
+ QVERIFY2(!setupJob->error().hasError(), qPrintable(setupJob->error().toString()));
+ auto project = setupJob->project();
+ const auto products = project.projectData().products();
+ QList<qbs::ProductData> helperProducts;
+ qbs::ProductData productUnderTest;
+ for (const auto &product : products) {
+ if (!product.type().contains(QLatin1String("product-under-test")))
+ helperProducts.append(product);
+ else
+ productUnderTest = product;
+ }
+ const std::unique_ptr<qbs::BuildJob> buildHelpersJob{
+ project.buildSomeProducts(helperProducts, qbs::BuildOptions())};
+ QVERIFY(waitForFinished(buildHelpersJob.get(), testTimeoutInMsecs()));
+ if (buildHelpersJob->error().hasError()) {
+ qDebug().noquote() << buildHelpersJob->error().toString();
+ QFAIL("Could not build helper products");
+ }
+
+ const std::unique_ptr<qbs::BuildJob> buildJob(project.buildOneProduct(productUnderTest,
+ qbs::BuildOptions()));
+ QVERIFY(waitForFinished(buildJob.get(), testTimeoutInMsecs()));
+ QVERIFY(buildJob->error().hasError());
+ const auto errorString = buildJob->error().toString();
+ QVERIFY2(errorString.contains("cancel"), qPrintable(errorString));
+ QVERIFY(errorString.contains("timeout"));
+}
+
+void TestApi::timeout_data()
+{
+ QTest::addColumn<QString>("projectDirName");
+ QTest::newRow("JS Command") << QString("timeout-js");
+ QTest::newRow("Process Command") << QString("timeout-process");
+}
+
void TestApi::toolInModule()
{
QVariantMap overrides({std::make_pair("qbs.installRoot", m_workingDataDir
diff --git a/tests/auto/api/tst_api.h b/tests/auto/api/tst_api.h
index c04e9feb0..ce1678133 100644
--- a/tests/auto/api/tst_api.h
+++ b/tests/auto/api/tst_api.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 Jochen Ulrich <jochenulrich@t-online.de>
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qbs.
@@ -142,6 +143,8 @@ private slots:
void subProjects();
void targetArtifactStatus_data();
void targetArtifactStatus();
+ void timeout();
+ void timeout_data();
void toolInModule();
void trackAddQObjectHeader();
void trackRemoveQObjectHeader();
diff --git a/tests/auto/blackbox/testdata-joblimits/job-limits/job-limits.qbs b/tests/auto/blackbox/testdata-joblimits/job-limits/job-limits.qbs
index 1ab369c88..221105a64 100644
--- a/tests/auto/blackbox/testdata-joblimits/job-limits/job-limits.qbs
+++ b/tests/auto/blackbox/testdata-joblimits/job-limits/job-limits.qbs
@@ -63,7 +63,7 @@ Project {
outputFileTags: "tool_in"
outputArtifacts: {
var artifacts = [];
- for (var i = 0; i < 7; ++i)
+ for (var i = 0; i < 5; ++i)
artifacts.push({filePath: "file" + i + ".in", fileTags: "tool_in"});
return artifacts;
}
diff --git a/tests/auto/blackbox/testdata-joblimits/job-limits/main.cpp b/tests/auto/blackbox/testdata-joblimits/job-limits/main.cpp
index 0a94c6393..ec9acba80 100644
--- a/tests/auto/blackbox/testdata-joblimits/job-limits/main.cpp
+++ b/tests/auto/blackbox/testdata-joblimits/job-limits/main.cpp
@@ -76,7 +76,7 @@ int main(int argc, char *argv[])
return 4;
}
}
- std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ std::this_thread::sleep_for(std::chrono::milliseconds(50));
fclose(lockFile);
std::FILE * const output = std::fopen(argv[1], "w");
if (!output) {
diff --git a/tests/auto/blackbox/testdata/autotest-timeout/autotests-timeout.qbs b/tests/auto/blackbox/testdata/autotest-timeout/autotests-timeout.qbs
new file mode 100644
index 000000000..49ee35d3a
--- /dev/null
+++ b/tests/auto/blackbox/testdata/autotest-timeout/autotests-timeout.qbs
@@ -0,0 +1,20 @@
+Project {
+ CppApplication {
+ name: "testApp"
+ type: ["application", "autotest"]
+ Depends { name: "autotest" }
+ cpp.cxxLanguageVersion: "c++11"
+ cpp.minimumOsxVersion: "10.8" // For <chrono>
+ Properties {
+ condition: qbs.toolchain.contains("gcc")
+ cpp.driverFlags: "-pthread"
+ }
+ files: "test-main.cpp"
+ }
+ AutotestRunner {
+ Depends {
+ name: "cpp" // Make sure build environment is set up properly.
+ condition: qbs.hostOS.contains("windows") && qbs.toolchain.contains("gcc")
+ }
+ }
+}
diff --git a/tests/auto/blackbox/testdata/autotest-timeout/test-main.cpp b/tests/auto/blackbox/testdata/autotest-timeout/test-main.cpp
new file mode 100644
index 000000000..4bb1ca27c
--- /dev/null
+++ b/tests/auto/blackbox/testdata/autotest-timeout/test-main.cpp
@@ -0,0 +1,37 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Jochen Ulrich <jochenulrich@t-online.de>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qbs.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <chrono>
+#include <thread>
+
+int main()
+{
+ std::this_thread::sleep_for(std::chrono::seconds(5));
+ return 0;
+}
+
diff --git a/tests/auto/blackbox/testdata/autotest-with-dependencies/autotest-with-dependencies.qbs b/tests/auto/blackbox/testdata/autotest-with-dependencies/autotest-with-dependencies.qbs
index 92d5ec6dd..7ae6cef73 100644
--- a/tests/auto/blackbox/testdata/autotest-with-dependencies/autotest-with-dependencies.qbs
+++ b/tests/auto/blackbox/testdata/autotest-with-dependencies/autotest-with-dependencies.qbs
@@ -21,6 +21,10 @@ Project {
}
AutotestRunner {
+ Depends {
+ name: "cpp" // Make sure build environment is set up properly.
+ condition: qbs.hostOS.contains("windows") && qbs.toolchain.contains("gcc")
+ }
arguments: FileInfo.joinPaths(qbs.installRoot, qbs.installPrefix, "bin")
auxiliaryInputs: "test-helper"
}
diff --git a/tests/auto/blackbox/testdata/autotests/autotests.qbs b/tests/auto/blackbox/testdata/autotests/autotests.qbs
index a2c2646dc..10334156e 100644
--- a/tests/auto/blackbox/testdata/autotests/autotests.qbs
+++ b/tests/auto/blackbox/testdata/autotests/autotests.qbs
@@ -1,4 +1,9 @@
Project {
references: ["test1", "test2", "test3"]
- AutotestRunner {}
+ AutotestRunner {
+ Depends {
+ name: "cpp" // Make sure build environment is set up properly.
+ condition: qbs.hostOS.contains("windows") && qbs.toolchain.contains("gcc")
+ }
+ }
}
diff --git a/tests/auto/blackbox/testdata/lexyacc/one-grammar/one-grammar.qbs b/tests/auto/blackbox/testdata/lexyacc/one-grammar/one-grammar.qbs
index 61f76f4be..6cd334247 100644
--- a/tests/auto/blackbox/testdata/lexyacc/one-grammar/one-grammar.qbs
+++ b/tests/auto/blackbox/testdata/lexyacc/one-grammar/one-grammar.qbs
@@ -8,6 +8,23 @@ CppApplication {
cpp.cxxLanguageVersion: "c++11"
cpp.minimumMacosVersion: "10.7"
consoleApplication: true
+ Probe {
+ id: pathCheck
+ property string theDir: {
+ if (qbs.targetOS.contains("windows")) {
+ if (qbs.toolchain.contains("mingw"))
+ return cpp.toolchainInstallPath;
+ if (qbs.toolchain.contains("clang") && qbs.sysroot)
+ return qbs.sysroot + "/bin";
+ }
+ }
+ configure: {
+ if (theDir)
+ console.info("add to PATH: " + theDir);
+ found = true;
+ }
+ }
+
files: [
"lexer.l",
"parser.y",
diff --git a/tests/auto/blackbox/testdata/separate-debug-info/separate-debug-info.qbs b/tests/auto/blackbox/testdata/separate-debug-info/separate-debug-info.qbs
index 48bdff904..0b16d1984 100644
--- a/tests/auto/blackbox/testdata/separate-debug-info/separate-debug-info.qbs
+++ b/tests/auto/blackbox/testdata/separate-debug-info/separate-debug-info.qbs
@@ -4,6 +4,15 @@ Project {
type: ["application"]
files: ["main.cpp"]
cpp.separateDebugInformation: true
+
+ Probe {
+ id: osProbe
+ property stringList targetOS: qbs.targetOS
+ configure: {
+ console.info("is windows: " + (targetOS.contains("windows") ? "yes" : "no"));
+ console.info("is darwin: " + (targetOS.contains("darwin") ? "yes" : "no"));
+ }
+ }
}
DynamicLibrary {
Depends { name: "cpp" }
diff --git a/tests/auto/blackbox/testdata/setup-run-environment/setup-run-environment.qbs b/tests/auto/blackbox/testdata/setup-run-environment/setup-run-environment.qbs
index b5ac8b289..d2d47b767 100644
--- a/tests/auto/blackbox/testdata/setup-run-environment/setup-run-environment.qbs
+++ b/tests/auto/blackbox/testdata/setup-run-environment/setup-run-environment.qbs
@@ -61,6 +61,16 @@ Project {
bundle.isBundle: false
}
+ // Testing shows that clang (8.0) does not find dynamic libraries via
+ // the -L<dir> and -l<libname> mechanism unless the name is "lib<libname>.a".
+ Properties {
+ condition: qbs.hostOS.contains("windows") && qbs.toolchain.contains("clang")
+ cpp.dynamicLibraryPrefix: "lib"
+ cpp.dynamicLibraryImportSuffix: ".a"
+ }
+ cpp.dynamicLibraryPrefix: original
+ cpp.dynamicLibraryImportSuffix: original
+
install: true
installImportLib: true
installDir: "lib4"
@@ -91,8 +101,9 @@ Project {
property string fullInstallPrefix: FileInfo.joinPaths(qbs.installRoot, qbs.installPrefix)
property string lib3FilePath: FileInfo.joinPaths(fullInstallPrefix, "lib3",
- cpp.dynamicLibraryPrefix + "lib3" + (qbs.toolchain.contains("msvc")
- ? ".lib" : cpp.dynamicLibrarySuffix))
+ cpp.dynamicLibraryPrefix + "lib3" + (qbs.targetOS.contains("windows")
+ ? cpp.dynamicLibraryImportSuffix
+ : cpp.dynamicLibrarySuffix))
cpp.dynamicLibraries: [lib3FilePath, "lib4"]
cpp.libraryPaths: FileInfo.joinPaths(fullInstallPrefix, "lib4")
}
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index 19676d050..a2e8238c9 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 Jochen Ulrich <jochenulrich@t-online.de>
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qbs.
@@ -1805,14 +1806,17 @@ void TestBlackbox::separateDebugInfo()
{
QDir::setCurrent(testDataDir + "/separate-debug-info");
QCOMPARE(runQbs(QbsRunParameters(QStringList("qbs.debugInformation:true"))), 0);
+ const bool isWindows = m_qbsStdout.contains("is windows: yes");
+ const bool isNotWindows = m_qbsStdout.contains("is windows: no");
+ QVERIFY(isWindows != isNotWindows);
+ const bool isDarwin = m_qbsStdout.contains("is darwin: yes");
+ const bool isNotDarwin = m_qbsStdout.contains("is darwin: no");
+ QVERIFY(isDarwin != isNotDarwin);
const SettingsPtr s = settings();
Profile buildProfile(profileName(), s.get());
QStringList toolchain = buildProfile.value("qbs.toolchain").toStringList();
- std::string targetPlatform = buildProfile.value("qbs.targetPlatform").toString().toStdString();
- std::vector<std::string> targetOS = HostOsInfo::canonicalOSIdentifiers(targetPlatform);
- if (qbs::Internal::contains(targetOS, "darwin")
- || (targetPlatform.empty() && HostOsInfo::isMacosHost())) {
+ if (isDarwin) {
QVERIFY(directoryExists(relativeProductBuildDir("app1") + "/app1.app.dSYM"));
QVERIFY(regularFileExists(relativeProductBuildDir("app1")
+ "/app1.app.dSYM/Contents/Info.plist"));
@@ -1877,7 +1881,6 @@ void TestBlackbox::separateDebugInfo()
.entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries).size(), 1);
QVERIFY(regularFileExists(relativeProductBuildDir("bar5") + "/bar5.bundle.dwarf"));
} else if (toolchain.contains("gcc")) {
- const bool isWindows = qbs::Internal::contains(targetOS, "windows");
const QString exeSuffix = isWindows ? ".exe" : "";
const QString dllPrefix = isWindows ? "" : "lib";
const QString dllSuffix = isWindows ? ".dll" : ".so";
@@ -4353,6 +4356,18 @@ void TestBlackbox::lexyacc()
QCOMPARE(runQbs(), 0);
const QString parserBinary = relativeExecutableFilePath("one-grammar");
QProcess p;
+ const QByteArray magicString = "add to PATH: ";
+ const int magicStringIndex = m_qbsStdout.indexOf(magicString);
+ if (magicStringIndex != -1) {
+ const int newLineIndex = m_qbsStdout.indexOf('\n', magicStringIndex);
+ QVERIFY(newLineIndex != -1);
+ const int dirIndex = magicStringIndex + magicString.length();
+ const QString dir = QString::fromLocal8Bit(m_qbsStdout.mid(dirIndex,
+ newLineIndex - dirIndex));
+ QProcessEnvironment env;
+ env.insert("PATH", dir);
+ p.setProcessEnvironment(env);
+ }
p.start(parserBinary);
QVERIFY2(p.waitForStarted(), qPrintable(p.errorString()));
p.write("a && b || c && !d");
@@ -5624,6 +5639,34 @@ void TestBlackbox::autotestWithDependencies()
&& m_qbsStdout.contains("i am the helper"), m_qbsStdout.constData());
}
+void TestBlackbox::autotestTimeout()
+{
+ QFETCH(QStringList, resolveParams);
+ QFETCH(bool, expectFailure);
+ QDir::setCurrent(testDataDir + "/autotest-timeout");
+ QbsRunParameters resolveParameters("resolve", resolveParams);
+ QCOMPARE(runQbs(resolveParameters), 0);
+ QbsRunParameters buildParameters(QStringList({"-p", "autotest-runner"}));
+ buildParameters.expectFailure = expectFailure;
+ if (expectFailure) {
+ QVERIFY(runQbs(buildParameters) != 0);
+ QVERIFY(m_qbsStderr.contains("cancelled") && m_qbsStderr.contains("timeout"));
+ }
+ else
+ QVERIFY(runQbs(buildParameters) == 0);
+}
+
+void TestBlackbox::autotestTimeout_data()
+{
+ QTest::addColumn<QStringList>("resolveParams");
+ QTest::addColumn<bool>("expectFailure");
+ QTest::newRow("no timeout") << QStringList() << false;
+ QTest::newRow("timeout on test") << QStringList({"products.testApp.autotest.timeout:2"})
+ << true;
+ QTest::newRow("timeout on runner") << QStringList({"products.autotest-runner.timeout:2"})
+ << true;
+}
+
void TestBlackbox::autotests_data()
{
QTest::addColumn<QString>("evilPropertySpec");
diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h
index 959858321..ba511ed10 100644
--- a/tests/auto/blackbox/tst_blackbox.h
+++ b/tests/auto/blackbox/tst_blackbox.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 Jochen Ulrich <jochenulrich@t-online.de>
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qbs.
@@ -48,6 +49,8 @@ private slots:
void artifactScanning();
void assembly();
void autotestWithDependencies();
+ void autotestTimeout();
+ void autotestTimeout_data();
void autotests_data();
void autotests();
void auxiliaryInputsFromDependencies();
diff --git a/tests/auto/blackbox/tst_blackboxjoblimits.cpp b/tests/auto/blackbox/tst_blackboxjoblimits.cpp
index 0c366759d..89b5f638e 100644
--- a/tests/auto/blackbox/tst_blackboxjoblimits.cpp
+++ b/tests/auto/blackbox/tst_blackboxjoblimits.cpp
@@ -165,7 +165,7 @@ void TestBlackboxJobLimits::jobLimits()
else
QVERIFY2(m_qbsStderr.contains("exclusive"), m_qbsStderr.constData());
if (exitCode == 0)
- QCOMPARE(m_qbsStdout.count("Running tool"), 7);
+ QCOMPARE(m_qbsStdout.count("Running tool"), 5);
}
QTEST_MAIN(TestBlackboxJobLimits)