aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2018-04-17 16:56:47 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2018-05-09 07:36:39 +0000
commit15751999bbfa66015f48bbdde2fea2d4e8fed61a (patch)
tree17998f9d794db3ee00fea05680f3abada10bf81c /tests
parent03d1b289e4f2dd8021b57a070e97092034ffa6ac (diff)
Add a Makefile generator
At the very least, this is a useful debugging tool, as it displays the artifacts part of the build graph in a familiar format. Tested successfully with the qbs project itself: The generated Makefile could be used to build a working qbs on Linux and Windows. [ChangeLog] Added a Makefile generator Task-number: QBS-33 Change-Id: I8165168d9273bdb4853d4ac566b72087f9104f7a Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/blackbox/testdata/makefile-generator/app.qbs13
-rw-r--r--tests/auto/blackbox/testdata/makefile-generator/main.cpp6
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp24
-rw-r--r--tests/auto/blackbox/tst_blackbox.h1
-rw-r--r--tests/auto/blackbox/tst_blackboxbase.cpp3
5 files changed, 46 insertions, 1 deletions
diff --git a/tests/auto/blackbox/testdata/makefile-generator/app.qbs b/tests/auto/blackbox/testdata/makefile-generator/app.qbs
new file mode 100644
index 000000000..16981005a
--- /dev/null
+++ b/tests/auto/blackbox/testdata/makefile-generator/app.qbs
@@ -0,0 +1,13 @@
+import qbs
+
+CppApplication {
+ name: "the app"
+ consoleApplication: true
+ files: "main.cpp"
+ qbs.installPrefix: "/usr/local"
+ Group {
+ fileTagsFilter: "application"
+ qbs.install: true
+ qbs.installDir: "bin"
+ }
+}
diff --git a/tests/auto/blackbox/testdata/makefile-generator/main.cpp b/tests/auto/blackbox/testdata/makefile-generator/main.cpp
new file mode 100644
index 000000000..7f95e64bb
--- /dev/null
+++ b/tests/auto/blackbox/testdata/makefile-generator/main.cpp
@@ -0,0 +1,6 @@
+#include <iostream>
+
+int main()
+{
+ std::cout << "Hello, World!" << std::endl;
+}
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index c3885b88f..62930f54f 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -5464,6 +5464,30 @@ void TestBlackbox::localDeployment()
QVERIFY2(m_qbsStdout.contains(content), m_qbsStdout.constData());
}
+void TestBlackbox::makefileGenerator()
+{
+ QDir::setCurrent(testDataDir + "/makefile-generator");
+ const QbsRunParameters params("generate", QStringList{"-g", "makefile"});
+ QCOMPARE(runQbs(params), 0);
+ if (HostOsInfo::isWindowsHost())
+ return;
+ QProcess make;
+ make.setWorkingDirectory(QDir::currentPath() + '/' + relativeBuildDir());
+ const QString customInstallRoot = QDir::currentPath() + "/my-install-root";
+ make.start("make", QStringList{"INSTALL_ROOT=" + customInstallRoot, "install"});
+ QVERIFY(waitForProcessSuccess(make));
+ QVERIFY(QFile::exists(relativeExecutableFilePath("the app")));
+ QVERIFY(!QFile::exists(relativeBuildGraphFilePath()));
+ QProcess app;
+ app.start('"' + customInstallRoot + "/usr/local/bin/the app\"");
+ QVERIFY(waitForProcessSuccess(app));
+ const QByteArray appStdout = app.readAllStandardOutput();
+ QVERIFY2(appStdout.contains("Hello, World!"), appStdout.constData());
+ make.start("make", QStringList("clean"));
+ QVERIFY(waitForProcessSuccess(make));
+ QVERIFY(!QFile::exists(relativeExecutableFilePath("the app")));
+}
+
void TestBlackbox::minimumSystemVersion()
{
rmDirR(relativeBuildDir());
diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h
index 2804f513c..f3fb1f90d 100644
--- a/tests/auto/blackbox/tst_blackbox.h
+++ b/tests/auto/blackbox/tst_blackbox.h
@@ -154,6 +154,7 @@ private slots:
void listPropertyOrder();
void loadableModule();
void localDeployment();
+ void makefileGenerator();
void minimumSystemVersion();
void minimumSystemVersion_data();
void missingBuildGraph();
diff --git a/tests/auto/blackbox/tst_blackboxbase.cpp b/tests/auto/blackbox/tst_blackboxbase.cpp
index 6cc0766d6..b07f14553 100644
--- a/tests/auto/blackbox/tst_blackboxbase.cpp
+++ b/tests/auto/blackbox/tst_blackboxbase.cpp
@@ -86,7 +86,8 @@ int TestBlackboxBase::runQbs(const QbsRunParameters &params)
}
args << params.arguments;
const bool commandImpliesResolve = params.command.isEmpty() || params.command == "resolve"
- || params.command == "build" || params.command == "install" || params.command == "run";
+ || params.command == "build" || params.command == "install" || params.command == "run"
+ || params.command == "generate";
if (!params.profile.isEmpty() && commandImpliesResolve) {
args.push_back(QLatin1String("profile:") + params.profile);
}