summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-08-15 01:00:30 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-08-15 01:00:30 +0200
commitc5c938055524b8b7e41ad361b0063f9ed1762044 (patch)
tree6f2961ef872e33679e02c0d0ef82334381db93f3 /tests
parent8bd48a1c335b404ebbeb7c09c859e0715e6b5cd4 (diff)
parent0d024bd0a63fa7a741f4f118a3b48806b695594f (diff)
Merge remote-tracking branch 'origin/5.12' into 5.13
Diffstat (limited to 'tests')
-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 0a7ba3b40b..e769f955c4 100644
--- a/tests/auto/tools/qmake/testcompiler.cpp
+++ b/tests/auto/tools/qmake/testcompiler.cpp
@@ -279,6 +279,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 50232669c0..e22a2c6c3d 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 cacee30c86..8ca367773d 100644
--- a/tests/auto/tools/qmake/tst_qmake.cpp
+++ b/tests/auto/tools/qmake/tst_qmake.cpp
@@ -81,6 +81,7 @@ private slots:
void substitutes();
void project();
void proFileCache();
+ void qinstall();
void resources();
private:
@@ -588,6 +589,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";