summaryrefslogtreecommitdiffstats
path: root/tests/packagecreator/tst_packagecreator.cpp
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@pelagicore.com>2016-12-02 01:11:22 +0100
committerRobert Griebl <robert.griebl@pelagicore.com>2016-12-06 13:14:51 +0000
commit656ec980e963438567778ee1c2f7038acabce5d3 (patch)
treeeeeeac460c218d8836d13440c240f8f9f00e0500 /tests/packagecreator/tst_packagecreator.cpp
parentc932d79eda7f881d5421fcedcc00163d610c01d2 (diff)
Fixed auto-tests on Windows
Some tests need Unix tools in the path and they are now able to make use of a Cygwin environment, if it is available. Also fixed the test certificate generation, since it produced invalid p12s that somehow did work with OpenSSL/SecurityFramework. Change-Id: Id5c942b8d4532dc70872b434b49e0fee9f4f0c65 Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
Diffstat (limited to 'tests/packagecreator/tst_packagecreator.cpp')
-rw-r--r--tests/packagecreator/tst_packagecreator.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/tests/packagecreator/tst_packagecreator.cpp b/tests/packagecreator/tst_packagecreator.cpp
index f4b5ba50..2f21795a 100644
--- a/tests/packagecreator/tst_packagecreator.cpp
+++ b/tests/packagecreator/tst_packagecreator.cpp
@@ -51,8 +51,12 @@ private slots:
void createAndVerify();
private:
+ QString escapeFilename(const QString &name);
+
+private:
QDir m_baseDir;
bool m_tarAvailable = false;
+ bool m_isCygwin = false;
};
tst_PackageCreator::tst_PackageCreator()
@@ -68,6 +72,8 @@ void tst_PackageCreator::initTestCase()
&& tar.waitForFinished(3000)
&& (tar.exitStatus() == QProcess::NormalExit);
+ m_isCygwin = tar.readAllStandardOutput().contains("Cygwin");
+
QVERIFY(checkCorrectLocale());
}
@@ -113,7 +119,7 @@ void tst_PackageCreator::createAndVerify()
QSKIP("No tar command found in PATH - skipping the verification part of the test!");
QProcess tar;
- tar.start(qSL("tar"), { qSL("-tzf"), output.fileName() });
+ tar.start(qSL("tar"), { qSL("-tzf"), escapeFilename(output.fileName()) });
QVERIFY2(tar.waitForStarted(3000) &&
tar.waitForFinished(3000) &&
(tar.exitStatus() == QProcess::NormalExit) &&
@@ -123,7 +129,9 @@ void tst_PackageCreator::createAndVerify()
expectedContents.sort();
expectedContents.prepend(qSL("--PACKAGE-HEADER--"));
expectedContents.append(qSL("--PACKAGE-FOOTER--"));
- QCOMPARE(expectedContents, QString::fromLocal8Bit(tar.readAllStandardOutput()).split(qL1C('\n'), QString::SkipEmptyParts));
+
+ QStringList actualContents = QString::fromLocal8Bit(tar.readAllStandardOutput()).split(qL1C('\n'), QString::SkipEmptyParts);
+ QCOMPARE(actualContents, expectedContents);
// check the contents of the files
@@ -132,7 +140,7 @@ void tst_PackageCreator::createAndVerify()
QVERIFY2(src.open(QFile::ReadOnly), qPrintable(src.errorString()));
QByteArray data = src.readAll();
- tar.start(qSL("tar"), { qSL("-xzOf"), output.fileName(), file });
+ tar.start(qSL("tar"), { qSL("-xzOf"), escapeFilename(output.fileName()), file });
QVERIFY2(tar.waitForStarted(3000) &&
tar.waitForFinished(3000) &&
(tar.exitStatus() == QProcess::NormalExit) &&
@@ -142,6 +150,18 @@ void tst_PackageCreator::createAndVerify()
}
}
+QString tst_PackageCreator::escapeFilename(const QString &name)
+{
+ if (!m_isCygwin) {
+ return name;
+ } else {
+ QString s = QFileInfo(name).absoluteFilePath();
+ QString t = qSL("/cygdrive/");
+ t.append(s.at(0));
+ return t + s.mid(2);
+ }
+}
+
int main(int argc, char *argv[])
{
ensureCorrectLocale();