diff options
author | Joerg Bornemann <joerg.bornemann@theqtcompany.com> | 2014-11-03 11:29:14 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@theqtcompany.com> | 2014-11-03 11:29:14 +0100 |
commit | 8821b89c074b5901c6a2dc3b3756cd9531698ca7 (patch) | |
tree | 0c9058169127a9728b6664e914b77d63896b7f6f /tests/auto/api | |
parent | 4b736ac6bd882d0d09ecb0de31faa03b089fe2dc (diff) | |
parent | 0d1b18c7ad5bbfe4507f33d5f726b46f39d08677 (diff) |
Merge remote-tracking branch 'origin/1.3'
Conflicts:
tests/auto/api/tst_api.h
Change-Id: I1f9cb9105f4ed2c428729810b7a7079d11e90957
Diffstat (limited to 'tests/auto/api')
-rw-r--r-- | tests/auto/api/testdata/command-extraction/main.cpp | 1 | ||||
-rw-r--r-- | tests/auto/api/testdata/command-extraction/project.qbs | 5 | ||||
-rw-r--r-- | tests/auto/api/tst_api.cpp | 43 | ||||
-rw-r--r-- | tests/auto/api/tst_api.h | 1 |
4 files changed, 50 insertions, 0 deletions
diff --git a/tests/auto/api/testdata/command-extraction/main.cpp b/tests/auto/api/testdata/command-extraction/main.cpp new file mode 100644 index 000000000..237c8ce18 --- /dev/null +++ b/tests/auto/api/testdata/command-extraction/main.cpp @@ -0,0 +1 @@ +int main() {} diff --git a/tests/auto/api/testdata/command-extraction/project.qbs b/tests/auto/api/testdata/command-extraction/project.qbs new file mode 100644 index 000000000..73b66aaa0 --- /dev/null +++ b/tests/auto/api/testdata/command-extraction/project.qbs @@ -0,0 +1,5 @@ +import qbs + +CppApplication { + files: "main.cpp" +} diff --git a/tests/auto/api/tst_api.cpp b/tests/auto/api/tst_api.cpp index 9b72c0f04..d488068e3 100644 --- a/tests/auto/api/tst_api.cpp +++ b/tests/auto/api/tst_api.cpp @@ -682,6 +682,49 @@ void TestApi::changeContent() #endif // QBS_ENABLE_PROJECT_FILE_UPDATES +void TestApi::commandExtraction() +{ + qbs::SetupProjectParameters setupParams + = defaultSetupParameters("/command-extraction/project.qbs"); + 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(); + qbs::ProjectData projectData = project.projectData(); + QCOMPARE(projectData.allProducts().count(), 1); + qbs::ProductData productData = projectData.allProducts().first(); + qbs::ErrorInfo errorInfo; + const QString projectDirPath = QDir::cleanPath(QFileInfo(setupParams.projectFilePath()).path()); + const QString sourceFilePath = projectDirPath + "/main.cpp"; + + // Before the first build, no rules exist. + qbs::RuleCommandList commands + = project.ruleCommands(productData, sourceFilePath, "obj", &errorInfo); + QCOMPARE(commands.count(), 0); + QVERIFY(errorInfo.hasError()); + QVERIFY2(errorInfo.toString().contains("No rule"), qPrintable(errorInfo.toString())); + + qbs::BuildOptions options; + options.setDryRun(true); + QScopedPointer<qbs::BuildJob> buildJob(project.buildAllProducts(options)); + waitForFinished(buildJob.data()); + QVERIFY2(!buildJob->error().hasError(), qPrintable(buildJob->error().toString())); + projectData = project.projectData(); + QCOMPARE(projectData.allProducts().count(), 1); + productData = projectData.allProducts().first(); + errorInfo = qbs::ErrorInfo(); + + // After the build, the compile command must be found. + commands = project.ruleCommands(productData, sourceFilePath, "obj", &errorInfo); + QCOMPARE(commands.count(), 1); + QVERIFY2(!errorInfo.hasError(), qPrintable(errorInfo.toString())); + const qbs::RuleCommand command = commands.first(); + QCOMPARE(command.type(), qbs::RuleCommand::ProcessCommandType); + QVERIFY(!command.executable().isEmpty()); + QVERIFY(!command.arguments().isEmpty()); +} + void TestApi::changeDependentLib() { qbs::ErrorInfo errorInfo = doBuildProject("change-dependent-lib/change-dependent-lib.qbs"); diff --git a/tests/auto/api/tst_api.h b/tests/auto/api/tst_api.h index 47bfb829d..3f0f19145 100644 --- a/tests/auto/api/tst_api.h +++ b/tests/auto/api/tst_api.h @@ -65,6 +65,7 @@ private slots: #ifdef QBS_ENABLE_PROJECT_FILE_UPDATES void changeContent(); #endif + void commandExtraction(); void changeDependentLib(); void enableAndDisableProduct(); void disabledInstallGroup(); |