aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/blackbox
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/blackbox')
-rw-r--r--tests/auto/blackbox/testdata/nodejs/hello.js3
-rw-r--r--tests/auto/blackbox/testdata/nodejs/hello.qbs7
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp40
-rw-r--r--tests/auto/blackbox/tst_blackbox.h1
4 files changed, 51 insertions, 0 deletions
diff --git a/tests/auto/blackbox/testdata/nodejs/hello.js b/tests/auto/blackbox/testdata/nodejs/hello.js
new file mode 100644
index 000000000..43f1e2ffd
--- /dev/null
+++ b/tests/auto/blackbox/testdata/nodejs/hello.js
@@ -0,0 +1,3 @@
+if (console) {
+ console.log("hello world");
+}
diff --git a/tests/auto/blackbox/testdata/nodejs/hello.qbs b/tests/auto/blackbox/testdata/nodejs/hello.qbs
new file mode 100644
index 000000000..e11b1a599
--- /dev/null
+++ b/tests/auto/blackbox/testdata/nodejs/hello.qbs
@@ -0,0 +1,7 @@
+import qbs
+
+NodeJSApplication {
+ nodejs.applicationFile: "hello.js"
+ name: "hello"
+ files: "hello.js"
+}
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index d4ff742cb..c980896db 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -1980,4 +1980,44 @@ void TestBlackbox::testWiX()
QVERIFY(QFile::exists(buildDir + "/qbs-setup-" + arch + ".exe"));
}
+static QString findExecutable(const QStringList &fileNames)
+{
+ const QStringList path = QString::fromLocal8Bit(qgetenv("PATH"))
+ .split(HostOsInfo::pathListSeparator(), QString::SkipEmptyParts);
+
+ foreach (const QString &fileName, fileNames) {
+ foreach (const QString &ppath, path) {
+ const QString fullPath = ppath + QLatin1Char('/') + fileName;
+ if (QFileInfo(fullPath).exists())
+ return QDir::cleanPath(fullPath);
+ }
+ }
+ return QString();
+}
+
+static bool haveNodeJs()
+{
+ // The Node.js binary is called nodejs on Debian/Ubuntu-family operating systems due to a
+ // conflict with another package containing a binary named node
+ return !findExecutable(QStringList()
+ << QLatin1String("nodejs")
+ << QLatin1String("node")).isEmpty();
+}
+
+void TestBlackbox::testNodeJs()
+{
+ if (!haveNodeJs()) {
+ SKIP_TEST("Node.js is not installed");
+ return;
+ }
+
+ QDir::setCurrent(testDataDir + QLatin1String("/nodejs"));
+
+ QbsRunParameters params;
+ params.command = QLatin1String("run");
+ QCOMPARE(runQbs(params), 0);
+ QVERIFY((bool)m_qbsStdout.contains("hello world"));
+ QVERIFY(QFile::exists(buildDir + "/hello.js"));
+}
+
QTEST_MAIN(TestBlackbox)
diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h
index e0d6600eb..900b9d13e 100644
--- a/tests/auto/blackbox/tst_blackbox.h
+++ b/tests/auto/blackbox/tst_blackbox.h
@@ -169,6 +169,7 @@ private slots:
void testNsis();
void testEmbedInfoPlist();
void testWiX();
+ void testNodeJs();
private:
QByteArray m_qbsStderr;