From 67b0f10356220f6fa485ef9bb49cc1a1b0844d1b Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 14 Nov 2013 12:57:26 -0500 Subject: Turn NSIS manual test into an autotest. Change-Id: Ic8db2f80e1b6ebdad61032b3bcd8c8c986b62614 Reviewed-by: Christian Kandeler --- tests/auto/blackbox/testdata/nsis/hello.bat | 1 + tests/auto/blackbox/testdata/nsis/hello.nsi | 19 ++++++++++++++ tests/auto/blackbox/testdata/nsis/hello.qbs | 10 ++++++++ tests/auto/blackbox/tst_blackbox.cpp | 40 +++++++++++++++++++++++++++++ tests/auto/blackbox/tst_blackbox.h | 1 + tests/manual/nsis/hello.bat | 1 - tests/manual/nsis/hello.nsi | 19 -------------- tests/manual/nsis/hello.qbs | 9 ------- 8 files changed, 71 insertions(+), 29 deletions(-) create mode 100755 tests/auto/blackbox/testdata/nsis/hello.bat create mode 100755 tests/auto/blackbox/testdata/nsis/hello.nsi create mode 100755 tests/auto/blackbox/testdata/nsis/hello.qbs delete mode 100755 tests/manual/nsis/hello.bat delete mode 100755 tests/manual/nsis/hello.nsi delete mode 100755 tests/manual/nsis/hello.qbs (limited to 'tests') 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; diff --git a/tests/manual/nsis/hello.bat b/tests/manual/nsis/hello.bat deleted file mode 100755 index 3af583cd8..000000000 --- a/tests/manual/nsis/hello.bat +++ /dev/null @@ -1 +0,0 @@ -echo Hello world! diff --git a/tests/manual/nsis/hello.nsi b/tests/manual/nsis/hello.nsi deleted file mode 100755 index 70b73056a..000000000 --- a/tests/manual/nsis/hello.nsi +++ /dev/null @@ -1,19 +0,0 @@ -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/manual/nsis/hello.qbs b/tests/manual/nsis/hello.qbs deleted file mode 100755 index 47465dcf4..000000000 --- a/tests/manual/nsis/hello.qbs +++ /dev/null @@ -1,9 +0,0 @@ -import qbs - -NSISSetup { - name: "Qbs Hello" - targetName: "qbs-hello-" + qbs.architecture - files: ["hello.nsi", "hello.bat"] - nsis.defines: ["batchFile=hello.bat"] - nsis.compressor: "lzma-solid" -} -- cgit v1.2.1