diff options
author | Christian Kandeler <christian.kandeler@digia.com> | 2014-04-10 17:30:41 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@digia.com> | 2014-04-11 11:20:52 +0200 |
commit | aeabec6dd3b4496549012df158e19d862cfcc548 (patch) | |
tree | 7b94ead8bdcb83a75f691e49bd4fa702d2ebf9f5 /tests/auto | |
parent | cf16c7c3d6ccb01db5af15de4a40c13e6f7c9877 (diff) |
Add (failing) autotest for QBS-552.
Change-Id: Idea84b324ddccc62721ff0025ffb85c55dd82a80
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/api/testdata/infinite-loop-js/infinite-loop.qbs | 20 | ||||
-rw-r--r-- | tests/auto/api/testdata/infinite-loop-process/dummy-input.txt | 0 | ||||
-rw-r--r-- | tests/auto/api/testdata/infinite-loop-process/infinite-loop.qbs | 32 | ||||
-rw-r--r-- | tests/auto/api/testdata/infinite-loop-process/main.cpp | 5 | ||||
-rw-r--r-- | tests/auto/api/tst_api.cpp | 37 | ||||
-rw-r--r-- | tests/auto/api/tst_api.h | 2 |
6 files changed, 95 insertions, 1 deletions
diff --git a/tests/auto/api/testdata/infinite-loop-js/infinite-loop.qbs b/tests/auto/api/testdata/infinite-loop-js/infinite-loop.qbs new file mode 100644 index 000000000..85f2b880e --- /dev/null +++ b/tests/auto/api/testdata/infinite-loop-js/infinite-loop.qbs @@ -0,0 +1,20 @@ +import qbs + +Product { + type: "mytype" + Transformer { + Artifact { + fileName: "output.txt" + fileTags: "mytype" + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "Running infinite loop"; + cmd.sourceCode = function() { + while (true) + ; + } + return cmd; + } + } +} diff --git a/tests/auto/api/testdata/infinite-loop-process/dummy-input.txt b/tests/auto/api/testdata/infinite-loop-process/dummy-input.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/auto/api/testdata/infinite-loop-process/dummy-input.txt diff --git a/tests/auto/api/testdata/infinite-loop-process/infinite-loop.qbs b/tests/auto/api/testdata/infinite-loop-process/infinite-loop.qbs new file mode 100644 index 000000000..166f598dd --- /dev/null +++ b/tests/auto/api/testdata/infinite-loop-process/infinite-loop.qbs @@ -0,0 +1,32 @@ +import qbs + +Project { + CppApplication { + type: "application" // suppress bundle generation + files: "main.cpp" + name: "infinite-loop" + } + + Product { + type: "mytype" + name: "caller" + Depends { name: "infinite-loop" } + Group { + files: "dummy-input.txt" // Needed because of QBS-277 + fileTags: "schnurz" + } + Rule { + inputs: "schnurz" + usings: "application" + Artifact { + fileName: "dummy" + fileTags: "mytype" + } + prepare: { + var cmd = new Command(inputs["application"][0].filePath); + cmd.description = "Calling application that runs forever"; + return cmd; + } + } + } +} diff --git a/tests/auto/api/testdata/infinite-loop-process/main.cpp b/tests/auto/api/testdata/infinite-loop-process/main.cpp new file mode 100644 index 000000000..71b27a96b --- /dev/null +++ b/tests/auto/api/testdata/infinite-loop-process/main.cpp @@ -0,0 +1,5 @@ +int main() +{ + while (true) + ; +} diff --git a/tests/auto/api/tst_api.cpp b/tests/auto/api/tst_api.cpp index 53064c6ee..aaafd49ce 100644 --- a/tests/auto/api/tst_api.cpp +++ b/tests/auto/api/tst_api.cpp @@ -49,6 +49,7 @@ #include <QScopedPointer> #include <QStringList> #include <QTest> +#include <QTimer> class LogSink: public qbs::ILogSink { @@ -90,11 +91,20 @@ void TestApi::initTestCase() m_workingDataDir, false, &errorMessage), qPrintable(errorMessage)); } -static void waitForFinished(qbs::AbstractJob *job) +static bool waitForFinished(qbs::AbstractJob *job, int timeout = 0) { QEventLoop loop; QObject::connect(job, SIGNAL(finished(bool,qbs::AbstractJob*)), &loop, SLOT(quit())); + if (timeout > 0) { + QTimer timer; + QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + timer.setSingleShot(true); + timer.start(timeout); + loop.exec(); + return timer.isActive(); // Timer ended the loop <=> job did not finish. + } loop.exec(); + return true; } @@ -419,6 +429,31 @@ void TestApi::fileTagsFilterOverride() QVERIFY(installableFiles.first().targetDirectory().contains("habicht")); } +void TestApi::infiniteLoop() +{ + QFETCH(QString, projectDirName); + qbs::SetupProjectParameters setupParams = defaultSetupParameters(); + const QString projectDir = QDir::cleanPath(m_workingDataDir + '/' + projectDirName); + setupParams.setProjectFilePath(projectDir + "/infinite-loop.qbs"); + setupParams.setBuildRoot(projectDir); + QScopedPointer<qbs::SetupProjectJob> setupJob(qbs::Project::setupProject(setupParams, + m_logSink, 0)); + waitForFinished(setupJob.data()); + QVERIFY2(!setupJob->error().hasError(), qPrintable(setupJob->error().toString())); + qbs::Project project = setupJob->project(); + const QScopedPointer<qbs::BuildJob> buildJob(project.buildAllProducts(qbs::BuildOptions())); + QTimer::singleShot(1000, setupJob.data(), SLOT(cancel())); + QEXPECT_FAIL(0, "QBS-552", Continue); + QVERIFY(waitForFinished(buildJob.data(), 3000)); +} + +void TestApi::infiniteLoop_data() +{ + QTest::addColumn<QString>("projectDirName"); + QTest::newRow("JS Command") << QString("infinite-loop-js"); + QTest::newRow("Process Command") << QString("infinite-loop-process"); +} + void TestApi::installableFiles() { qbs::SetupProjectParameters setupParams = defaultSetupParameters(); diff --git a/tests/auto/api/tst_api.h b/tests/auto/api/tst_api.h index 9908cc627..6183346ce 100644 --- a/tests/auto/api/tst_api.h +++ b/tests/auto/api/tst_api.h @@ -51,6 +51,8 @@ private slots: void changeContent(); void disabledInstallGroup(); void fileTagsFilterOverride(); + void infiniteLoop(); + void infiniteLoop_data(); void installableFiles(); void listBuildSystemFiles(); void nonexistingProjectPropertyFromProduct(); |