summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-08-16 01:00:32 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-08-16 01:00:33 +0200
commit56f46ba13dd9273b4be4e8f1f1f867a6feff04da (patch)
treec05a8f2bea5f645eaff32a5aa0380a9704366b6e /tests/auto
parent37bae591b7829cd8ac6a9c8556bbe6b96b365bc3 (diff)
parent66a1975200c5ec106205522c37e32f990df84883 (diff)
Merge remote-tracking branch 'origin/5.13' into dev
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/tools/qmake/testcompiler.cpp7
-rw-r--r--tests/auto/tools/qmake/testcompiler.h2
-rw-r--r--tests/auto/tools/qmake/tst_qmake.cpp99
3 files changed, 108 insertions, 0 deletions
diff --git a/tests/auto/tools/qmake/testcompiler.cpp b/tests/auto/tools/qmake/testcompiler.cpp
index b5aa4bec82..8ab8d5d721 100644
--- a/tests/auto/tools/qmake/testcompiler.cpp
+++ b/tests/auto/tools/qmake/testcompiler.cpp
@@ -281,6 +281,13 @@ bool TestCompiler::qmake(const QString &workDir, const QString &proName, const Q
<< additionalArguments);
}
+bool TestCompiler::qmake(const QString &workDir, const QStringList &arguments)
+{
+ QDir d;
+ d.setCurrent(workDir); // ### runCommand should take a workingDir argument instead
+ return runCommand(qmakeCmd_, arguments);
+}
+
bool TestCompiler::make( const QString &workPath, const QString &target, bool expectFail )
{
QDir D;
diff --git a/tests/auto/tools/qmake/testcompiler.h b/tests/auto/tools/qmake/testcompiler.h
index 73a79201fe..d80cd8d53a 100644
--- a/tests/auto/tools/qmake/testcompiler.h
+++ b/tests/auto/tools/qmake/testcompiler.h
@@ -60,6 +60,8 @@ public:
// executes a qmake on proName in the specified workDir, output goes to buildDir or workDir if it's null
bool qmake(const QString &workDir, const QString &proName, const QString &buildDir = QString(),
const QStringList &additionalArguments = QStringList());
+ // executes qmake in workDir with the specified arguments
+ bool qmake(const QString &workDir, const QStringList &arguments);
// executes a make in the specified workPath, with an optional target (eg. install)
bool make( const QString &workPath, const QString &target = QString(), bool expectFail = false );
// checks if the executable exists in destDir
diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp
index 290ff49304..99d41d3583 100644
--- a/tests/auto/tools/qmake/tst_qmake.cpp
+++ b/tests/auto/tools/qmake/tst_qmake.cpp
@@ -84,6 +84,7 @@ private slots:
void substitutes();
void project();
void proFileCache();
+ void qinstall();
void resources();
void conflictingTargets();
@@ -620,6 +621,104 @@ void tst_qmake::proFileCache()
QVERIFY( test_compiler.qmake( workDir, "pro_file_cache" ));
}
+void tst_qmake::qinstall()
+{
+ const QString testName = "qinstall";
+ QDir testDataDir = base_path + "/testdata";
+ if (testDataDir.exists(testName))
+ testDataDir.rmdir(testName);
+ QVERIFY(testDataDir.mkdir(testName));
+ const QString workDir = testDataDir.filePath(testName);
+ auto qinstall = [&](const QString &src, const QString &dst, bool executable = false) {
+ QStringList args = {"-install", "qinstall"};
+ if (executable)
+ args << "-exe";
+ args << src << dst;
+ return test_compiler.qmake(workDir, args);
+ };
+ const QFileDevice::Permissions readFlags
+ = QFileDevice::ReadOwner | QFileDevice::ReadUser
+ | QFileDevice::ReadGroup | QFileDevice::ReadOther;
+ const QFileDevice::Permissions writeFlags
+ = QFileDevice::WriteOwner | QFileDevice::WriteUser
+ | QFileDevice::WriteGroup | QFileDevice::WriteOther;
+ const QFileDevice::Permissions exeFlags
+ = QFileDevice::ExeOwner | QFileDevice::ExeUser
+ | QFileDevice::ExeGroup | QFileDevice::ExeOther;
+
+ // install a regular file
+ {
+ QFileInfo src(testDataDir.filePath("project/main.cpp"));
+ QFileInfo dst("foo.cpp");
+ QVERIFY(qinstall(src.filePath(), dst.filePath()));
+ QVERIFY(dst.exists());
+ QCOMPARE(src.size(), dst.size());
+ QVERIFY(dst.permissions() & readFlags);
+ QVERIFY(dst.permissions() & writeFlags);
+ QVERIFY(!(dst.permissions() & exeFlags));
+ test_compiler.clearCommandOutput();
+ }
+
+ // install an executable file
+ {
+ const QString mocFilePath = QLibraryInfo::location(QLibraryInfo::BinariesPath)
+ + "/moc"
+#ifdef Q_OS_WIN
+ + ".exe"
+#endif
+ ;
+ QFileInfo src(mocFilePath);
+ QVERIFY(src.exists());
+ QVERIFY(src.permissions() & exeFlags);
+ QFileInfo dst("copied_" + src.fileName());
+ QVERIFY(qinstall(src.filePath(), dst.filePath(), true));
+ QVERIFY(dst.exists());
+ QCOMPARE(src.size(), dst.size());
+ QVERIFY(dst.permissions() & readFlags);
+ QVERIFY(dst.permissions() & writeFlags);
+ QVERIFY(dst.permissions() & exeFlags);
+ test_compiler.clearCommandOutput();
+ }
+
+ // install a read-only file
+ {
+ QFile srcfile("foo.cpp");
+ QVERIFY(srcfile.setPermissions(srcfile.permissions() & ~writeFlags));
+ QFileInfo src(srcfile);
+ QFileInfo dst("bar.cpp");
+ QVERIFY(qinstall(src.filePath(), dst.filePath()));
+ QVERIFY(dst.exists());
+ QCOMPARE(src.size(), dst.size());
+ QVERIFY(dst.permissions() & readFlags);
+ QVERIFY(dst.permissions() & writeFlags);
+ QVERIFY(!(dst.permissions() & exeFlags));
+ test_compiler.clearCommandOutput();
+ }
+
+ // install a directory
+ {
+ QDir src = testDataDir;
+ src.cd("project");
+ QDir dst("narf");
+ QVERIFY(qinstall(src.absolutePath(), dst.absolutePath()));
+ QCOMPARE(src.entryList(QDir::Files, QDir::Name), dst.entryList(QDir::Files, QDir::Name));
+ test_compiler.clearCommandOutput();
+ }
+
+ // install a directory with a read-only file
+ {
+ QDir src("narf");
+ QFile srcfile(src.filePath("main.cpp"));
+ QVERIFY(srcfile.setPermissions(srcfile.permissions() & ~writeFlags));
+ QDir dst("zort");
+#ifdef Q_OS_WIN
+ QEXPECT_FAIL("", "QTBUG-77299", Abort);
+#endif
+ QVERIFY(qinstall(src.absolutePath(), dst.absolutePath()));
+ QCOMPARE(src.entryList(QDir::Files, QDir::Name), dst.entryList(QDir::Files, QDir::Name));
+ }
+}
+
void tst_qmake::resources()
{
QString workDir = base_path + "/testdata/resources";