CQtDeployer/UnitTests/tst_deploytest.cpp

1598 lines
44 KiB
C++
Raw Normal View History

2019-01-26 15:34:39 +03:00
/*
* Copyright (C) 2018-2019 QuasarApp.
* Distributed under the lgplv3 software license, see the accompanying
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
#include <QtTest>
#include <quasarapp.h>
2019-09-03 18:15:05 +03:00
#include <deploycore.h>
2019-09-08 13:37:33 +03:00
#include <extracter.h>
2019-03-19 21:50:05 +03:00
#include <dependenciesscanner.h>
2019-03-26 22:12:20 +03:00
#include <qml.h>
2019-09-08 19:30:01 +03:00
#include <deploy.h>
2019-09-14 13:59:11 +03:00
#include <configparser.h>
#include <QCryptographicHash>
2019-09-15 11:47:51 +03:00
#include <distrostruct.h>
#include <pathutils.h>
2019-01-26 15:34:39 +03:00
2019-03-19 21:50:05 +03:00
#include <QMap>
2019-01-26 22:27:36 +03:00
#include <QByteArray>
2019-01-26 15:34:39 +03:00
#include <QDir>
2019-01-26 22:27:36 +03:00
#include <thread>
2019-03-19 21:50:05 +03:00
#include "libcreator.h"
2019-09-14 15:51:23 +03:00
#include "modules.h"
2019-03-26 22:12:20 +03:00
#include "qmlcreator.h"
2019-09-10 18:22:49 +03:00
#include "testutils.h"
2019-01-26 15:34:39 +03:00
// add necessary includes here
2019-09-11 18:09:37 +03:00
const QString TestBinDir = TEST_BIN_DIR;
const QString TestQtDir = QT_BASE_DIR;
2019-09-11 18:09:37 +03:00
2019-01-26 15:34:39 +03:00
class deploytest : public QObject
{
Q_OBJECT
private:
2019-09-13 17:44:20 +03:00
QSet<QString> qtFilesTree;
2019-04-01 12:45:12 +03:00
bool runProcess(const QString& DistroPath,
const QString& filename,
const QString &qt = "");
2019-03-29 23:02:39 +03:00
QStringList getFilesFromDir(const QString& dir);
2019-05-14 11:31:13 +03:00
2019-09-14 15:51:23 +03:00
void runTestParams(const QStringList &list, QSet<QString> *tree = nullptr, bool noWarnings = false);
2019-09-10 18:22:49 +03:00
2019-09-27 20:18:45 +03:00
void checkResults(const QSet<QString> &tree, bool noWarnings);
2019-01-26 15:34:39 +03:00
public:
deploytest();
2019-01-27 12:30:45 +03:00
/**
* @brief generateLib
* @param paath
* @return size of lib
*/
int generateLib(const QString& paath);
void deleteLib(const QString& paath);
2019-01-26 15:34:39 +03:00
~deploytest();
private slots:
void initTestCase();
void cleanupTestCase();
2019-09-10 18:22:49 +03:00
// old tests (not valid)
2019-01-26 22:27:36 +03:00
void testDeployTarget();
void testStrip();
2019-03-19 21:50:05 +03:00
void testExtractLib();
2019-09-15 11:47:51 +03:00
void testDistroStruct();
void testRelativeLink();
2019-11-01 19:43:54 +03:00
void testCheckQt();
2019-05-23 18:31:51 +03:00
2019-04-01 12:50:59 +03:00
void testQmlExtrct();
2019-08-27 11:07:12 +03:00
void testSetTargetDir();
2019-01-26 15:34:39 +03:00
2019-09-14 15:51:23 +03:00
// void mainTests();
2019-09-10 18:22:49 +03:00
// end old tests
2019-09-12 17:00:50 +03:00
// tested flags : help, version
2019-09-10 18:22:49 +03:00
void testHelp();
2019-09-28 16:44:39 +03:00
2019-09-12 17:00:50 +03:00
// tested flags clear noOvervrite
void testOverwrite();
2019-09-12 17:00:50 +03:00
// tested flags binDir
2019-09-12 10:23:49 +03:00
void testBinDir();
2019-09-14 15:51:23 +03:00
// tested flags confFile
2019-09-12 17:00:50 +03:00
void testConfFile();
2019-09-14 15:51:23 +03:00
// tested flags qmlDir qmake
void testQt();
2019-09-28 16:44:39 +03:00
// tested clear force clear in clear mode
void testClear();
2019-09-14 15:51:23 +03:00
// tested flags ignore ignoreEnv
void testIgnore();
// tested flags libDir recursiveDepth
void testLibDir();
// tested flag extraPlugin
void testExtraPlugins();
// tested flag targetDir
void testTargetDir();
2019-09-24 16:30:52 +03:00
// tested flag noLibc deploySystem
2019-09-14 15:51:23 +03:00
void testSystemLib();
2019-09-24 16:30:52 +03:00
// tested flag qmlOut libOut trOut pluginOut binOut
void testOutDirs();
2019-03-28 10:32:46 +03:00
void testMSVC();
2019-09-10 18:22:49 +03:00
2019-09-16 12:38:48 +03:00
void testEmptyParamsString();
2019-09-19 10:25:31 +03:00
void testWebEngine();
2019-11-06 12:32:34 +03:00
// extractPlugins flags
void testExtractPlugins();
2019-01-26 15:34:39 +03:00
};
2019-04-01 12:45:12 +03:00
bool deploytest::runProcess(const QString &DistroPath,
const QString &filename,
const QString& qt) {
QProcess p;
2019-04-01 12:45:12 +03:00
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
if (qt.size()) {
auto val = env.value("LD_LIBRARY_PATH","").remove(qt);
env.insert("LD_LIBRARY_PATH", val);
val = env.value("PATH","").remove(qt);
env.insert("PATH", val);
env.insert("QTDIR", "");
} else {
env.clear();
env.insert("QTDIR", "");
}
p.setProcessEnvironment(env);
#ifdef Q_OS_UNIX
p.setProgram(DistroPath + "/" + filename + ".sh");
#else
p.setProgram(DistroPath + "/" + filename + ".exe");
#endif
p.start();
2019-04-06 18:12:50 +03:00
if (!p.waitForFinished(10000)) {
return false;
}
QString str = p.readAll();
2019-04-01 12:45:12 +03:00
if (p.exitCode()) {
qCritical() << p.errorString();
}
if (p.exitCode()) {
qWarning() << "exitCode == " << p.exitCode();
}
if (str.contains("failed to load component", Qt::CaseInsensitive)
|| str.contains("is not installed", Qt::CaseInsensitive) ||
str.contains("error", Qt::CaseInsensitive)) {
return false;
}
return p.exitCode() == 0;
}
2019-03-29 23:02:39 +03:00
QStringList deploytest::getFilesFromDir(const QString &path) {
2019-09-14 15:51:23 +03:00
QDir dir(path);
2019-03-29 23:02:39 +03:00
2019-09-14 15:51:23 +03:00
QStringList res;
2019-03-29 23:02:39 +03:00
2019-09-14 15:51:23 +03:00
auto list = dir.entryInfoList(QDir::Dirs| QDir::Files| QDir::NoDotAndDotDot);
2019-03-29 23:02:39 +03:00
2019-09-14 15:51:23 +03:00
for (auto &&subDir: list) {
2019-03-29 23:02:39 +03:00
2019-09-14 15:51:23 +03:00
if (subDir.isFile()) {
res.push_back(subDir.fileName());
} else {
res.append(getFilesFromDir(subDir.absoluteFilePath()));
2019-03-29 23:02:39 +03:00
}
2019-05-14 11:31:13 +03:00
}
2019-09-14 15:51:23 +03:00
return res;
2019-03-29 23:02:39 +03:00
}
2019-05-14 11:31:13 +03:00
2019-09-13 17:44:20 +03:00
deploytest::deploytest() {
TestUtils utils;
2019-05-14 11:31:13 +03:00
2019-09-13 17:44:20 +03:00
auto tempTree = utils.getTree(TestQtDir);
2019-05-14 11:31:13 +03:00
2019-11-06 16:07:02 +03:00
tempTree += utils.getTree("/lib", 5);
tempTree += utils.getTree("/usr/lib", 5);
2019-09-23 14:26:45 +03:00
2019-09-13 17:44:20 +03:00
for (const QString &i: tempTree) {
qtFilesTree.insert(QFileInfo(i).fileName());
2019-05-14 11:31:13 +03:00
}
}
2019-01-27 12:30:45 +03:00
int deploytest::generateLib(const QString &paath)
{
QDir dir;
2019-01-27 15:37:19 +03:00
dir.mkpath(QFileInfo(paath).absolutePath());
2019-01-27 12:30:45 +03:00
QFile testLib (paath);
int size = 0;
if (testLib.open(QIODevice::ReadWrite| QIODevice::Truncate)) {
QFile resData(":/debugLib");
if (resData.open(QIODevice::ReadOnly)) {
QByteArray tempData = resData.readAll();
size = tempData.size();
testLib.write(tempData.data(), tempData.size());
resData.close();
}
testLib.close();
}
return size;
}
void deploytest::deleteLib(const QString &paath)
{
QFileInfo info(paath);
if (info.isDir()) {
QFile::remove(info.absoluteFilePath());
} else {
QDir qt(info.absoluteFilePath());
qt.removeRecursively();
}
}
2019-01-26 15:34:39 +03:00
deploytest::~deploytest(){}
void deploytest::initTestCase() {
QDir qt;
2019-11-05 13:17:52 +03:00
2019-01-26 15:34:39 +03:00
qt.mkpath("./test/Qt/5.12/");
qt.mkpath("./test/extraPath/");
qt.mkpath("./test/extra/");
qt.mkpath("./test/warning/");
2019-01-26 17:39:19 +03:00
qt.mkpath("./test/bins/");
2019-01-26 15:34:39 +03:00
QFile f( "./test/Qt/5.12/generalLib.so");
if (f.open(QIODevice::WriteOnly| QIODevice::Truncate)) {
f.write("lib", 3);
f.close();
}
f.setFileName("./test/extraPath/ExtraLib.so");
if (f.open(QIODevice::WriteOnly| QIODevice::Truncate)) {
f.write("lib", 3);
f.close();
}
f.setFileName("./test/extra/ExtraLib.so");
if (f.open(QIODevice::WriteOnly| QIODevice::Truncate)) {
f.write("lib", 3);
f.close();
}
f.setFileName("./test/warning/WarningLib.so");
if (f.open(QIODevice::WriteOnly| QIODevice::Truncate)) {
f.write("lib", 3);
f.close();
}
2019-01-26 17:39:19 +03:00
f.setFileName("./test/bins/execTarget.exe");
if (f.open(QIODevice::WriteOnly| QIODevice::Truncate)) {
f.write("exec", 3);
f.close();
}
f.setFileName("./test/bins/execTarget");
if (f.open(QIODevice::WriteOnly| QIODevice::Truncate)) {
f.write("exec", 3);
f.close();
}
2019-01-26 15:34:39 +03:00
}
void deploytest::cleanupTestCase() {
QDir qt("./test");
qt.removeRecursively();
}
2019-01-26 22:27:36 +03:00
void deploytest::testDeployTarget() {
2019-01-26 15:34:39 +03:00
2019-09-08 19:30:01 +03:00
FileManager file;
2019-09-14 13:59:11 +03:00
ConfigParser *deploy = new ConfigParser(&file);
2019-09-08 19:30:01 +03:00
2019-01-26 17:39:19 +03:00
QStringList targets;
targets << "./test/bins/execTarget.exe";
QVERIFY(deploy->setTargets(targets));
delete deploy;
targets.clear();
2019-09-14 13:59:11 +03:00
deploy = new ConfigParser(&file);
2019-01-26 17:39:19 +03:00
targets << "./test/bins/execTarget";
QVERIFY(deploy->setTargets(targets));
delete deploy;
targets.clear();
2019-09-14 13:59:11 +03:00
deploy = new ConfigParser(&file);
2019-01-26 17:39:19 +03:00
targets << "./test/bins/execTarget.exe" << "./test/bins/execTarget";
QVERIFY(deploy->setTargets(targets));
delete deploy;
targets.clear();
2019-09-14 13:59:11 +03:00
deploy = new ConfigParser(&file);
2019-01-26 17:39:19 +03:00
targets << "./test/bns/execTarget.exe";
QVERIFY(!deploy->setTargets(targets));
delete deploy;
targets.clear();
2019-09-14 13:59:11 +03:00
deploy = new ConfigParser(&file);
2019-01-26 17:39:19 +03:00
targets << "./test/bins/";
QVERIFY(deploy->setTargets(targets));
delete deploy;
targets.clear();
2019-09-14 13:59:11 +03:00
deploy = new ConfigParser(&file);
2019-01-26 17:39:19 +03:00
targets << "./test/bins/" << "./test/warning/";
QVERIFY(deploy->setTargets(targets));
delete deploy;
targets.clear();
2019-01-26 22:27:36 +03:00
}
2019-01-26 17:39:19 +03:00
2019-01-26 22:27:36 +03:00
void deploytest::testStrip() {
2019-01-26 17:39:19 +03:00
2019-09-08 19:30:01 +03:00
#ifdef Q_OS_UNIX
2019-01-27 12:30:45 +03:00
//for one lib
qint64 sizeBefor = generateLib("./test/binTargetDir/debugLib.so");
2019-01-26 22:27:36 +03:00
qint64 sizeAfter = 0;
2019-09-04 12:01:33 +03:00
FileManager *deploy = new FileManager();
2019-01-27 12:30:45 +03:00
QVERIFY(deploy->strip("./test/binTargetDir/debugLib.so"));
2019-01-26 22:27:36 +03:00
2019-01-27 12:30:45 +03:00
QFile testLib ("./test/binTargetDir/debugLib.so");
2019-01-26 22:27:36 +03:00
if (testLib.open(QIODevice::ReadOnly)) {
sizeAfter = testLib.size();
testLib.close();
}
2019-01-26 15:34:39 +03:00
2019-01-27 12:30:45 +03:00
deleteLib("./test/binTargetDir");
delete deploy;
2019-01-26 15:34:39 +03:00
2019-01-26 22:27:36 +03:00
QVERIFY(sizeBefor > sizeAfter);
2019-01-27 12:30:45 +03:00
//for folder
QStringList libList = {
("./test/binTargetDir/debugLib1.so"),
("./test/binTargetDir/debugLib2.so.1.2"),
("./test/binTargetDir/debugLib3.so.1"),
("./test/binTargetDir/debugLib4.so.1.0.0"),
("./test/binTargetDir/debugLib.dll"),
("./test/binTargetDir/debugLib1.dll")
};
QList<qint64> sizeBeforList = {};
for (auto i: libList) {
sizeBeforList.push_back(generateLib(i));
}
QList<qint64> sizeAfterList;
2019-09-04 12:01:33 +03:00
deploy = new FileManager();
2019-01-27 12:30:45 +03:00
QVERIFY(deploy->strip("./test/binTargetDir"));
for(auto i: libList) {
QFile testLib (i);
if (testLib.open(QIODevice::ReadOnly)) {
sizeAfterList.push_back(testLib.size());
testLib.close();
}
}
deleteLib("./test/binTargetDir");
QVERIFY(sizeBeforList.size() == sizeAfterList.size());
for (int i = 0; i < sizeAfterList.size(); ++i) {
QVERIFY2(sizeBeforList[i] > sizeAfterList[i],
QString("index %0, lib: %1 size befor:%2, sizeAfter:%3").
arg(i).arg(libList[i]).arg(sizeBeforList[i]).arg(sizeAfterList[i]).
toLatin1());
}
2019-04-01 22:03:37 +03:00
2019-01-27 19:46:11 +03:00
#endif
}
2019-03-19 21:50:05 +03:00
void deploytest::testExtractLib() {
LibCreator creator("./");
auto libs = creator.getLibs();
auto deb = creator.getLibsDep();
auto platforms = creator.getLibplatform();
DependenciesScanner scaner;
LibInfo info;
for (auto &&lib : libs) {
QVERIFY(scaner.fillLibInfo(info, lib));
2019-04-05 14:23:42 +03:00
QVERIFY(info.getName() == QFileInfo(lib).fileName());
QVERIFY(info.getPath() == QFileInfo(lib).absolutePath());
2019-03-19 21:50:05 +03:00
QVERIFY(info.fullPath() == QFileInfo(lib).absoluteFilePath());
2019-04-05 14:23:42 +03:00
QVERIFY(info.getPlatform() == platforms.value(lib));
2019-03-23 20:40:33 +03:00
for (auto &dep : deb.value(lib)) {
2019-04-05 16:52:53 +03:00
bool test = info.getDependncies().contains(dep.toUpper());
QVERIFY(test);
2019-03-23 20:40:33 +03:00
}
2019-03-19 21:50:05 +03:00
}
}
2019-03-28 10:32:46 +03:00
void deploytest::testMSVC() {
QString testPath = "./Qt/5.11.2/msvc2017_64/bin/";
QDir d;
QDir oldDir("./Qt");
oldDir.removeRecursively();
QVERIFY(d.mkpath(testPath));
2019-11-01 15:12:03 +03:00
auto msvc = DeployCore::getMSVC(testPath);
2019-03-28 10:32:46 +03:00
QVERIFY(msvc & MSVCVersion::MSVC_17);
QVERIFY(msvc & MSVCVersion::MSVC_x64);
2019-04-01 12:54:07 +03:00
QDir dir("./Qt");
dir.removeRecursively();
2019-03-28 10:32:46 +03:00
}
2019-09-16 12:38:48 +03:00
void deploytest::testEmptyParamsString() {
TestUtils utils;
2019-09-19 11:13:28 +03:00
#ifdef WITH_ALL_TESTS
2019-09-16 12:38:48 +03:00
QDir("./" + DISTRO_DIR).removeRecursively();
auto comapareTree = utils.createTree({
2019-09-19 10:25:31 +03:00
"./" + DISTRO_DIR + "/UnitTests.sh",
2019-09-19 11:13:28 +03:00
"./" + DISTRO_DIR + "/bin/qt.conf",
2019-09-19 10:25:31 +03:00
"./" + DISTRO_DIR + "/bin/UnitTests",
2019-09-16 12:38:48 +03:00
});
runTestParams({}, &comapareTree);
comapareTree = utils.createTree({});
runTestParams({"clear"}, &comapareTree);
comapareTree = utils.createTree({
2019-09-19 10:25:31 +03:00
"./" + DISTRO_DIR + "/UnitTests.sh",
2019-09-19 11:13:28 +03:00
"./" + DISTRO_DIR + "/bin/qt.conf",
2019-09-19 10:25:31 +03:00
"./" + DISTRO_DIR + "/bin/UnitTests",
2019-09-16 12:38:48 +03:00
});
runTestParams({"-bin", "./UnitTests"
"-targetDor", "./testDeployDir"}, &comapareTree);
comapareTree = utils.createTree({});
runTestParams({"clear", "-targetDor", "./testDeployDir"}, &comapareTree);
#endif
}
2019-09-15 20:31:31 +03:00
void deploytest::testWebEngine() {
#ifdef WITH_ALL_TESTS
2019-09-15 20:31:31 +03:00
TestUtils utils;
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "quicknanobrowser";
QString qmake = TestQtDir + "bin/qmake";
#else
QString bin = TestBinDir + "quicknanobrowser.exe";
QString qmake = TestQtDir + "bin/qmake.exe";
#endif
2019-09-17 14:35:40 +03:00
auto comapareTree = Modules::qtWebEngine();
2019-09-15 20:31:31 +03:00
runTestParams({"-bin", bin, "clear" ,
"-qmake", qmake,
"-qmlDir", TestBinDir + "/../quicknanobrowser"}, &comapareTree);
#endif
2019-09-15 20:31:31 +03:00
}
2019-11-06 12:32:34 +03:00
void deploytest::testExtractPlugins() {
TestUtils utils;
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "TestQMLWidgets";
QString qmake = TestQtDir + "bin/qmake";
#else
QString bin = TestBinDir + "TestQMLWidgets.exe";
QString qmake = TestQtDir + "bin/qmake.exe";
#endif
auto comapareTree = Modules::qmlLibs();
runTestParams({"-bin", bin, "clear" ,
"-qmake", qmake,
"-qmlDir", TestBinDir + "/../TestQMLWidgets",
"extractPlugins"}, &comapareTree);
2019-11-06 16:07:02 +03:00
QuasarAppUtils::Params::parseParams({"-bin", bin, "clear" ,
"-qmake", qmake,
"-qmlDir", TestBinDir + "/../TestQMLWidgets",
"extractPlugins", "deploySystem"});
2019-11-06 12:32:34 +03:00
2019-11-06 16:07:02 +03:00
Deploy deploy;
QVERIFY(deploy.run() == 0);
QVERIFY(DeployCore::_config);
QVERIFY(!DeployCore::_config->targetDir.isEmpty());
2019-11-06 12:32:34 +03:00
2019-11-06 16:07:02 +03:00
auto resultTree = utils.getTree(DeployCore::_config->targetDir);
auto comapre = utils.compareTree(resultTree, comapareTree);
2019-11-06 16:33:30 +03:00
#ifdef Q_OS_LINUX
2019-11-06 16:07:02 +03:00
QVERIFY(comapre.size());
2019-11-06 16:33:30 +03:00
#endif
2019-11-06 16:07:02 +03:00
for (auto i = comapre.begin(); i != comapre.end(); ++i) {
2019-11-06 16:23:56 +03:00
if (i.value() != 1 && qtFilesTree.contains(QFileInfo(i.key()).fileName())) {
qCritical() << "missing library found " << i.key();
2019-11-06 16:07:02 +03:00
QVERIFY(false);
2019-11-06 16:23:56 +03:00
}
2019-11-06 16:07:02 +03:00
}
2019-11-06 12:32:34 +03:00
}
2019-04-01 12:54:07 +03:00
void deploytest::testQmlExtrct() {
2019-03-26 22:12:20 +03:00
QmlCreator creator("./");
auto imports = creator.getQmlImports();
auto qmlFiles = creator.getCopyedQml();
QML scaner("./");
for (auto &&file : qmlFiles) {
auto fileImports = scaner.extractImportsFromFile(file);
2019-04-02 12:46:14 +03:00
for (auto &fil : imports.value(file)) {
QVERIFY(fileImports.contains(fil, Qt::CaseInsensitive));
2019-03-26 22:12:20 +03:00
}
}
}
2019-08-25 14:42:00 +03:00
void deploytest::testDistroStruct() {
DistroStruct distro;
auto cases = QList<QPair<QString,QString>>{
2019-08-26 08:46:53 +03:00
{"", "/"},
2019-08-25 14:42:00 +03:00
{"/", "/"},
2019-08-28 17:23:49 +03:00
{"/res","/../"},
{"/res/","/../"},
{"/res/type","/../../"},
{"/res/type/","/../../"},
{"res/type","/../../"},
{"res/type/","/../../"},
{"res//type/","/../../"},
{"res////type/","/../../"},
{"//res///type/////","/../../"},
2019-08-26 08:46:53 +03:00
{"\\", "/"},
2019-08-28 17:23:49 +03:00
{"\\res","/../"},
{"\\res\\","/../"},
{"\\res\\type","/../../"},
{"\\res\\type\\","/../../"},
{"res\\type","/../../"},
{"res\\type\\","/../../"},
{"res\\\\type\\","/../../"},
{"res\\\\\\\\type\\","/../../"},
{"\\\\res\\\\\\type\\\\\\\\\\","/../../"},
2019-08-25 14:42:00 +03:00
};
2019-08-26 08:46:53 +03:00
for (auto &i: cases) {
QVERIFY(distro.getRelativePath(i.first) == i.second);
2019-08-27 11:21:13 +03:00
}
2019-08-27 11:17:07 +03:00
}
void deploytest::testRelativeLink() {
auto cases = QList<QList<QString>>{
{"", "", "./"},
{"/media", "/etc", "./../etc/"},
{"/media///", "/etc///", "./../etc/"},
{"/media/etc/usr", "/media/etc", "./../"},
{"/media/etc", "/media/etc/usr", "./usr/"},
2019-10-16 18:07:36 +03:00
{"C:/", "C:/", "./"},
{"C:\\", "C:/", "./"},
{"C:/", "C:\\", "./"},
{"C:/media", "C:/etc", "./../etc/"},
{"C:/media//\\", "C:/etc///", "./../etc/"},
{"C:/media/etc/usr", "C:/media/etc", "./../"},
{"C:/media\\etc", "C:/media/etc/usr", "./usr/"},
{"C:/media/etc", "D:/media/etc/usr", "D:/media/etc/usr"},
};
for (auto &i: cases) {
QVERIFY(PathUtils::getRelativeLink(i[0], i[1]) == i[2]);
}
2019-10-16 18:07:36 +03:00
for (int i = 1; i < cases.size() - 1; i++) {
QVERIFY(PathUtils::isAbsalutPath(cases[i][0]));
QVERIFY(!PathUtils::isAbsalutPath(cases[i][2]));
}
}
2019-11-01 19:43:54 +03:00
void deploytest::testCheckQt() {
Deploy *deployer = new Deploy();
QuasarAppUtils::Params::parseParams({"-binDir", TestBinDir, "clear"});
QVERIFY(deployer->prepare());
auto cases = QList<QPair<QString, bool>>{
{TestQtDir + "/", false},
{TestQtDir + "", false},
{TestQtDir + "/bin/file1", false},
{TestQtDir + "/lib/file12", false},
{TestQtDir + "/resurces/file13", false},
{TestQtDir + "/libexec/f", false},
{TestQtDir + "/mkspecs", false},
{TestQtDir + "/qml", false},
{TestQtDir + "/plugins", false},
{TestQtDir + "/file", false},
{TestQtDir + "\\", false},
{TestQtDir + "", false},
{TestQtDir + "\\bin\\file1", false},
{TestQtDir + "\\lib\\file12", false},
{TestQtDir + "\\resurces\\file13", false},
{TestQtDir + "\\libexec\\f", false},
{TestQtDir + "\\mkspecs", false},
{TestQtDir + "\\qml", false},
{TestQtDir + "\\plugins", false},
{TestQtDir + "\\file", false},
};
for (auto &i: cases) {
QVERIFY(DeployCore::isQtLib(i.first) == i.second);
}
delete deployer;
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "TestQMLWidgets";
QString qmake = TestQtDir + "bin/qmake";
#else
QString bin = TestBinDir + "TestQMLWidgets.exe";
QString qmake = TestQtDir + "bin/qmake.exe";
#endif
deployer = new Deploy();
QuasarAppUtils::Params::parseParams({"-bin", bin, "clear" ,
"-qmake", qmake,
"-qmlDir", TestBinDir + "/../TestQMLWidgets"});
QVERIFY(deployer->prepare());
cases = QList<QPair<QString, bool>>{
{TestQtDir + "/", false},
{TestQtDir + "", false},
{TestQtDir + "/bin/file1", true},
{TestQtDir + "/lib/file12", true},
{TestQtDir + "/resources/file13", true},
{TestQtDir + "/libexec/f", true},
{TestQtDir + "/mkspecs", false},
{TestQtDir + "/qml", true},
{TestQtDir + "/plugins", true},
{TestQtDir + "/file", false},
{TestQtDir + "\\", false},
{TestQtDir + "", false},
{TestQtDir + "\\bin\\file1", true},
{TestQtDir + "\\lib\\file12", true},
{TestQtDir + "\\resources\\file13", true},
{TestQtDir + "\\libexec\\f", true},
{TestQtDir + "\\mkspecs", false},
{TestQtDir + "\\qml", true},
{TestQtDir + "\\plugins", true},
{TestQtDir + "\\file", false},
};
for (auto &i: cases) {
QVERIFY(DeployCore::isQtLib(i.first) == i.second);
}
delete deployer;
}
2019-08-27 11:07:12 +03:00
void deploytest::testSetTargetDir() {
2019-09-09 09:56:57 +03:00
FileManager file;
2019-09-14 13:59:11 +03:00
ConfigParser dep(&file);
2019-08-27 11:07:12 +03:00
dep.setTargetDir();
2019-09-16 09:44:19 +03:00
QVERIFY(dep.config()->targetDir == QFileInfo("./" + DISTRO_DIR + "").absoluteFilePath());
2019-08-27 11:07:12 +03:00
dep.setTargetDir("./ff");
2019-09-09 09:56:57 +03:00
QVERIFY(dep.config()->targetDir == QFileInfo("./ff").absoluteFilePath());
2019-08-27 11:07:12 +03:00
2019-09-16 09:44:19 +03:00
QStringList argv = {"-targetDir", "./" + DISTRO_DIR + "2"};
2019-08-27 11:07:12 +03:00
2019-09-16 09:44:19 +03:00
QuasarAppUtils::Params::parseParams(argv);
2019-08-27 11:07:12 +03:00
dep.setTargetDir();
2019-09-16 09:44:19 +03:00
QVERIFY(dep.config()->targetDir == QFileInfo("./" + DISTRO_DIR + "2").absoluteFilePath());
2019-08-27 11:07:12 +03:00
dep.setTargetDir("./ff");
2019-09-16 09:44:19 +03:00
QVERIFY(dep.config()->targetDir == QFileInfo("./" + DISTRO_DIR + "2").absoluteFilePath());
2019-08-26 08:46:53 +03:00
2019-08-25 14:42:00 +03:00
}
2019-09-14 15:51:23 +03:00
void deploytest::runTestParams(const QStringList &list, QSet<QString>* tree, bool noWarnings) {
2019-09-10 18:22:49 +03:00
QuasarAppUtils::Params::parseParams(list);
Deploy deploy;
QVERIFY(deploy.run() == 0);
if (tree) {
2019-09-27 20:18:45 +03:00
checkResults(*tree, noWarnings);
}
#ifdef WITH_SNAP
#ifdef Q_OS_UNIX
if (QFileInfo::exists("/snap/cqtdeployer/current/cqtdeployer.sh") && tree) {
2019-09-10 18:22:49 +03:00
TestUtils utils;
2019-09-27 20:18:45 +03:00
auto targetDir = DeployCore::_config->targetDir;
QuasarAppUtils::Params::parseParams(QStringList{"clear",
"-targetDir", targetDir,
});
Deploy deployClear;
QVERIFY(deployClear.run() == 0);
2019-09-10 18:22:49 +03:00
auto resultTree = utils.getTree(DeployCore::_config->targetDir);
2019-09-13 17:44:20 +03:00
2019-09-27 20:18:45 +03:00
QVERIFY(!resultTree.size());
2019-09-10 18:22:49 +03:00
2019-09-27 20:18:45 +03:00
QProcess cqtdeployerProcess;
cqtdeployerProcess.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
cqtdeployerProcess.setProgram("cqtdeployer");
cqtdeployerProcess.setArguments(list);
2019-05-14 11:31:13 +03:00
2019-09-27 20:18:45 +03:00
cqtdeployerProcess.start();
2019-09-13 17:44:20 +03:00
2019-09-27 20:18:45 +03:00
QVERIFY(cqtdeployerProcess.waitForStarted());
QVERIFY(cqtdeployerProcess.waitForFinished(3000000));
2019-09-13 17:44:20 +03:00
2019-09-27 20:18:45 +03:00
checkResults(*tree, noWarnings);
}
#endif
#endif
}
2019-09-13 17:44:20 +03:00
2019-09-27 20:18:45 +03:00
void deploytest::checkResults(const QSet<QString> &tree, bool noWarnings) {
TestUtils utils;
2019-09-13 17:44:20 +03:00
2019-09-27 20:18:45 +03:00
QVERIFY(DeployCore::_config);
QVERIFY(!DeployCore::_config->targetDir.isEmpty());
auto resultTree = utils.getTree(DeployCore::_config->targetDir);
2019-09-27 20:18:45 +03:00
auto comapre = utils.compareTree(resultTree, tree);
2019-09-27 20:18:45 +03:00
if (comapre.size() != 0) {
2019-09-27 20:18:45 +03:00
bool bug = false;
2019-11-02 01:00:05 +03:00
QJsonObject comapreResult;
2019-09-27 20:18:45 +03:00
for (auto i = comapre.begin(); i != comapre.end(); ++i) {
if (i.value() == 1) {
2019-11-02 01:00:05 +03:00
comapreResult[ i.key()] = "Added unnecessary file";
2019-09-27 20:18:45 +03:00
qCritical() << "added unnecessary file : " + i.key();
bug = true;
} else if (qtFilesTree.contains(QFileInfo(i.key()).fileName())) {
2019-11-02 01:00:05 +03:00
comapreResult[ i.key()] = "Missing";
2019-09-27 20:18:45 +03:00
qCritical() << "Missing file : " + i.key();
bug = true;
} else if (noWarnings) {
2019-11-02 01:00:05 +03:00
comapreResult[ i.key()] = " not exits in qt Dir";
2019-09-27 20:18:45 +03:00
qCritical() << "File : " + i.key() + " not exits in qt Dir";
bug = true;
} else {
2019-11-02 01:00:05 +03:00
comapreResult[ i.key()] = " not exits in qt Dir";
2019-09-27 20:18:45 +03:00
qWarning() << "File : " + i.key() + " not exits in qt Dir";
}
}
2019-09-12 21:42:10 +03:00
2019-09-27 20:18:45 +03:00
if (!bug) {
return;
}
2019-09-27 20:18:45 +03:00
QJsonObject obj;
for (const auto &i : resultTree) {
obj[i];
2019-09-12 21:42:10 +03:00
}
2019-09-10 18:22:49 +03:00
2019-09-27 20:18:45 +03:00
QJsonDocument doc(obj);
QFile lasttree("./LastTree.json");
lasttree.open(QIODevice::WriteOnly| QIODevice::Truncate);
lasttree.write(doc.toJson());
lasttree.close();
2019-11-02 01:00:05 +03:00
lasttree.setFileName("./CompareTree.json");
lasttree.open(QIODevice::WriteOnly| QIODevice::Truncate);
lasttree.write(QJsonDocument(comapreResult).toJson());
lasttree.close();
2019-09-27 20:18:45 +03:00
QVERIFY2(false, "runTestParams fail");
2019-09-10 18:22:49 +03:00
}
}
void deploytest::testHelp() {
runTestParams({"h"});
runTestParams({"v"});
2019-09-12 09:38:30 +03:00
auto help = DeployCore::help();
2019-09-10 18:22:49 +03:00
for (auto &key: DeployCore::helpKeys()) {
2019-11-05 16:52:22 +03:00
if (!help.contains(key)) {
QVERIFY(false);
}
2019-09-10 18:22:49 +03:00
}
}
void deploytest::testOverwrite() {
TestUtils utils;
2019-09-12 17:00:50 +03:00
#ifdef Q_OS_UNIX
2019-09-16 09:44:19 +03:00
QFile f("./" + DISTRO_DIR + "/bin/TestOnlyC");
auto comapareTree = utils.createTree(
2019-09-16 09:44:19 +03:00
{"./" + DISTRO_DIR + "/bin/TestOnlyC",
2019-09-19 10:25:31 +03:00
"./" + DISTRO_DIR + "/bin/qt.conf",
2019-09-16 09:44:19 +03:00
"./" + DISTRO_DIR + "/TestOnlyC.sh"});
2019-09-14 13:59:11 +03:00
QString bin = TestBinDir + "TestOnlyC";
2019-09-12 17:00:50 +03:00
#else
2019-09-16 09:44:19 +03:00
QFile f("./" + DISTRO_DIR + "/TestOnlyC.exe");
2019-09-12 17:00:50 +03:00
auto comapareTree = utils.createTree(
2019-09-16 09:44:19 +03:00
{"./" + DISTRO_DIR + "/TestOnlyC.exe",
"./" + DISTRO_DIR + "/qt.conf"});
2019-09-14 13:59:11 +03:00
QString bin = TestBinDir + "TestOnlyC.exe";
2019-04-06 14:42:22 +03:00
2019-04-01 12:45:12 +03:00
#endif
2019-09-14 13:59:11 +03:00
runTestParams({"-bin", bin, "force-clear", "noOverwrite"}, &comapareTree);
QVERIFY(f.open(QIODevice::ReadOnly));
auto hashBefor = QCryptographicHash::hash(f.readAll(), QCryptographicHash::Md5);
f.close();
QVERIFY(f.open(QIODevice::WriteOnly | QIODevice::Append));
f.write(QByteArray(10, '1'));
f.close();
QVERIFY(f.open(QIODevice::ReadOnly));
auto hashAfter = QCryptographicHash::hash(f.readAll(), QCryptographicHash::Md5);
f.close();
QVERIFY(hashAfter != hashBefor);
2019-09-14 13:59:11 +03:00
runTestParams({"-bin", bin, "noOverwrite"}, &comapareTree);
QVERIFY(f.open(QIODevice::ReadOnly));
hashAfter = QCryptographicHash::hash(f.readAll(), QCryptographicHash::Md5);
f.close();
QVERIFY(hashAfter != hashBefor);
2019-09-14 13:59:11 +03:00
runTestParams({"-bin", bin}, &comapareTree);
QVERIFY(f.open(QIODevice::ReadOnly));
hashAfter = QCryptographicHash::hash(f.readAll(), QCryptographicHash::Md5);
f.close();
QVERIFY(hashAfter == hashBefor);
2019-04-01 12:45:12 +03:00
}
2019-09-12 10:23:49 +03:00
void deploytest::testBinDir() {
TestUtils utils;
2019-09-12 17:00:50 +03:00
#ifdef Q_OS_UNIX
2019-09-12 10:23:49 +03:00
auto comapareTree = utils.createTree(
2019-09-16 09:44:19 +03:00
{"./" + DISTRO_DIR + "/bin/TestOnlyC",
2019-09-19 10:25:31 +03:00
"./" + DISTRO_DIR + "/bin/qt.conf",
2019-09-16 09:44:19 +03:00
"./" + DISTRO_DIR + "/bin/QtWidgetsProject",
"./" + DISTRO_DIR + "/bin/TestQMLWidgets",
"./" + DISTRO_DIR + "/TestOnlyC.sh",
"./" + DISTRO_DIR + "/QtWidgetsProject.sh",
"./" + DISTRO_DIR + "/TestQMLWidgets.sh"});
2019-09-12 17:00:50 +03:00
#else
auto comapareTree = utils.createTree(
2019-09-16 09:44:19 +03:00
{"./" + DISTRO_DIR + "/TestOnlyC.exe",
"./" + DISTRO_DIR + "/QtWidgetsProject.exe",
"./" + DISTRO_DIR + "/TestQMLWidgets.exe",
"./" + DISTRO_DIR + "/qt.conf"});
2019-09-12 17:00:50 +03:00
#endif
2019-04-04 18:11:38 +03:00
2019-09-19 11:13:28 +03:00
#ifdef WITH_ALL_TESTS
comapareTree += utils.createTree(
{"./" + DISTRO_DIR + "/bin/quicknanobrowser",
"./" + DISTRO_DIR + "/quicknanobrowser.sh"});
#endif
2019-04-04 18:11:38 +03:00
2019-09-12 10:23:49 +03:00
runTestParams({"-binDir", TestBinDir, "clear"}, &comapareTree);
2019-09-12 17:00:50 +03:00
}
void deploytest::testConfFile() {
TestUtils utils;
2019-04-04 18:11:38 +03:00
2019-09-12 21:42:10 +03:00
QFile::remove(TestBinDir + "/TestConf.json");
2019-10-16 14:25:44 +03:00
QFile::remove(TestBinDir + "/../folder/For/Testing/Deploy/File/TestConf.json");
2019-09-12 17:00:50 +03:00
#ifdef Q_OS_UNIX
auto comapareTree = utils.createTree(
2019-09-16 09:44:19 +03:00
{"./" + DISTRO_DIR + "/bin/TestOnlyC",
2019-09-19 10:25:31 +03:00
"./" + DISTRO_DIR + "/bin/qt.conf",
2019-09-16 09:44:19 +03:00
"./" + DISTRO_DIR + "/bin/QtWidgetsProject",
"./" + DISTRO_DIR + "/bin/TestQMLWidgets",
"./" + DISTRO_DIR + "/TestOnlyC.sh",
"./" + DISTRO_DIR + "/QtWidgetsProject.sh",
"./" + DISTRO_DIR + "/TestQMLWidgets.sh"});
2019-04-04 18:11:38 +03:00
#else
2019-09-12 17:00:50 +03:00
auto comapareTree = utils.createTree(
2019-09-16 09:44:19 +03:00
{"./" + DISTRO_DIR + "/TestOnlyC.exe",
2019-09-23 17:59:36 +03:00
"./" + DISTRO_DIR + "/qt.conf",
2019-09-16 09:44:19 +03:00
"./" + DISTRO_DIR + "/QtWidgetsProject.exe",
2019-09-23 17:59:36 +03:00
"./" + DISTRO_DIR + "/TestQMLWidgets.exe"});
2019-04-04 18:11:38 +03:00
#endif
2019-03-28 19:23:22 +03:00
2019-09-19 10:25:31 +03:00
#ifdef WITH_ALL_TESTS
2019-09-19 11:13:28 +03:00
comapareTree += utils.createTree(
2019-09-19 10:25:31 +03:00
{"./" + DISTRO_DIR + "/bin/quicknanobrowser",
"./" + DISTRO_DIR + "/quicknanobrowser.sh"});
#endif
2019-03-28 19:23:22 +03:00
2019-09-12 17:00:50 +03:00
runTestParams({"-bin", TestBinDir, "clear" ,
"-confFile", TestBinDir + "/TestConf.json"}, &comapareTree);
2019-03-28 19:23:22 +03:00
2019-09-12 17:00:50 +03:00
QVERIFY(QFile::exists(TestBinDir + "/TestConf.json"));
QFile::remove(TestBinDir + "/TestConf.json");
2019-03-28 19:23:22 +03:00
2019-09-12 17:00:50 +03:00
#ifdef Q_OS_UNIX
2019-09-12 21:42:10 +03:00
runTestParams({"-bin", TestBinDir + "TestOnlyC," + TestBinDir + "QtWidgetsProject," + TestBinDir + "TestQMLWidgets",
2019-10-16 18:07:36 +03:00
"clear",
2019-09-12 17:00:50 +03:00
"-confFile", TestBinDir + "/TestConf.json"}, &comapareTree);
#else
2019-09-12 21:42:10 +03:00
runTestParams({"-bin", TestBinDir + "TestOnlyC.exe," + TestBinDir + "QtWidgetsProject.exe," + TestBinDir + "TestQMLWidgets.exe",
2019-10-17 15:42:44 +03:00
"clear" , "-libDir", "L:/never/absalut/path",
2019-09-12 17:00:50 +03:00
"-confFile", TestBinDir + "/TestConf.json"}, &comapareTree);
#endif
2019-09-12 17:00:50 +03:00
QFile confFile(TestBinDir + "/TestConf.json");
QVERIFY(confFile.open(QIODevice::ReadOnly));
2019-09-12 17:00:50 +03:00
auto data = confFile.readAll();
2019-09-12 21:42:10 +03:00
confFile.close();
2019-09-12 17:00:50 +03:00
QJsonDocument doc;
2019-09-12 21:42:10 +03:00
doc = doc.fromJson(data);
2019-09-12 17:00:50 +03:00
QVERIFY(!doc.isNull());
#ifdef Q_OS_UNIX
2019-09-12 21:42:10 +03:00
QVERIFY(data.contains("\"bin\": ["));
QVERIFY(data.contains("./TestOnlyC"));
QVERIFY(data.contains("./QtWidgetsProject"));
QVERIFY(data.contains("./TestQMLWidgets"));
2019-10-16 18:07:36 +03:00
// QVERIFY(data.contains("\"libDir\": \"/never/absalut/path/\""));
2019-09-12 17:00:50 +03:00
QVERIFY(data.contains("\"clear\": true"));
2019-10-17 12:42:55 +03:00
data.insert(data.size() - 2, QString(",\"libDir\": \"/never/absalut/path/\"").toLatin1());
QVERIFY(confFile.open(QIODevice::WriteOnly | QIODevice::Truncate));
confFile.write(data);
2019-10-16 18:07:36 +03:00
confFile.close();
2019-09-12 21:42:10 +03:00
runTestParams({"-confFile", TestBinDir + "/TestConf.json"}, &comapareTree);
2019-04-01 22:03:37 +03:00
#else
QVERIFY(data.contains("\"bin\": ["));
QVERIFY(data.contains("./TestOnlyC.exe"));
QVERIFY(data.contains("./QtWidgetsProject.exe"));
QVERIFY(data.contains("./TestQMLWidgets.exe"));
2019-10-17 15:42:44 +03:00
QVERIFY(data.contains("\"libDir\": \"L:/never/absalut/path\""));
QVERIFY(data.contains("\"clear\": true"));
2019-09-12 21:42:10 +03:00
runTestParams({"-confFile", TestBinDir + "/TestConf.json"}, &comapareTree);
2019-03-28 19:23:22 +03:00
#endif
2019-09-12 10:23:49 +03:00
2019-09-12 21:42:10 +03:00
QVERIFY(QuasarAppUtils::Params::isEndable("clear"));
QVERIFY(QuasarAppUtils::Params::isEndable("bin"));
2019-10-16 18:07:36 +03:00
QVERIFY(QuasarAppUtils::Params::isEndable("libDir"));
#ifdef Q_OS_UNIX
QVERIFY(QuasarAppUtils::Params::getStrArg("libDir") == "/never/absalut/path/");
#else
2019-10-17 15:42:44 +03:00
QVERIFY(QuasarAppUtils::Params::getStrArg("libDir") == "L:/never/absalut/path");
2019-10-16 18:07:36 +03:00
#endif
QFile::remove(TestBinDir + "/TestConf.json");
2019-10-16 14:25:44 +03:00
#ifdef Q_OS_UNIX
runTestParams({"-bin", TestBinDir + "TestOnlyC," + TestBinDir + "QtWidgetsProject," + TestBinDir + "TestQMLWidgets",
"clear" ,
"-confFile", TestBinDir + "/../folder/For/Testing/Deploy/File/TestConf.json"}, &comapareTree);
#else
runTestParams({"-bin", TestBinDir + "TestOnlyC.exe," + TestBinDir + "QtWidgetsProject.exe," + TestBinDir + "TestQMLWidgets.exe",
"clear" ,
"-confFile", TestBinDir + "/../folder/For/Testing/Deploy/File/TestConf.json"}, &comapareTree);
#endif
confFile.setFileName(TestBinDir + "/../folder/For/Testing/Deploy/File/TestConf.json");
QVERIFY(confFile.open(QIODevice::ReadOnly));
data = confFile.readAll();
confFile.close();
doc = doc.fromJson(data);
QVERIFY(!doc.isNull());
#ifdef Q_OS_UNIX
QVERIFY(data.contains("\"bin\": ["));
QVERIFY(data.contains("./../../../../../build/TestOnlyC"));
QVERIFY(data.contains("./../../../../../build/QtWidgetsProject"));
QVERIFY(data.contains("./../../../../../build/TestQMLWidgets"));
QVERIFY(data.contains("\"clear\": true"));
#else
QVERIFY(data.contains("\"bin\": ["));
QVERIFY(data.contains("./../../../../../build/TestOnlyC.exe"));
QVERIFY(data.contains("./../../../../../build/QtWidgetsProject.exe"));
QVERIFY(data.contains("./../../../../../build/TestQMLWidgets.exe"));
QVERIFY(data.contains("\"clear\": true"));
#endif
runTestParams({"-confFile", TestBinDir + "/../folder/For/Testing/Deploy/File/TestConf.json"}, &comapareTree);
QVERIFY(QuasarAppUtils::Params::isEndable("clear"));
QVERIFY(QuasarAppUtils::Params::isEndable("bin"));
QFile::remove(TestBinDir + "/../folder/For/Testing/Deploy/File/TestConf.json");
2019-03-28 19:23:22 +03:00
}
void deploytest::testQt() {
TestUtils utils;
2019-03-29 18:05:55 +03:00
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "TestQMLWidgets";
QString qmake = TestQtDir + "bin/qmake";
#else
QString bin = TestBinDir + "TestQMLWidgets.exe";
QString qmake = TestQtDir + "bin/qmake.exe";
#endif
2019-09-14 15:51:23 +03:00
auto comapareTree = Modules::qmlLibs();
runTestParams({"-bin", bin, "clear" ,
2019-09-14 15:51:23 +03:00
"-qmake", qmake,
"-qmlDir", TestBinDir + "/../TestQMLWidgets"}, &comapareTree);
2019-03-29 18:05:55 +03:00
2019-09-13 18:43:28 +03:00
#ifdef Q_OS_UNIX
bin = TestBinDir + "QtWidgetsProject";
2019-04-04 18:11:38 +03:00
#else
2019-09-14 13:59:11 +03:00
bin = TestBinDir + "QtWidgetsProject.exe";
2019-09-13 18:43:28 +03:00
2019-04-04 18:11:38 +03:00
#endif
2019-09-14 15:51:23 +03:00
comapareTree = Modules::qtLibs();
2019-03-29 18:05:55 +03:00
2019-09-13 18:43:28 +03:00
runTestParams({"-bin", bin, "clear" ,
2019-09-14 15:51:23 +03:00
"-qmake", qmake}, &comapareTree);
2019-03-29 18:05:55 +03:00
2019-09-14 15:51:23 +03:00
comapareTree = Modules::qtWithoutTr();
2019-09-24 16:30:52 +03:00
2019-09-13 18:43:28 +03:00
runTestParams({"-bin", bin, "clear" ,
2019-09-14 15:51:23 +03:00
"-qmake", qmake, "noTranslations"}, &comapareTree);
2019-09-14 15:51:23 +03:00
}
2019-09-28 16:44:39 +03:00
void deploytest::testClear() {
TestUtils utils;
auto compareTree = QSet<QString>{};
runTestParams({"clear"}, &compareTree);
}
2019-09-14 15:51:23 +03:00
void deploytest::testIgnore() {
TestUtils utils;
2019-03-29 18:05:55 +03:00
2019-03-29 23:02:39 +03:00
2019-09-14 15:51:23 +03:00
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "QtWidgetsProject";
QString qmake = TestQtDir + "bin/qmake";
2019-09-26 13:18:10 +03:00
auto comapareTree = utils.createTree(
{
"./" + DISTRO_DIR + "/QtWidgetsProject.sh",
"./" + DISTRO_DIR + "/bin/qt.conf",
"./" + DISTRO_DIR + "/bin/QtWidgetsProject",
});
2019-09-14 15:51:23 +03:00
2019-09-24 16:30:52 +03:00
#else
QString bin = TestBinDir + "QtWidgetsProject.exe";
QString qmake = TestQtDir + "bin/qmake.exe";
2019-09-14 15:51:23 +03:00
auto comapareTree = utils.createTree(
{
2019-09-26 13:18:10 +03:00
"./" + DISTRO_DIR + "/qt.conf",
"./" + DISTRO_DIR + "/QtWidgetsProject.exe",
2019-09-14 15:51:23 +03:00
});
2019-05-14 11:31:13 +03:00
2019-09-26 13:18:10 +03:00
#endif
if (!TestQtDir.contains("Qt5")) {
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "QtWidgetsProject";
QString qmake = TestQtDir + "bin/qmake";
comapareTree += utils.createTree(
{
"./" + DISTRO_DIR + "/lib/libicudata.so",
"./" + DISTRO_DIR + "/lib/libicui18n.so",
"./" + DISTRO_DIR + "/lib/libicuuc.so"
});
#else
QString bin = TestBinDir + "QtWidgetsProject.exe";
QString qmake = TestQtDir + "bin/qmake.exe";
comapareTree += utils.createTree(
2019-11-02 01:00:05 +03:00
{
"./" + DISTRO_DIR + "/libgcc_s_seh-1.dll",
"./" + DISTRO_DIR + "/libstdc++-6.dll",
"./" + DISTRO_DIR + "/libwinpthread-1.dll"
});
2019-09-26 13:18:10 +03:00
#endif
}
2019-05-14 11:31:13 +03:00
2019-09-14 15:51:23 +03:00
runTestParams({"-bin", bin, "clear" ,
"-qmake", qmake,
"-ignore", "Qt5"}, &comapareTree);
2019-03-29 18:05:55 +03:00
2019-09-26 13:18:10 +03:00
#ifdef Q_OS_UNIX
2019-09-14 15:51:23 +03:00
comapareTree = utils.createTree(
{
2019-09-16 09:44:19 +03:00
"./" + DISTRO_DIR + "/QtWidgetsProject.sh",
2019-09-19 11:13:28 +03:00
"./" + DISTRO_DIR + "/bin/qt.conf",
2019-09-16 09:44:19 +03:00
"./" + DISTRO_DIR + "/bin/QtWidgetsProject",
2019-09-14 15:51:23 +03:00
});
2019-03-29 18:05:55 +03:00
2019-09-26 13:18:10 +03:00
auto removeTree = utils.createTree({
"./" + DISTRO_DIR + "/lib/libQt5VirtualKeyboard.so",
});
2019-10-15 13:35:50 +03:00
auto removeTreePlugins = utils.createTree({
"./" + DISTRO_DIR + "/plugins/virtualkeyboard/libqtvirtualkeyboard_hangul.so",
"./" + DISTRO_DIR + "/plugins/virtualkeyboard/libqtvirtualkeyboard_openwnn.so",
"./" + DISTRO_DIR + "/plugins/virtualkeyboard/libqtvirtualkeyboard_pinyin.so",
"./" + DISTRO_DIR + "/plugins/virtualkeyboard/libqtvirtualkeyboard_tcime.so",
"./" + DISTRO_DIR + "/plugins/virtualkeyboard/libqtvirtualkeyboard_thai.so",
"./" + DISTRO_DIR + "/plugins/platforminputcontexts/libqtvirtualkeyboardplugin.so",
"./" + DISTRO_DIR + "/lib/libQt5VirtualKeyboard.so",
});
2019-09-26 13:18:10 +03:00
#else
comapareTree = utils.createTree(
{
"./" + DISTRO_DIR + "/qt.conf",
"./" + DISTRO_DIR + "/QtWidgetsProject.exe",
});
auto removeTree = utils.createTree({
"./" + DISTRO_DIR + "/Qt5VirtualKeyboard.dll",
});
2019-10-17 15:42:44 +03:00
2019-10-15 13:35:50 +03:00
auto removeTreePlugins = utils.createTree({
2019-10-17 15:42:44 +03:00
"./" + DISTRO_DIR + "/plugins/virtualkeyboard/qtvirtualkeyboard_hangul.dll",
"./" + DISTRO_DIR + "/plugins/virtualkeyboard/qtvirtualkeyboard_openwnn.dll",
"./" + DISTRO_DIR + "/plugins/virtualkeyboard/qtvirtualkeyboard_pinyin.dll",
"./" + DISTRO_DIR + "/plugins/virtualkeyboard/qtvirtualkeyboard_tcime.dll",
"./" + DISTRO_DIR + "/plugins/virtualkeyboard/qtvirtualkeyboard_thai.dll",
"./" + DISTRO_DIR + "/plugins/platforminputcontexts/qtvirtualkeyboardplugin.dll",
"./" + DISTRO_DIR + "/Qt5VirtualKeyboard.dll",
2019-10-15 13:35:50 +03:00
});
2019-09-26 13:18:10 +03:00
#endif
2019-09-14 15:51:23 +03:00
runTestParams({"-bin", bin, "clear" ,
"-qmake", qmake,
"-ignoreEnv", TestQtDir + "/lib," + TestQtDir + "/bin" }, &comapareTree);
2019-09-26 13:18:10 +03:00
2019-09-14 15:51:23 +03:00
comapareTree = Modules::qtLibs() - removeTree;
2019-09-14 15:51:23 +03:00
runTestParams({"-bin", bin, "clear" ,
"-qmake", qmake,
"-ignore", "VirtualKeyboard"}, &comapareTree);
2019-09-13 18:43:28 +03:00
2019-10-15 13:35:50 +03:00
comapareTree = Modules::qtLibs() - removeTreePlugins;
runTestParams({"-bin", bin, "clear" ,
"-qmake", qmake,
"-ignore", "VirtualKeyboard,virtualkeyboard"}, &comapareTree);
2019-09-12 10:23:49 +03:00
}
2019-09-14 15:51:23 +03:00
void deploytest::testLibDir() {
TestUtils utils;
2019-04-04 18:11:38 +03:00
2019-09-14 15:51:23 +03:00
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "TestOnlyC";
2019-09-28 13:06:43 +03:00
QString extraPath = "/usr/lib,/lib";
2019-04-04 18:11:38 +03:00
2019-09-24 15:11:30 +03:00
auto comapareTree = utils.createTree(
{
2019-09-24 16:30:52 +03:00
"./" + DISTRO_DIR + "/TestOnlyC.sh",
"./" + DISTRO_DIR + "/bin/qt.conf",
"./" + DISTRO_DIR + "/bin/TestOnlyC"
2019-09-24 15:11:30 +03:00
});
2019-09-26 13:18:10 +03:00
#else
QString bin = TestBinDir + "TestOnlyC.exe";
QString extraPath = TestQtDir;
auto comapareTree = utils.createTree(
{
"./" + DISTRO_DIR + "/qt.conf",
"./" + DISTRO_DIR + "/TestOnlyC.exe",
});
#endif
2019-09-14 15:51:23 +03:00
runTestParams({"-bin", bin, "clear" ,
"-libDir", extraPath,
}, &comapareTree);
2019-09-26 13:18:10 +03:00
#ifdef Q_OS_UNIX
2019-09-14 15:51:23 +03:00
comapareTree = utils.createTree(
{
2019-09-16 09:44:19 +03:00
"./" + DISTRO_DIR + "/TestOnlyC.sh",
2019-09-19 11:13:28 +03:00
"./" + DISTRO_DIR + "/bin/qt.conf",
2019-09-16 09:44:19 +03:00
"./" + DISTRO_DIR + "/bin/TestOnlyC",
"./" + DISTRO_DIR + "/lib/libstdc++.so",
2019-09-27 18:58:08 +03:00
"./" + DISTRO_DIR + "/lib/libgcc_s.so",
"./" + DISTRO_DIR + "/lib/ld-linux-x86-64.so",
"./" + DISTRO_DIR + "/lib/libc.so",
"./" + DISTRO_DIR + "/lib/libm.so",
2019-09-14 15:51:23 +03:00
});
2019-11-05 13:17:52 +03:00
auto comapareTreeExtraLib = utils.createTree(
{
"./" + DISTRO_DIR + "/TestOnlyC.sh",
"./" + DISTRO_DIR + "/bin/qt.conf",
"./" + DISTRO_DIR + "/bin/TestOnlyC",
"./" + DISTRO_DIR + "/lib/libstdc++.so",
"./" + DISTRO_DIR + "/lib/libgcc_s.so"
});
2019-09-26 13:18:10 +03:00
#else
comapareTree = utils.createTree(
{
"./" + DISTRO_DIR + "/qt.conf",
"./" + DISTRO_DIR + "/TestOnlyC.exe",
"./" + DISTRO_DIR + "/libgcc_s_seh-1.dll",
"./" + DISTRO_DIR + "/libwinpthread-1.dll",
"./" + DISTRO_DIR + "/libstdc++-6.dll",
});
2019-11-05 13:17:52 +03:00
auto comapareTreeExtraLib = utils.createTree(
{
"./" + DISTRO_DIR + "/qt.conf",
"./" + DISTRO_DIR + "/TestOnlyC.exe",
"./" + DISTRO_DIR + "/libgcc_s_seh-1.dll",
"./" + DISTRO_DIR + "/libstdc++-6.dll",
});
2019-09-26 13:18:10 +03:00
#endif
2019-09-14 15:51:23 +03:00
runTestParams({"-bin", bin, "clear" ,
"-libDir", extraPath,
2019-09-14 15:59:46 +03:00
"-recursiveDepth", "5"}, &comapareTree, true);
2019-11-05 13:17:52 +03:00
runTestParams({"-bin", bin, "clear" ,
2019-11-05 16:52:22 +03:00
"-extraLibs", "stdc,gcc"}, &comapareTreeExtraLib, true);
2019-11-05 13:17:52 +03:00
2019-09-14 15:51:23 +03:00
}
2019-09-14 15:51:23 +03:00
void deploytest::testExtraPlugins() {
TestUtils utils;
2019-03-29 23:02:39 +03:00
2019-09-14 15:51:23 +03:00
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "QtWidgetsProject";
QString extraPath = "/usr/lib";
QString qmake = TestQtDir + "bin/qmake";
2019-03-29 23:02:39 +03:00
2019-09-26 13:18:10 +03:00
auto pluginTree = utils.createTree(
{
"./" + DISTRO_DIR + "/bin/qt.conf",
"./" + DISTRO_DIR + "/plugins/sqldrivers/libqsqlodbc.so",
"./" + DISTRO_DIR + "/plugins/sqldrivers/libqsqlpsql.so",
"./" + DISTRO_DIR + "/plugins/sqldrivers/libqsqlite.so",
"./" + DISTRO_DIR + "/lib/libQt5Sql.so",
2019-04-04 18:11:38 +03:00
2019-09-26 13:18:10 +03:00
});
2019-04-04 18:11:38 +03:00
#else
2019-09-14 15:51:23 +03:00
QString bin = TestBinDir + "QtWidgetsProject.exe";
QString extraPath = "/usr/lib";
QString qmake = TestQtDir + "bin/qmake.exe";
2019-03-29 18:05:55 +03:00
2019-09-26 13:18:10 +03:00
auto pluginTree = utils.createTree(
{
"./" + DISTRO_DIR + "/qt.conf",
"./" + DISTRO_DIR + "/plugins/sqldrivers/qsqlmysql.dll",
"./" + DISTRO_DIR + "/plugins/sqldrivers/qsqlodbc.dll",
"./" + DISTRO_DIR + "/plugins/sqldrivers/qsqlite.dll",
"./" + DISTRO_DIR + "/plugins/sqldrivers/qsqlpsql.dll",
"./" + DISTRO_DIR + "/Qt5Sql.dll",
2019-04-04 18:11:38 +03:00
2019-09-26 13:18:10 +03:00
});
2019-04-04 18:11:38 +03:00
#endif
2019-09-14 15:51:23 +03:00
auto comapareTree = Modules::qtLibs();
2019-03-29 23:02:39 +03:00
2019-09-14 15:51:23 +03:00
runTestParams({"-bin", bin, "clear" ,
"-qmake", qmake,
}, &comapareTree);
2019-03-29 23:02:39 +03:00
2019-09-14 15:51:23 +03:00
comapareTree = comapareTree + pluginTree;
2019-03-29 23:02:39 +03:00
2019-09-14 15:51:23 +03:00
runTestParams({"-bin", bin, "clear" ,
"-qmake", qmake,
"-extraPlugin", "sqldrivers"}, &comapareTree);
}
2019-05-14 11:31:13 +03:00
2019-09-14 15:51:23 +03:00
void deploytest::testTargetDir() {
TestUtils utils;
2019-05-14 11:31:13 +03:00
2019-09-14 15:51:23 +03:00
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "TestOnlyC";
2019-09-24 16:30:52 +03:00
auto comapareTree = utils.createTree(
{"./" + DISTRO_DIR + "Z/bin/TestOnlyC",
"./" + DISTRO_DIR + "Z/bin/qt.conf",
"./" + DISTRO_DIR + "Z/TestOnlyC.sh"});
2019-09-26 13:18:10 +03:00
#else
QString bin = TestBinDir + "TestOnlyC.exe";
auto comapareTree = utils.createTree(
{"./" + DISTRO_DIR + "Z/TestOnlyC.exe",
"./" + DISTRO_DIR + "Z/qt.conf"});
#endif
2019-09-14 15:51:23 +03:00
runTestParams({"-bin", bin, "clear" ,
2019-09-16 09:44:19 +03:00
"-targetDir", "./" + DISTRO_DIR + "Z"
2019-09-14 15:51:23 +03:00
}, &comapareTree);
2019-03-29 18:05:55 +03:00
}
2019-09-14 15:51:23 +03:00
void deploytest::testSystemLib() {
TestUtils utils;
2019-01-27 15:37:19 +03:00
2019-09-14 15:51:23 +03:00
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "TestOnlyC";
2019-09-25 18:13:04 +03:00
auto comapareTree = utils.createTree(
{
"./" + DISTRO_DIR + "/TestOnlyC.sh",
"./" + DISTRO_DIR + "/bin/qt.conf",
"./" + DISTRO_DIR + "/bin/TestOnlyC",
"./" + DISTRO_DIR + "/lib/libgcc_s.so",
"./" + DISTRO_DIR + "/lib/libstdc++.so"
});
2019-01-27 15:37:19 +03:00
2019-09-24 16:30:52 +03:00
#else
QString bin = TestBinDir + "TestOnlyC.exe";
2019-09-14 15:51:23 +03:00
auto comapareTree = utils.createTree(
{
2019-09-26 13:18:10 +03:00
"./" + DISTRO_DIR + "/TestOnlyC.exe",
"./" + DISTRO_DIR + "/libgcc_s_seh-1.dll",
"./" + DISTRO_DIR + "/libstdc++-6.dll",
"./" + DISTRO_DIR + "/libwinpthread-1.dll",
"./" + DISTRO_DIR + "/qt.conf"
2019-09-14 15:51:23 +03:00
});
2019-09-25 18:13:04 +03:00
#endif
2019-09-14 15:51:23 +03:00
runTestParams({"-bin", bin, "clear" ,
"deploySystem"
2019-09-14 15:59:46 +03:00
}, &comapareTree, true);
2019-01-27 15:37:19 +03:00
2019-09-14 15:51:23 +03:00
#ifdef Q_OS_UNIX
2019-01-27 15:37:19 +03:00
2019-09-16 09:44:19 +03:00
QFile file("./" + DISTRO_DIR + "/TestOnlyC.sh");
2019-01-27 15:37:19 +03:00
2019-09-14 15:51:23 +03:00
QVERIFY(file.open(QIODevice::ReadOnly));
2019-01-27 15:37:19 +03:00
2019-09-14 15:51:23 +03:00
auto runScript = file.readAll();
file.close();
2019-01-27 15:37:19 +03:00
2019-09-24 16:30:52 +03:00
QVERIFY(!runScript.contains("export LD_PRELOAD="));
comapareTree = utils.createTree(
{
"./" + DISTRO_DIR + "/TestOnlyC.sh",
"./" + DISTRO_DIR + "/bin/qt.conf",
"./" + DISTRO_DIR + "/bin/TestOnlyC",
"./" + DISTRO_DIR + "/lib/libgcc_s.so",
"./" + DISTRO_DIR + "/lib/ld-linux-x86-64.so",
"./" + DISTRO_DIR + "/lib/libc.so",
"./" + DISTRO_DIR + "/lib/libm.so",
"./" + DISTRO_DIR + "/lib/libstdc++.so"
});
runTestParams({"-bin", bin, "clear" ,
"deploySystem-with-libc"
}, &comapareTree, true);
file.setFileName("./" + DISTRO_DIR + "/TestOnlyC.sh");
QVERIFY(file.open(QIODevice::ReadOnly));
runScript = file.readAll();
file.close();
2019-09-14 15:51:23 +03:00
QVERIFY(runScript.contains("export LD_PRELOAD="));
2019-09-24 16:30:52 +03:00
2019-09-24 15:11:30 +03:00
#endif
2019-09-24 16:30:52 +03:00
}
2019-09-24 15:11:30 +03:00
2019-09-24 16:30:52 +03:00
void deploytest::testOutDirs() {
TestUtils utils;
2019-01-27 15:37:19 +03:00
2019-09-24 16:30:52 +03:00
#ifdef Q_OS_UNIX
2019-09-24 18:21:12 +03:00
QString bin = TestBinDir + "TestQMLWidgets";
QString qmake = TestQtDir + "bin/qmake";
2019-09-24 15:11:30 +03:00
#else
2019-09-24 18:21:12 +03:00
QString bin = TestBinDir + "TestQMLWidgets.exe";
QString qmake = TestQtDir + "bin/qmake.exe";
2019-09-24 16:30:52 +03:00
#endif
2019-09-24 18:21:12 +03:00
auto comapareTree = Modules::outTestLibs();
2019-01-27 15:37:19 +03:00
2019-09-24 16:30:52 +03:00
runTestParams({"-bin", bin, "clear" ,
2019-09-24 18:21:12 +03:00
"-binOut", "/lol",
"-libOut", "/lolLib",
"-trOut", "/lolTr",
"-pluginOut", "/p",
"-qmlOut", "/q",
"-qmake", qmake,
"-qmlDir", TestBinDir + "/../TestQMLWidgets"
2019-09-25 13:23:07 +03:00
}, &comapareTree);
2019-09-24 16:30:52 +03:00
2019-09-25 12:32:05 +03:00
QFile file;
file.setFileName("./" + DISTRO_DIR + "/lol/qt.conf");
QVERIFY(file.open(QIODevice::ReadOnly));
auto runScript = file.readAll();
file.close();
QVERIFY(runScript.contains("Prefix= ./../"));
QVERIFY(runScript.contains("Libraries= ./lolLib/"));
QVERIFY(runScript.contains("Plugins= ./p/"));
QVERIFY(runScript.contains("Imports= ./q/"));
QVERIFY(runScript.contains("Translations= ./lolTr/"));
QVERIFY(runScript.contains("Qml2Imports= ./q/"));
2019-09-25 18:13:04 +03:00
#ifdef Q_OS_WIN
runTestParams({"-bin", bin, "clear" ,
2019-09-26 13:18:10 +03:00
"-binOut", "/lol",
2019-09-25 18:13:04 +03:00
"-libOut", "/lolLib",
"-trOut", "/lolTr",
"-pluginOut", "/p",
"-qmlOut", "/q",
"-qmake", qmake,
"-qmlDir", TestBinDir + "/../TestQMLWidgets"
}, &comapareTree);
file.setFileName( "./" + DISTRO_DIR + "/TestQMLWidgets.bat");
QVERIFY(file.open(QIODevice::ReadOnly));
runScript = file.readAll();
file.close();
2019-09-26 13:18:10 +03:00
QVERIFY(runScript.contains("SET BASE_DIR=%~dp0"));
QVERIFY(runScript.contains("SET PATH=%BASE_DIR%\\\\lolLib\\;%PATH%"));
QVERIFY(runScript.contains("start \"\" \"%BASE_DIR%\\\\lol\\TestQMLWidgets.exe\" %*"));
2019-09-25 18:13:04 +03:00
#endif
2019-01-27 15:37:19 +03:00
}
2019-01-26 15:34:39 +03:00
QTEST_APPLESS_MAIN(deploytest)
#include "tst_deploytest.moc"