diff options
author | Christian Kandeler <christian.kandeler@digia.com> | 2014-03-25 10:54:45 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@digia.com> | 2014-03-26 16:21:53 +0100 |
commit | 8042731153f49484dc831b7e51675652cef317cb (patch) | |
tree | 2fd43db5cc656f2e103f884644f8fd746ee6b7f0 /tests | |
parent | c0e86b13594631188d457e0a360799e7de73777d (diff) |
Fix "build single file" and "changed files" functionalities.
These had several problems.
Firstly, the "changed files" case was implemented by setting all
artifacts to "Built" and then setting the ones to "Buildable" that were
reachable bottom-up from artifacts corresponding to the respective files.
This approach broke with the introduction of rule nodes, because
parent nodes do not necessarily exist yet at initialization time. This
was not caught due to the lack of an autotest.
Secondly, the logic behind the "build single file" functionality was
faulty. The assumption was that this could be implemented on top of the
"changed file" functionality, which is wrong: Consider the case where
you have several cpp files that have not yet been built. Now
marking one of them as changed and filtering by the "obj" tag will still
cause all of them to be compiled, as we cannot simply exclude all other
source files from being built, which would break the build for the
normal "changed files" case without tag filtering. Therefore we need a
dedicated list of input files by which we can filter transformers.
Task-number: QBS-537
Change-Id: I47e2ba6d0cbd073561064640eaf8f63c4e0b39fa
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/api/tst_api.cpp | 7 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/changed-files/file1.cpp | 1 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/changed-files/file2.cpp | 1 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/changed-files/main.cpp | 1 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/changed-files/project.qbs | 5 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.cpp | 20 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.h | 1 |
7 files changed, 32 insertions, 4 deletions
diff --git a/tests/auto/api/tst_api.cpp b/tests/auto/api/tst_api.cpp index e88246283..53064c6ee 100644 --- a/tests/auto/api/tst_api.cpp +++ b/tests/auto/api/tst_api.cpp @@ -112,8 +112,8 @@ void printProjectData(const qbs::ProjectData &project) void TestApi::buildSingleFile() { qbs::SetupProjectParameters setupParams = defaultSetupParameters(); - setupParams.setProjectFilePath(QDir::cleanPath(m_workingDataDir + - "/build-single-file/project.qbs")); + const QString projectDirPath = QDir::cleanPath(m_workingDataDir + "/build-single-file"); + setupParams.setProjectFilePath(projectDirPath + "/project.qbs"); QScopedPointer<qbs::SetupProjectJob> setupJob(qbs::Project::setupProject(setupParams, m_logSink, 0)); waitForFinished(setupJob.data()); @@ -121,7 +121,7 @@ void TestApi::buildSingleFile() qbs::Project project = setupJob->project(); qbs::BuildOptions options; options.setDryRun(true); - options.setChangedFiles(QStringList(m_workingDataDir + "/build-single-file/compiled.cpp")); + options.setFilesToConsider(QStringList(projectDirPath + "/compiled.cpp")); options.setActiveFileTags(QStringList("obj")); m_logSink->setLogLevel(qbs::LoggerMaxLevel); QScopedPointer<qbs::BuildJob> buildJob(project.buildAllProducts(options)); @@ -130,7 +130,6 @@ void TestApi::buildSingleFile() SLOT(handleDescription(QString,QString))); waitForFinished(buildJob.data()); QVERIFY2(!buildJob->error().hasError(), qPrintable(buildJob->error().toString())); - QEXPECT_FAIL(0, "QBS-537", Abort); QCOMPARE(receiver.descriptions.count("compiling"), 1); QVERIFY2(receiver.descriptions.contains("compiling compiled.cpp"), qPrintable(receiver.descriptions)); diff --git a/tests/auto/blackbox/testdata/changed-files/file1.cpp b/tests/auto/blackbox/testdata/changed-files/file1.cpp new file mode 100644 index 000000000..1d6ea3b78 --- /dev/null +++ b/tests/auto/blackbox/testdata/changed-files/file1.cpp @@ -0,0 +1 @@ +void f1() {} diff --git a/tests/auto/blackbox/testdata/changed-files/file2.cpp b/tests/auto/blackbox/testdata/changed-files/file2.cpp new file mode 100644 index 000000000..8ccc02b45 --- /dev/null +++ b/tests/auto/blackbox/testdata/changed-files/file2.cpp @@ -0,0 +1 @@ +void f2() {} diff --git a/tests/auto/blackbox/testdata/changed-files/main.cpp b/tests/auto/blackbox/testdata/changed-files/main.cpp new file mode 100644 index 000000000..237c8ce18 --- /dev/null +++ b/tests/auto/blackbox/testdata/changed-files/main.cpp @@ -0,0 +1 @@ +int main() {} diff --git a/tests/auto/blackbox/testdata/changed-files/project.qbs b/tests/auto/blackbox/testdata/changed-files/project.qbs new file mode 100644 index 000000000..7fedd66d5 --- /dev/null +++ b/tests/auto/blackbox/testdata/changed-files/project.qbs @@ -0,0 +1,5 @@ +import qbs + +CppApplication { + files: ["file1.cpp", "file2.cpp", "main.cpp"] +} diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index b28e7ba8d..c106d5d16 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -363,6 +363,26 @@ void TestBlackbox::changeDependentLib() QCOMPARE(runQbs(), 0); } +void TestBlackbox::changedFiles() +{ + QDir::setCurrent(testDataDir + "/changed-files"); + const QString changedFile = QDir::cleanPath(QDir::currentPath() + "/file1.cpp"); + QbsRunParameters params(QStringList("--changed-files") << changedFile); + + // Initial run: Build all files, even though only one of them was marked as changed. + QCOMPARE(runQbs(params), 0); + QCOMPARE(m_qbsStdout.count("compiling"), 3); + + waitForNewTimestamp(); + touch(QDir::currentPath() + "/main.cpp"); + + // Now only the file marked as changed must be compiled, even though it hasn't really + // changed and another one has. + QCOMPARE(runQbs(params), 0); + QCOMPARE(m_qbsStdout.count("compiling"), 1); + QVERIFY2(m_qbsStdout.contains("file1.cpp"), m_qbsStdout.constData()); +} + void TestBlackbox::dependenciesProperty() { QDir::setCurrent(testDataDir + QLatin1String("/dependenciesProperty")); diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index b29b86c52..41b48aa49 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -104,6 +104,7 @@ private slots: void build_project_dry_run_data(); void build_project_dry_run(); void changeDependentLib(); + void changedFiles(); void dependenciesProperty(); void disabledProduct(); void disabledProject(); |