Add tst_qmake::qinstall

...with a failing test case for QTBUG-77299.

Task-number: QTBUG-77299
Change-Id: I42c4fc4bb96f8660f8ff9bea97e6096ca6cec972
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Joerg Bornemann 2019-08-06 09:53:54 +02:00
parent 1be4f6c32c
commit 08192d6097
3 changed files with 108 additions and 0 deletions

View File

@ -279,6 +279,13 @@ bool TestCompiler::qmake(const QString &workDir, const QString &proName, const Q
<< additionalArguments); << 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 ) bool TestCompiler::make( const QString &workPath, const QString &target, bool expectFail )
{ {
QDir D; QDir D;

View File

@ -60,6 +60,8 @@ public:
// executes a qmake on proName in the specified workDir, output goes to buildDir or workDir if it's null // 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(), bool qmake(const QString &workDir, const QString &proName, const QString &buildDir = QString(),
const QStringList &additionalArguments = QStringList()); 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) // 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 ); bool make( const QString &workPath, const QString &target = QString(), bool expectFail = false );
// checks if the executable exists in destDir // checks if the executable exists in destDir

View File

@ -81,6 +81,7 @@ private slots:
void substitutes(); void substitutes();
void project(); void project();
void proFileCache(); void proFileCache();
void qinstall();
void resources(); void resources();
private: private:
@ -588,6 +589,104 @@ void tst_qmake::proFileCache()
QVERIFY( test_compiler.qmake( workDir, "pro_file_cache" )); 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() void tst_qmake::resources()
{ {
QString workDir = base_path + "/testdata/resources"; QString workDir = base_path + "/testdata/resources";