diff options
Diffstat (limited to 'tests/auto/blackbox')
-rwxr-xr-x | tests/auto/blackbox/testdata/nsis/hello.bat | 1 | ||||
-rwxr-xr-x | tests/auto/blackbox/testdata/nsis/hello.nsi | 19 | ||||
-rwxr-xr-x | tests/auto/blackbox/testdata/nsis/hello.qbs | 10 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.cpp | 40 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.h | 1 |
5 files changed, 71 insertions, 0 deletions
diff --git a/tests/auto/blackbox/testdata/nsis/hello.bat b/tests/auto/blackbox/testdata/nsis/hello.bat new file mode 100755 index 000000000..3af583cd8 --- /dev/null +++ b/tests/auto/blackbox/testdata/nsis/hello.bat @@ -0,0 +1 @@ +echo Hello world! diff --git a/tests/auto/blackbox/testdata/nsis/hello.nsi b/tests/auto/blackbox/testdata/nsis/hello.nsi new file mode 100755 index 000000000..70b73056a --- /dev/null +++ b/tests/auto/blackbox/testdata/nsis/hello.nsi @@ -0,0 +1,19 @@ +SetCompressor zlib + +!ifdef Win64 + Name "Qbs Hello - ${qbs.architecture} (64-bit)" +!else + Name "Qbs Hello - ${qbs.architecture} (32-bit)" +!endif + +OutFile "you-should-not-see-a-file-with-this-name.exe" +InstallDir "$DESKTOP\Qbs Hello" +RequestExecutionLevel user + +Page directory +Page instfiles + +Section "" + SetOutPath "$INSTDIR" + File "${batchFile}" +SectionEnd diff --git a/tests/auto/blackbox/testdata/nsis/hello.qbs b/tests/auto/blackbox/testdata/nsis/hello.qbs new file mode 100755 index 000000000..b7f3da505 --- /dev/null +++ b/tests/auto/blackbox/testdata/nsis/hello.qbs @@ -0,0 +1,10 @@ +import qbs + +NSISSetup { + condition: qbs.targetOS.contains("windows") + name: "Qbs Hello" + targetName: "qbs-hello-" + qbs.architecture + files: ["hello.nsi", "hello.bat"] + nsis.defines: ["batchFile=hello.bat"] + nsis.compressor: "lzma-solid" +} diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 0700df165..bf02d86a8 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -1538,4 +1538,44 @@ void TestBlackbox::testAssembly() QCOMPARE((bool)m_qbsStdout.contains("creating libtestc.a"), haveGcc); } +void TestBlackbox::testNsis() +{ + QStringList regKeys; + regKeys << QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\NSIS") + << QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS"); + + QStringList paths = QProcessEnvironment::systemEnvironment().value("PATH") + .split(HostOsInfo::pathListSeparator(), QString::SkipEmptyParts); + + foreach (const QString &key, regKeys) { + QSettings settings(key, QSettings::NativeFormat); + QString str = settings.value(QLatin1String(".")).toString(); + if (!str.isEmpty()) + paths.prepend(str); + } + + bool haveMakeNsis = false; + foreach (const QString &path, paths) { + if (QFile::exists(QDir::fromNativeSeparators(path) + + HostOsInfo::appendExecutableSuffix(QLatin1String("/makensis")))) { + haveMakeNsis = true; + break; + } + } + + if (!haveMakeNsis) { + SKIP_TEST("makensis is not installed"); + return; + } + + SettingsPtr settings = qbsSettings(); + Profile profile(buildProfileName, settings.data()); + bool targetIsWindows = profile.value("qbs.targetOS").toStringList().contains("windows"); + QDir::setCurrent(testDataDir + "/nsis"); + QVERIFY(runQbs() == 0); + QCOMPARE((bool)m_qbsStdout.contains("compiling hello.nsi"), targetIsWindows); + QCOMPARE((bool)m_qbsStdout.contains("SetCompressor ignored due to previous call with the /FINAL switch"), targetIsWindows); + QVERIFY(!QFile::exists(defaultInstallRoot + "/you-should-not-see-a-file-with-this-name.exe")); +} + QTEST_MAIN(TestBlackbox) diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index 24e8dce5d..43c1d1d12 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -153,6 +153,7 @@ private slots: void checkProjectFilePath(); void missingProfile(); void testAssembly(); + void testNsis(); private: QByteArray m_qbsStderr; |