aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@digia.com>2014-02-10 18:08:01 +0100
committerJoerg Bornemann <joerg.bornemann@digia.com>2014-02-13 15:33:27 +0100
commite73f60919079fc7cb0f0ad6d50b1a364c7b0d2a6 (patch)
tree3ce15f1f9b336063d591999ce325ce28a6e21320 /tests
parenta3634a6bbb193c47cdec887a6b29356c979961aa (diff)
support transformers with an unknown number of outputs
To support different types of nodes in the build graph, we introduce the base class BuildGraphNode. Artifact now derives from BuildGraphNode. A RuleNode class is introduced that represents a rule in the build graph. Rules are applied in the build phase and not in a pre-build phase anymore. The handling of moc has been revisited. The fixed automoc pre-build phase is no more. This is the squashed merge of a feature branch. Task-number: QBS-370 Change-Id: If27cdc51cba8c9542e4282c2caa456faa723aeff Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/api/tst_api.cpp23
-rw-r--r--tests/auto/blackbox/testdata/add-qobject-macro-to-cpp-file/main.cpp7
-rw-r--r--tests/auto/blackbox/testdata/add-qobject-macro-to-cpp-file/object.cpp13
-rw-r--r--tests/auto/blackbox/testdata/add-qobject-macro-to-cpp-file/object.h4
-rw-r--r--tests/auto/blackbox/testdata/add-qobject-macro-to-cpp-file/project.qbs7
-rw-r--r--tests/auto/blackbox/testdata/added-file-persistent/file.cpp1
-rw-r--r--tests/auto/blackbox/testdata/added-file-persistent/main.cpp3
-rw-r--r--tests/auto/blackbox/testdata/added-file-persistent/project.qbs8
-rw-r--r--tests/auto/blackbox/testdata/fileTagger/moc_cpp.qbs2
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp98
-rw-r--r--tests/auto/blackbox/tst_blackbox.h3
11 files changed, 150 insertions, 19 deletions
diff --git a/tests/auto/api/tst_api.cpp b/tests/auto/api/tst_api.cpp
index 7536f4302..3ef5d7364 100644
--- a/tests/auto/api/tst_api.cpp
+++ b/tests/auto/api/tst_api.cpp
@@ -326,6 +326,15 @@ void TestApi::changeContent()
QVERIFY2(!errorInfo.hasError(), qPrintable(errorInfo.toString()));
}
+static qbs::ErrorInfo forceRuleEvaluation(const qbs::Project project)
+{
+ qbs::BuildOptions buildOptions;
+ buildOptions.setDryRun(true);
+ QScopedPointer<qbs::BuildJob> buildJob(project.buildAllProducts(buildOptions));
+ waitForFinished(buildJob.data());
+ return buildJob->error();
+}
+
void TestApi::disabledInstallGroup()
{
qbs::SetupProjectParameters setupParams = defaultSetupParameters();
@@ -335,7 +344,11 @@ void TestApi::disabledInstallGroup()
m_logSink, 0));
waitForFinished(job.data());
QVERIFY2(!job->error().hasError(), qPrintable(job->error().toString()));
- qbs::Project project = job->project();
+ const qbs::Project project = job->project();
+
+ const qbs::ErrorInfo errorInfo = forceRuleEvaluation(project);
+ QVERIFY2(!errorInfo.hasError(), qPrintable(errorInfo.toString()));
+
qbs::ProjectData projectData = project.projectData();
QCOMPARE(projectData.allProducts().count(), 1);
qbs::ProductData product = projectData.allProducts().first();
@@ -358,6 +371,10 @@ void TestApi::fileTagsFilterOverride()
waitForFinished(job.data());
QVERIFY2(!job->error().hasError(), qPrintable(job->error().toString()));
qbs::Project project = job->project();
+
+ const qbs::ErrorInfo errorInfo = forceRuleEvaluation(project);
+ QVERIFY2(!errorInfo.hasError(), qPrintable(errorInfo.toString()));
+
qbs::ProjectData projectData = project.projectData();
QCOMPARE(projectData.allProducts().count(), 1);
const qbs::ProductData product = projectData.allProducts().first();
@@ -378,6 +395,10 @@ void TestApi::installableFiles()
waitForFinished(job.data());
QVERIFY2(!job->error().hasError(), qPrintable(job->error().toString()));
qbs::Project project = job->project();
+
+ const qbs::ErrorInfo errorInfo = forceRuleEvaluation(project);
+ QVERIFY2(!errorInfo.hasError(), qPrintable(errorInfo.toString()));
+
qbs::ProjectData projectData = project.projectData();
QCOMPARE(projectData.allProducts().count(), 1);
qbs::ProductData product = projectData.allProducts().first();
diff --git a/tests/auto/blackbox/testdata/add-qobject-macro-to-cpp-file/main.cpp b/tests/auto/blackbox/testdata/add-qobject-macro-to-cpp-file/main.cpp
new file mode 100644
index 000000000..940a7628d
--- /dev/null
+++ b/tests/auto/blackbox/testdata/add-qobject-macro-to-cpp-file/main.cpp
@@ -0,0 +1,7 @@
+#include "object.h"
+
+int main()
+{
+ Object o;
+ o.f();
+}
diff --git a/tests/auto/blackbox/testdata/add-qobject-macro-to-cpp-file/object.cpp b/tests/auto/blackbox/testdata/add-qobject-macro-to-cpp-file/object.cpp
new file mode 100644
index 000000000..aab24f6c0
--- /dev/null
+++ b/tests/auto/blackbox/testdata/add-qobject-macro-to-cpp-file/object.cpp
@@ -0,0 +1,13 @@
+#include "object.h"
+
+#include <QObject>
+
+// class InternalClass : public QObject
+// {
+// Q_OBJECT
+// };
+
+void Object::f() { }
+
+
+// #include "object.moc"
diff --git a/tests/auto/blackbox/testdata/add-qobject-macro-to-cpp-file/object.h b/tests/auto/blackbox/testdata/add-qobject-macro-to-cpp-file/object.h
new file mode 100644
index 000000000..37070b494
--- /dev/null
+++ b/tests/auto/blackbox/testdata/add-qobject-macro-to-cpp-file/object.h
@@ -0,0 +1,4 @@
+class Object {
+public:
+ void f();
+};
diff --git a/tests/auto/blackbox/testdata/add-qobject-macro-to-cpp-file/project.qbs b/tests/auto/blackbox/testdata/add-qobject-macro-to-cpp-file/project.qbs
new file mode 100644
index 000000000..6c8db1913
--- /dev/null
+++ b/tests/auto/blackbox/testdata/add-qobject-macro-to-cpp-file/project.qbs
@@ -0,0 +1,7 @@
+import qbs
+
+CppApplication {
+ Depends { name: "Qt.core" }
+ files: ["main.cpp", "object.h", "object.cpp"]
+}
+
diff --git a/tests/auto/blackbox/testdata/added-file-persistent/file.cpp b/tests/auto/blackbox/testdata/added-file-persistent/file.cpp
new file mode 100644
index 000000000..8101b05dc
--- /dev/null
+++ b/tests/auto/blackbox/testdata/added-file-persistent/file.cpp
@@ -0,0 +1 @@
+void f() { }
diff --git a/tests/auto/blackbox/testdata/added-file-persistent/main.cpp b/tests/auto/blackbox/testdata/added-file-persistent/main.cpp
new file mode 100644
index 000000000..1921f1feb
--- /dev/null
+++ b/tests/auto/blackbox/testdata/added-file-persistent/main.cpp
@@ -0,0 +1,3 @@
+void f();
+
+int main() { f(); }
diff --git a/tests/auto/blackbox/testdata/added-file-persistent/project.qbs b/tests/auto/blackbox/testdata/added-file-persistent/project.qbs
new file mode 100644
index 000000000..672886646
--- /dev/null
+++ b/tests/auto/blackbox/testdata/added-file-persistent/project.qbs
@@ -0,0 +1,8 @@
+import qbs
+
+CppApplication {
+ files: [
+ 'main.cpp',
+ /* 'file.cpp' */
+ ]
+}
diff --git a/tests/auto/blackbox/testdata/fileTagger/moc_cpp.qbs b/tests/auto/blackbox/testdata/fileTagger/moc_cpp.qbs
index b56412bed..2bc02e23c 100644
--- a/tests/auto/blackbox/testdata/fileTagger/moc_cpp.qbs
+++ b/tests/auto/blackbox/testdata/fileTagger/moc_cpp.qbs
@@ -20,7 +20,7 @@ Project {
Rule {
inputs: ['text']
Artifact {
- fileTags: ['cpp', 'moc_cpp']
+ fileTags: ['cpp']
fileName: input.baseName + '.cpp'
}
prepare: {
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index d92896223..105af71a8 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -199,6 +199,63 @@ void TestBlackbox::initTestCase()
ccp(testSourceDir, testDataDir);
}
+void TestBlackbox::addedFilePersistent()
+{
+ QDir::setCurrent(testDataDir + QLatin1String("/added-file-persistent"));
+
+ // On the initial run, linking will fail.
+ QbsRunParameters failedRunParams;
+ failedRunParams.expectFailure = true;
+ QVERIFY(runQbs(failedRunParams) != 0);
+
+ // Add a file. qbs must schedule it for rule application on the next build.
+ QFile projectFile("project.qbs");
+ QVERIFY2(projectFile.open(QIODevice::ReadWrite), qPrintable(projectFile.errorString()));
+ const QByteArray originalContent = projectFile.readAll();
+ QByteArray addedFileContent = originalContent;
+ addedFileContent.replace("/* 'file.cpp' */", "'file.cpp'");
+ projectFile.resize(0);
+ projectFile.write(addedFileContent);
+ waitForNewTimestamp();
+ projectFile.flush();
+ QCOMPARE(runQbs(QbsRunParameters("resolve")), 0);
+
+ // Remove the file again. qbs must unschedule the rule application again.
+ // Consequently, the linking step must fail as in the initial run.
+ projectFile.resize(0);
+ projectFile.write(originalContent);
+ waitForNewTimestamp();
+ projectFile.flush();
+ QVERIFY(runQbs(failedRunParams) != 0);
+
+ // Add the file again. qbs must schedule it for rule application on the next build.
+ projectFile.resize(0);
+ projectFile.write(addedFileContent);
+ waitForNewTimestamp();
+ projectFile.close();
+ QCOMPARE(runQbs(QbsRunParameters("resolve")), 0);
+
+ // qbs must remember that a file was scheduled for rule application. The build must then
+ // succeed, as now all necessary symbols are linked in.
+ QCOMPARE(runQbs(), 0);
+}
+
+void TestBlackbox::addQObjectMacroToCppFile()
+{
+ QDir::setCurrent(testDataDir + QLatin1String("/add-qobject-macro-to-cpp-file"));
+ QCOMPARE(runQbs(), 0);
+
+ waitForNewTimestamp();
+ QFile cppFile("object.cpp");
+ QVERIFY2(cppFile.open(QIODevice::ReadWrite), qPrintable(cppFile.errorString()));
+ QByteArray contents = cppFile.readAll();
+ contents.replace("// ", "");
+ cppFile.resize(0);
+ cppFile.write(contents);
+ cppFile.close();
+ QCOMPARE(runQbs(), 0);
+}
+
void TestBlackbox::baseProperties()
{
QDir::setCurrent(testDataDir + QLatin1String("/baseProperties"));
@@ -1331,22 +1388,6 @@ void TestBlackbox::propertyChanges()
QVERIFY(!m_qbsStdout.contains("compiling lib.cpp"));
QVERIFY(!m_qbsStdout.contains("generated.txt"));
QVERIFY(m_qbsStdout.contains("Making output from input"));
-
- // Incremental build, irrelevant file tag of a rule in a module changed.
- waitForNewTimestamp();
- QVERIFY(moduleFile.open(QIODevice::ReadWrite));
- contents = moduleFile.readAll();
- contents.replace("inputs: ['test-input']", "inputs: ['test-input', 'hupe']");
- moduleFile.resize(0);
- moduleFile.write(contents);
- moduleFile.close();
- QCOMPARE(runQbs(params), 0);
- QVERIFY(!m_qbsStdout.contains("compiling source1.cpp"));
- QVERIFY(!m_qbsStdout.contains("compiling source2.cpp"));
- QVERIFY(!m_qbsStdout.contains("compiling source3.cpp"));
- QVERIFY(!m_qbsStdout.contains("compiling lib.cpp"));
- QVERIFY(!m_qbsStdout.contains("generated.txt"));
- QVERIFY(!m_qbsStdout.contains("Making output from input"));
}
void TestBlackbox::disabledProduct()
@@ -1388,7 +1429,6 @@ void TestBlackbox::dynamicLibs()
void TestBlackbox::dynamicRuleOutputs()
{
- SKIP_TEST("QBS-370");
const QString testDir = testDataDir + "/dynamicRuleOutputs";
QDir::setCurrent(testDir);
if (QFile::exists("work"))
@@ -1585,6 +1625,30 @@ void TestBlackbox::inheritQbsSearchPaths()
QCOMPARE(runQbs(), 0);
}
+void TestBlackbox::mocCppIncluded()
+{
+ QDir::setCurrent(testDataDir + "/moc_hpp_included");
+ QCOMPARE(runQbs(), 0); // Initial build.
+
+ // Touch header and try again.
+ waitForNewTimestamp();
+ QFile headerFile("object.h");
+ QVERIFY2(headerFile.open(QIODevice::WriteOnly | QIODevice::Append),
+ qPrintable(headerFile.errorString()));
+ headerFile.write("\n");
+ headerFile.close();
+ QCOMPARE(runQbs(), 0);
+
+ // Touch cpp file and try again.
+ waitForNewTimestamp();
+ QFile cppFile("object.cpp");
+ QVERIFY2(cppFile.open(QIODevice::WriteOnly | QIODevice::Append),
+ qPrintable(cppFile.errorString()));
+ cppFile.write("\n");
+ cppFile.close();
+ QCOMPARE(runQbs(), 0);
+}
+
void TestBlackbox::objC()
{
QDir::setCurrent(testDataDir + "/objc");
diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h
index 0c516d497..b29b86c52 100644
--- a/tests/auto/blackbox/tst_blackbox.h
+++ b/tests/auto/blackbox/tst_blackbox.h
@@ -96,6 +96,8 @@ public slots:
void initTestCase();
private slots:
+ void addedFilePersistent();
+ void addQObjectMacroToCppFile();
void baseProperties();
void build_project_data();
void build_project();
@@ -117,6 +119,7 @@ private slots:
void jsExtensionsPropertyList();
void jsExtensionsTextFile();
void inheritQbsSearchPaths();
+ void mocCppIncluded();
void objC();
void properQuoting();
void propertiesBlocks();