4
1
mirror of https://github.com/QuasarApp/CQtDeployer.git synced 2025-05-03 21:19:34 +00:00

separate all tests to multiple files

This commit is contained in:
Andrei Yankovich 2022-08-13 12:36:41 +03:00
parent ba8baf2d75
commit 9a3fac2861
59 changed files with 2708 additions and 27 deletions

119
tests/units/checkqttest.cpp Normal file

@ -0,0 +1,119 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "checkqttest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void CheckQtTest::test() {
Deploy *deployer = new Deploy();
QuasarAppUtils::Params::parseParams({"-bin", TestBinDir, "clear",
"noCheckRPATH", "noCheckPATH", "noQt"});
QVERIFY(deployer->prepare());
auto cases = QList<QPair<QString, QtMajorVersion>>{
{TestQtDir + "/", QtMajorVersion::NoQt},
{TestQtDir + "", QtMajorVersion::NoQt},
{TestQtDir + "/bin/file1", QtMajorVersion::NoQt},
{TestQtDir + "/lib/file12.so", QtMajorVersion::NoQt},
{TestQtDir + "/resurces/file13.dll", QtMajorVersion::NoQt},
{TestQtDir + "/libexec/f", QtMajorVersion::NoQt},
{TestQtDir + "/mkspecs", QtMajorVersion::NoQt},
{TestQtDir + "/qml", QtMajorVersion::NoQt},
{TestQtDir + "/plugins", QtMajorVersion::NoQt},
{TestQtDir + "/file", QtMajorVersion::NoQt},
{TestQtDir + "\\", QtMajorVersion::NoQt},
{TestQtDir + "", QtMajorVersion::NoQt},
{TestQtDir + "\\bin\\file1", QtMajorVersion::NoQt},
{TestQtDir + "\\lib\\file12", QtMajorVersion::NoQt},
{TestQtDir + "\\resurces\\file13", QtMajorVersion::NoQt},
{TestQtDir + "\\libexec\\f.so", QtMajorVersion::NoQt},
{TestQtDir + "\\mkspecs.dll", QtMajorVersion::NoQt},
{TestQtDir + "\\qml", QtMajorVersion::NoQt},
{TestQtDir + "\\plugins", QtMajorVersion::NoQt},
{TestQtDir + "\\file", QtMajorVersion::NoQt},
};
for (const auto &i: qAsConst(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, QtMajorVersion>>{
{TestQtDir + "/", QtMajorVersion::NoQt},
{TestQtDir + "", QtMajorVersion::NoQt},
{TestQtDir + "/bin/file1", QtMajorVersion::NoQt},
{TestQtDir + "/lib/file12", QtMajorVersion::NoQt},
{TestQtDir + "/lib/file12", QtMajorVersion::NoQt},
{TestQtDir + "/mkspecs", QtMajorVersion::NoQt},
{TestQtDir + "/qml", QtMajorVersion::NoQt},
{TestQtDir + "/plugins", QtMajorVersion::NoQt},
{TestQtDir + "/file", QtMajorVersion::NoQt},
{TestQtDir + "\\", QtMajorVersion::NoQt},
{TestQtDir + "", QtMajorVersion::NoQt},
{TestQtDir + "\\lib\\file12", QtMajorVersion::NoQt},
{TestQtDir + "\\libexec\\fQt", QtMajorVersion::NoQt},
{TestQtDir + "\\mkspecs", QtMajorVersion::NoQt},
{TestQtDir + "\\qml", QtMajorVersion::NoQt},
{TestQtDir + "\\plugins", QtMajorVersion::NoQt},
{TestQtDir + "\\file", QtMajorVersion::NoQt},
{TestQtDir + "/bin/file1Qt4.so", QtMajorVersion::Qt4},
{TestQtDir + "/resources/Qt4file13.so", QtMajorVersion::Qt4},
{TestQtDir + "/libexec/Qt4f.dll", QtMajorVersion::Qt4},
{TestQtDir + "\\bin\\Qt4file1.dll", QtMajorVersion::Qt4},
{TestQtDir + "\\resources\\fileQt413.dll", QtMajorVersion::Qt4},
{TestQtDir + "/bin/file1Qt5.so", QtMajorVersion::Qt5},
{TestQtDir + "/resources/Qt5file13.so", QtMajorVersion::Qt5},
{TestQtDir + "/libexec/Qt5f.dll", QtMajorVersion::Qt5},
{TestQtDir + "\\bin\\Qt5file1.dll", QtMajorVersion::Qt5},
{TestQtDir + "\\resources\\fileQt513.dll", QtMajorVersion::Qt5},
{TestQtDir + "/bin/file1Qt6.so", QtMajorVersion::Qt6},
{TestQtDir + "/resources/Qt6file13.so", QtMajorVersion::Qt6},
{TestQtDir + "/libexec/Qt6f.dll", QtMajorVersion::Qt6},
{TestQtDir + "\\bin\\Qt6file1.dll", QtMajorVersion::Qt6},
{TestQtDir + "\\resources\\fileQt613.dll", QtMajorVersion::Qt6},
};
for (const auto &i: qAsConst(cases)) {
auto dexription = QString("The isQtLib(%0) function should be return %1").arg(
i.first).arg(i.second);
QVERIFY2(DeployCore::isQtLib(i.first) == i.second, dexription.toLatin1().data());
}
delete deployer;
}

23
tests/units/checkqttest.h Normal file

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef CHECK_QT_TEST_H
#define CHECK_QT_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class CheckQtTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // CHECK_QT_TEST_H

25
tests/units/cleartest.cpp Normal file

@ -0,0 +1,25 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "cleartest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void ClearTest::test() {
TestUtils utils;
auto compareTree = QSet<QString>{};
runTestParams({"clear"}, &compareTree);
}

23
tests/units/cleartest.h Normal file

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef CLEAR_TEST_H
#define CLEAR_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class ClearTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // CLEAR_TEST_H

@ -0,0 +1,242 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "confifiletest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void ConfFileTest::test() {
TestUtils utils;
QFile::remove(TestBinDir + "/TestConf.json");
QFile::remove(TestBinDir + "/../folder/For/Testing/Deploy/File/TestConf.json");
#ifdef Q_OS_UNIX
auto comapareTree = utils.createTree(
{"./" + DISTRO_DIR + "/bin/TestOnlyC",
"./" + DISTRO_DIR + "/bin/qt.conf",
"./" + DISTRO_DIR + "/TestOnlyC.sh"});
#else
auto comapareTree = utils.createTree(
{"./" + DISTRO_DIR + "/TestOnlyC.exe",
"./" + DISTRO_DIR + "/TestOnlyC.bat",
"./" + DISTRO_DIR + "/qt.conf"});
#endif
#ifdef Q_OS_UNIX
runTestParams({"-bin", TestBinDir + "TestOnlyC", "clear" , "noCheckRPATH", "noCheckPATH", "noQt",
"-confFile", TestBinDir + "/TestConf.json"}, &comapareTree);
#else
runTestParams({"-bin", TestBinDir + "TestOnlyC.exe", "clear" , "noCheckRPATH", "noCheckPATH", "noQt",
"-confFile", TestBinDir + "/TestConf.json"}, &comapareTree);
#endif
QVERIFY(QFile::exists(TestBinDir + "/TestConf.json"));
QFile::remove(TestBinDir + "/TestConf.json");
#ifdef Q_OS_UNIX
comapareTree += utils.createTree(
{"./" + DISTRO_DIR + "/bin/TestCPPOnly",
"./" + DISTRO_DIR + "/TestCPPOnly.sh"});
#else
comapareTree += utils.createTree(
{"./" + DISTRO_DIR + "/TestCPPOnly.exe",
"./" + DISTRO_DIR + "/TestCPPOnly.bat"});
#endif
#ifdef Q_OS_UNIX
runTestParams({"-bin", TestBinDir + "TestOnlyC," + TestBinDir + "TestCPPOnly",
"clear", "noCheckRPATH", "noCheckPATH", "noQt",
"-confFile", TestBinDir + "/TestConf.json"}, &comapareTree);
#else
runTestParams({"-bin", TestBinDir + "TestOnlyC.exe," + TestBinDir + "TestCPPOnly.exe",
"clear" , "-libDir", "L:/never/absalut/path", "noCheckPATH", "noQt",
"-confFile", TestBinDir + "/TestConf.json"}, &comapareTree);
#endif
QFile confFile(TestBinDir + "/TestConf.json");
QVERIFY(confFile.open(QIODevice::ReadOnly));
auto data = confFile.readAll();
confFile.close();
QJsonDocument doc;
doc = doc.fromJson(data);
QVERIFY(!doc.isNull());
#ifdef Q_OS_UNIX
QVERIFY(data.contains("\"bin\": ["));
QVERIFY(data.contains("./TestOnlyC"));
QVERIFY(data.contains("./TestCPPOnly"));
QVERIFY(data.contains("\"clear\": true"));
data.insert(data.size() - 2, QString(",\"libDir\": \"/never/absalut/path/\"").toLatin1());
QVERIFY(confFile.open(QIODevice::WriteOnly | QIODevice::Truncate));
confFile.write(data);
confFile.close();
runTestParams({"-confFile", TestBinDir + "/TestConf.json"}, &comapareTree);
#else
QVERIFY(data.contains("\"bin\": ["));
QVERIFY(data.contains("./TestOnlyC.exe"));
QVERIFY(data.contains("./TestCPPOnly.exe"));
QVERIFY(data.contains("\"libDir\": \"L:/never/absalut/path\""));
QVERIFY(data.contains("\"clear\": true"));
runTestParams({"-confFile", TestBinDir + "/TestConf.json"}, &comapareTree);
#endif
QVERIFY(QuasarAppUtils::Params::isEndable("clear"));
QVERIFY(QuasarAppUtils::Params::isEndable("bin"));
QVERIFY(QuasarAppUtils::Params::isEndable("libDir"));
#ifdef Q_OS_UNIX
QVERIFY(QuasarAppUtils::Params::getArg("libDir") == "/never/absalut/path/");
#else
QVERIFY(QuasarAppUtils::Params::getArg("libDir") == "L:/never/absalut/path");
#endif
QFile::remove(TestBinDir + "/TestConf.json");
#ifdef Q_OS_UNIX
runTestParams({"-bin", TestBinDir + "TestOnlyC," + TestBinDir + "TestCPPOnly",
"clear" , "noCheckRPATH", "noCheckPATH", "noQt",
"-confFile", TestBinDir + "/../folder/For/Testing/Deploy/File/TestConf.json"}, &comapareTree);
#else
runTestParams({"-bin", TestBinDir + "TestOnlyC.exe," + TestBinDir + "TestCPPOnly.exe",
"clear" , "noCheckPATH", "noQt",
"-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/TestCPPOnly"));
QVERIFY(data.contains("\"clear\": true"));
QString qmake = TestQtDir + "bin/qmake";
#else
QVERIFY(data.contains("\"bin\": ["));
QVERIFY(data.contains("./../../../../../build/TestOnlyC.exe"));
QVERIFY(data.contains("./../../../../../build/TestCPPOnly.exe"));
QVERIFY(data.contains("\"clear\": true"));
QString qmake = TestQtDir + "bin/qmake.exe";
#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");
// Test generar string in confFile
comapareTree = TestModule.qtLibs();
comapareTree = TestModule.ignoreFilter(comapareTree, "/plugins/p");
#ifdef Q_OS_UNIX
comapareTree -= utils.createTree(
{
"./" + DISTRO_DIR + "/lib/libQt5EglFSDeviceIntegration.so",
});
auto bin = TestBinDir + "QtWidgetsProject";
#else
comapareTree -= utils.createTree(
{
"./" + DISTRO_DIR + "/Qt5DBus.dll"
});
auto bin = TestBinDir + "QtWidgetsProject.exe";
#endif
runTestParams({"-bin", bin,
"-qmake", qmake,
"clear",
"-ignore", "/plugins/p",
"-confFile", TestBinDir + "/TestConf.json"}, &comapareTree);
runTestParams({"-confFile", TestBinDir + "/TestConf.json"}, &comapareTree);
QFile::remove(TestBinDir + "/TestConf.json");
#ifdef Q_OS_UNIX
QFile f("./" + DISTRO_DIR + "/bin/TestOnlyC");
comapareTree = utils.createTree(
{
"./" + DISTRO_DIR + "/package/TestOnlyC.sh",
"./" + DISTRO_DIR + "/package/bin/TestOnlyC",
"./" + DISTRO_DIR + "/package/bin/qt.conf"
});
QString target1 = TestBinDir + "TestOnlyC";
#else
QFile f("./" + DISTRO_DIR + "/TestOnlyC.exe");
comapareTree = utils.createTree(
{"./" + DISTRO_DIR + "/package/TestOnlyC.exe",
"./" + DISTRO_DIR + "/package/TestOnlyC.bat",
"./" + DISTRO_DIR + "/package/qt.conf"});
QString target1 = TestBinDir + "TestOnlyC.exe";
#endif
bin = target1;
runTestParams({"-bin", bin, "force-clear",
"-targetPackage", "package;TestOn",
"-confFile", TestBinDir + "/../folder/For/Testing/Deploy/File/TestConf.json"}, &comapareTree);
runTestParams({"-confFile", TestBinDir + "/../folder/For/Testing/Deploy/File/TestConf.json"},
&comapareTree);
QFile::remove(TestBinDir + "/../folder/For/Testing/Deploy/File/TestConf.json");
auto file = "testCase.json";
#ifdef Q_OS_UNIX
bin = TestBinDir + "QtWidgetsProject," + TestBinDir + "TestOnlyC";
#else
bin = TestBinDir + "QtWidgetsProject.exe," + TestBinDir + "TestOnlyC.exe";
#endif
QVERIFY(utils.deployFile(":/testResurces/testRes/testMultiPackageConfig.json", file,
{{"$BIN_DIR", bin.toLatin1()}}));
comapareTree = TestModule.onlyC(DISTRO_DIR + "/Dstro1") +
TestModule.qtLibs(DISTRO_DIR + "/Dstro2");
runTestParams({"-confFile", file},
&comapareTree);
QFile::remove(TestBinDir + "/TestConf.json");
QFile::remove(TestBinDir + "/../folder/For/Testing/Deploy/File/TestConf.json");
}

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef CONF_FILE_TEST_H
#define CONF_FILE_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class ConfFileTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // CONF_FILE_TEST_H

@ -0,0 +1,56 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "customplatformtest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void CustomPlatformTest::test() {
TestUtils utils;
auto compareTree = TestModule.onlyC();
#ifdef Q_OS_UNIX
QString bin = {TestBinDir + "TestOnlyC"};
QString platform = "linux_x86_64";
#else
QString bin = {TestBinDir + "TestOnlyC.exe"};
QString platform = "win_x86_64";
compareTree = utils.createTree(
{
"./" + DISTRO_DIR + "/TestOnlyC.exe",
"./" + DISTRO_DIR + "/TestOnlyC.bat",
"./" + DISTRO_DIR + "/qt.conf"
}
);
#endif
runTestParams({
"-bin", bin,
"clear",
"-platform", platform,
}, &compareTree
);
runTestParams({
"-bin", bin,
"clear",
"-platform", "GeneralFile",
}, nullptr, false, false, exitCodes::PrepareError
);
}

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef CUSTOM_PLATFORM_TEST_H
#define CUSTOM_PLATFORM_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class CustomPlatformTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // CUSTOM_PLATFORM_TEST_H

@ -0,0 +1,69 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "customscripttest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void CustomScriptTest::test() {
TestUtils utils;
#ifdef Q_OS_UNIX
QFile f("./" + DISTRO_DIR + "/bin/TestOnlyC");
auto comapareTree = utils.createTree(
{"./" + DISTRO_DIR + "/bin/TestOnlyC",
"./" + DISTRO_DIR + "/bin/qt.conf",
"./" + DISTRO_DIR + "/TestOnlyC.sh"});
QString bin = TestBinDir + "TestOnlyC";
QString scriptPath = "./" + DISTRO_DIR + "/TestOnlyC.sh";
#else
QFile f("./" + DISTRO_DIR + "/TestOnlyC.exe");
auto comapareTree = utils.createTree(
{"./" + DISTRO_DIR + "/TestOnlyC.exe",
"./" + DISTRO_DIR + "/TestOnlyC.bat",
"./" + DISTRO_DIR + "/qt.conf"});
QString bin = TestBinDir + "TestOnlyC.exe";
QString scriptPath = "./" + DISTRO_DIR + "/TestOnlyC.bat";
#endif
runTestParams({"-bin", bin, "force-clear", "noOverwrite", "-libOut", "lib"}, &comapareTree);
QFile script(scriptPath);
QVERIFY(script.open(QIODevice::ReadOnly));
auto scriptText = script.readAll();
QVERIFY(!scriptText.contains("Begin Custom Script"));
script.close();
runTestParams({"-bin", bin, "force-clear", "noOverwrite",
"-libOut", "lib",
"-customScript", "echo 'this is test script'"}, &comapareTree);
QVERIFY(script.open(QIODevice::ReadOnly));
scriptText = script.readAll();
QVERIFY(scriptText.contains("Begin Custom Script"));
QVERIFY(scriptText.contains("echo 'this is test script'"));
QVERIFY(scriptText.contains("End Custom Script"));
script.close();
}

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef CUSTOM_SCRIPT_TEST_H
#define CUSTOM_SCRIPT_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class CustomScriptTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // CUSTOM_SCRIPT_TEST_H

@ -0,0 +1,20 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "customtest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void CustomTest::test() {
//runTestParams({"-confFile", "",
// "qifFromSystem"});
}

23
tests/units/customtest.h Normal file

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef CUSTOM_TEST_H
#define CUSTOM_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class CustomTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // CUSTOM_TEST_H

@ -0,0 +1,62 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "distrostructtest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void DistroStructTest::test() {
DistroStruct distro;
auto cases = QList<QPair<QString,QString>>{
{"", "/"},
{"/", "/"},
{"/res","/../"},
{"/res/","/../"},
{"/res/type","/../../"},
{"/res/type/","/../../"},
{"res/type","../../"},
{"res/type/","../../"},
{"res//type/","../../"},
{"res////type/","../../"},
{"//res///type/////","/../../"},
{"\\", "/"},
{"\\res","/../"},
{"\\res\\","/../"},
{"\\res\\type","/../../"},
{"\\res\\type\\","/../../"},
{"res\\type","../../"},
{"res\\type\\","../../"},
{"res\\\\type\\","../../"},
{"res\\\\\\\\type\\","../../"},
{"\\\\res\\\\\\type\\\\\\\\\\","/../../"},
};
for (const auto &i: qAsConst(cases)) {
if (distro.getRelativePath(i.first) != i.second)
QVERIFY(false);
}
distro = DistroStruct();
distro.setTrOutDir("/tr/");
QVERIFY(distro.getTrOutDir() == "/tr/");
distro.setTrOutDir("/tr");
QVERIFY(distro.getTrOutDir() == "/tr/");
distro.setTrOutDir("tr");
QVERIFY(distro.getTrOutDir() == "/tr/");
}

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef DISTRO_STRUCT_TEST_H
#define DISTRO_STRUCT_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class DistroStructTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // DISTRO_STRUCT_TEST_H

@ -0,0 +1,51 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "extradatatest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void ExtraDataTest::test() {
TestUtils utils;
#ifdef Q_OS_UNIX
auto comapareTree = utils.createTree(
{"./" + DISTRO_DIR + "/build/TestOnlyC",
"./" + DISTRO_DIR + "/build/TestCPPOnly",
"./" + DISTRO_DIR + "/build/QtWidgetsProject",
"./" + DISTRO_DIR + "/build/TestQMLWidgets",
"./" + DISTRO_DIR + "/build/basic",
"./" + DISTRO_DIR + "/build/quicknanobrowser",
"./" + DISTRO_DIR + "/build/webui"});
#else
auto comapareTree = utils.createTree(
{"./" + DISTRO_DIR + "/build/TestOnlyC.exe",
"./" + DISTRO_DIR + "/build/TestCPPOnly.exe",
"./" + DISTRO_DIR + "/build/QtWidgetsProject.exe",
"./" + DISTRO_DIR + "/build/TestQMLWidgets.exe",
"./" + DISTRO_DIR + "/build/basic.exe"});
#endif
runTestParams({"-extraData", TestBinDir, "clear",
"noCheckRPATH", "noCheckPATH", "noQt"}, &comapareTree);
comapareTree = TestModule.replace(comapareTree, {
{"DistributionKit/build",
"DistributionKit/myExtraData/build"}});
runTestParams({"-extraData", TestBinDir, "clear",
"noCheckRPATH", "noCheckPATH", "noQt",
"-extraDataOut", "myExtraData"}, &comapareTree);
}

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef EXTRA_DATA_TEST_H
#define EXTRA_DATA_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class ExtraDataTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // EXTRA_DATA_TEST_H

@ -0,0 +1,84 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "extrapluginstest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void ExtraPluginTest::test() {
TestUtils utils;
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "QtWidgetsProject";
QString qmake = TestQtDir + "bin/qmake";
auto pluginTree = utils.createTree(
{
"./" + DISTRO_DIR + "/plugins/sqldrivers/libqsqlodbc.so",
"./" + DISTRO_DIR + "/plugins/sqldrivers/libqsqlpsql.so",
"./" + DISTRO_DIR + "/plugins/sqldrivers/libqsqlite.so",
"./" + DISTRO_DIR + "/lib/libQt5Sql.so",
"./" + DISTRO_DIR + "/lib/libpq.so",
"./" + DISTRO_DIR + "/lib/libcrypto.so",
"./" + DISTRO_DIR + "/lib/libssl.so",
});
#else
QString bin = TestBinDir + "QtWidgetsProject.exe";
QString qmake = TestQtDir + "bin/qmake.exe";
auto pluginTree = utils.createTree(
{
"./" + 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",
"./" + DISTRO_DIR + "/libpq.dll",
});
#endif
auto comapareTree = TestModule.qtLibs();
runTestParams({"-bin", bin, "clear" ,
"-qmake", qmake,
}, &comapareTree);
comapareTree = comapareTree + pluginTree;
runTestParams({"-bin", bin, "clear" ,
"-qmake", qmake,
"-enablePlugins", "sqldrivers"}, &comapareTree);
runTestParams({"-bin", bin, "clear" ,
"-qmake", qmake,
"-extraPlugin", TestQtDir + "/plugins/sqldrivers"}, &comapareTree);
comapareTree -= pluginTree;
comapareTree -= utils.createTree(
{
"./" + DISTRO_DIR + "/plugins/platforms/libqxcb.so",
"./" + DISTRO_DIR + "/lib/libxcb-xinerama.so.0",
"./" + DISTRO_DIR + "/plugins/xcbglintegrations/libqxcb-egl-integration.so",
"./" + DISTRO_DIR + "/plugins/xcbglintegrations/libqxcb-glx-integration.so",
"./" + DISTRO_DIR + "/lib/libQt5XcbQpa.so",
});
runTestParams({"-bin", bin, "clear" ,
"-qmake", qmake,
"-disablePlugins", "qxcb,xcbglintegrations"}, &comapareTree);
}

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef EXTRA_PLUGIN_TEST_H
#define EXTRA_PLUGIN_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class ExtraPluginTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // EXTRA_PLUGIN_TEST_H

@ -0,0 +1,59 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "ignoreenvtest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void IgnoreEnvTest::test() {
Envirement env;
QDir("./testTree").removeRecursively();
QStringList ignoreTree = {
"./testTree/test",
"./testTree/",
"./testTree/test1/1",
"./testTree/test2/1/",
};
QStringList testTree = {
"./testTree/test/z",
"./testTree/z",
"./testTree/test1/1z",
"./testTree/test2/1/z",
};
createTree(ignoreTree);
createTree(testTree);
env.setIgnoreEnvList(ignoreTree);
env.addEnv(ignoreTree);
// must be empty becouse all pathes is ignored
QVERIFY(env.size() == 0);
env.addEnv(testTree);
// must be equals 4 becouse all pathes is not ignored
QVERIFY(env.size() == 4);
// try add dublicate
env.addEnv(testTree);
// must be equals 4 becouse all dublicates must be ignored
QVERIFY(env.size() == 4);
QVERIFY(QDir("./testTree").removeRecursively());
}

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef IGNORE_ENV_TEST_H
#define IGNORE_ENV_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class IgnoreEnvTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // IGNORE_ENV_TEST_H

@ -0,0 +1,33 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "ignoreenvwithlibdirtest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void IgnoreEnvWithLibDirTest::test() {
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "TestOnlyC";
#else
QString bin = TestBinDir + "TestOnlyC.exe";
#endif
QVERIFY(QDir().mkdir("libDirtest"));
// Run deploy installer
runTestParams({"-bin", bin, "clear",
"-targetDir", "./libDirtest",
"-libDir", "./libDirtest"}, nullptr, false, false,
exitCodes::PrepareError);
QVERIFY(QDir().rmdir("libDirtest"));
}

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef IGNORE_ENV_WITH_LIB_DIR_TEST_H
#define IGNORE_ENV_WITH_LIB_DIR_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class IgnoreEnvWithLibDirTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // IGNORE_ENV_WITH_LIB_DIR_TEST_H

104
tests/units/ignoretest.cpp Normal file

@ -0,0 +1,104 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "ignoretest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void IgnoreTest::test() {
TestUtils utils;
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "QtWidgetsProject";
QString qmake = TestQtDir + "bin/qmake";
auto comapareTree = utils.createTree(
{
"./" + DISTRO_DIR + "/QtWidgetsProject.sh",
"./" + DISTRO_DIR + "/bin/qt.conf",
"./" + DISTRO_DIR + "/bin/QtWidgetsProject",
});
#else
QString bin = TestBinDir + "QtWidgetsProject.exe";
QString qmake = TestQtDir + "bin/qmake.exe";
auto comapareTree = utils.createTree(
{
"./" + DISTRO_DIR + "/qt.conf",
"./" + DISTRO_DIR + "/QtWidgetsProject.exe",
"./" + DISTRO_DIR + "/QtWidgetsProject.bat",
#if defined(Q_OS_WIN64)
"./" + DISTRO_DIR + "/libgcc_s_seh-1.dll",
#else
"./" + DISTRO_DIR + "/libgcc_s_dw2-1.dll",
#endif
"./" + DISTRO_DIR + "/libstdc++-6.dll",
"./" + DISTRO_DIR + "/libwinpthread-1.dll"
});
#endif
if (!TestQtDir.contains("Qt5")) {
#ifdef Q_OS_UNIX
bin = TestBinDir + "QtWidgetsProject";
qmake = TestQtDir + "bin/qmake";
#else
bin = TestBinDir + "QtWidgetsProject.exe";
qmake = TestQtDir + "bin/qmake.exe";
#endif
}
runTestParams({"-bin", bin, "clear" ,
"-qmake", qmake,
"-ignore", "Qt5"}, &comapareTree);
#ifdef Q_OS_UNIX
auto removeTree = 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",
});
#else
auto removeTree = utils.createTree({
"./" + DISTRO_DIR + "/Qt5VirtualKeyboard.dll",
"./" + DISTRO_DIR + "/plugins/platforminputcontexts/qtvirtualkeyboardplugin.dll",
"./" + 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"
});
#endif
comapareTree = TestModule.qtLibs() - removeTree;
runTestParams({"-bin", bin, "clear" ,
"-qmake", qmake,
"-ignore", "VirtualKeyboard"}, &comapareTree);
}

23
tests/units/ignoretest.h Normal file

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef IGNORE_TEST_H
#define IGNORE_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class IgnoreTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // IGNORE_TEST_H

@ -0,0 +1,35 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "installdiroptionstest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void InstallDirsOptionsTest::test() {
#ifdef QT_DEBUG
#ifdef Q_OS_UNIX
QStringList binMulti = {TestBinDir + "TestOnlyC" , TestBinDir + "TestCPPOnly"};
#else
QStringList binMulti = {TestBinDir + "TestOnlyC.exe" , TestBinDir + "TestCPPOnly.exe"};
#endif
runTestParams({"-bin", binMulti.join(","), "clear",
"qif", "deb",
"-targetPackage", "pkg;TestCPPOnly",
"-installDirDeb", "pkg;/var",
"-installDirQIFW", "/opt"});
#endif
}

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef INSTALL_DIR_OPTIONS_TEST_H
#define INSTALL_DIR_OPTIONS_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class InstallDirsOptionsTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // INSTALL_DIR_OPTIONS_TEST_H

158
tests/units/libdirstest.cpp Normal file

@ -0,0 +1,158 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "libdirstest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void LibDirTest::test() {
TestUtils utils;
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "TestOnlyC";
QString extraPath = "/usr/lib,/lib";
auto comapareTree = utils.createTree(
{
"./" + DISTRO_DIR + "/TestOnlyC.sh",
"./" + DISTRO_DIR + "/bin/qt.conf",
"./" + DISTRO_DIR + "/bin/TestOnlyC"
});
#else
QString bin = TestBinDir + "TestOnlyC.exe";
QString extraPath = TestQtDir;
auto comapareTree = utils.createTree(
{
"./" + DISTRO_DIR + "/qt.conf",
"./" + DISTRO_DIR + "/TestOnlyC.exe",
"./" + DISTRO_DIR + "/TestOnlyC.bat",
});
#endif
runTestParams({"-bin", bin, "clear" ,
"-libDir", extraPath,
}, &comapareTree);
#ifdef Q_OS_UNIX
comapareTree = 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",
"./" + DISTRO_DIR + "/lib/ld-linux-x86-64.so",
"./" + DISTRO_DIR + "/lib/libc.so",
"./" + DISTRO_DIR + "/lib/libm.so",
});
auto comapareTreeExtraLib = utils.createTree(
{
"./" + DISTRO_DIR + "2/TestOnlyC.sh",
"./" + DISTRO_DIR + "2/bin/qt.conf",
"./" + DISTRO_DIR + "2/bin/TestOnlyC",
"./" + DISTRO_DIR + "2/lib/libstdc++.so",
"./" + DISTRO_DIR + "2/lib/libgcc_s.so"
});
#else
comapareTree = utils.createTree(
{
"./" + DISTRO_DIR + "/qt.conf",
"./" + DISTRO_DIR + "/TestOnlyC.exe",
"./" + DISTRO_DIR + "/TestOnlyC.bat",
#if defined(Q_OS_WIN64)
"./" + DISTRO_DIR + "/libgcc_s_seh-1.dll",
#else
"./" + DISTRO_DIR + "/libgcc_s_dw2-1.dll",
#endif
"./" + DISTRO_DIR + "/libwinpthread-1.dll",
"./" + DISTRO_DIR + "/libstdc++-6.dll",
});
auto comapareTreeExtraLib = utils.createTree(
{
"./" + DISTRO_DIR + "2/qt.conf",
"./" + DISTRO_DIR + "2/TestOnlyC.exe",
"./" + DISTRO_DIR + "2/TestOnlyC.bat",
#if defined(Q_OS_WIN64)
"./" + DISTRO_DIR + "2/libgcc_s_seh-1.dll",
#else
"./" + DISTRO_DIR + "2/libgcc_s_dw2-1.dll",
#endif
"./" + DISTRO_DIR + "2/libstdc++-6.dll",
});
#endif
runTestParams({"-bin", bin, "clear" ,
"-libDir", extraPath,
"-recursiveDepth", "5",
"noCheckRPATH, noCheckPATH", "noQt"}, &comapareTree, true);
runTestParams({"-bin", bin, "clear" ,
"-targetDir", "./" + DISTRO_DIR + "2",
"-extraLibs", "stdc,gcc",
"noCheckRPATH, noCheckPATH", "noQt"}, &comapareTreeExtraLib, true);
//task #258
//https://github.com/QuasarApp/CQtDeployer/issues/258
#ifdef Q_OS_UNIX
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"
});
extraPath = "./" + DISTRO_DIR + "2/lib";
#else
comapareTreeExtraLib = utils.createTree(
{
"./" + DISTRO_DIR + "/qt.conf",
"./" + DISTRO_DIR + "/TestOnlyC.exe",
"./" + DISTRO_DIR + "/TestOnlyC.bat",
#if defined(Q_OS_WIN64)
"./" + DISTRO_DIR + "/libgcc_s_seh-1.dll",
#else
"./" + DISTRO_DIR + "/libgcc_s_dw2-1.dll",
#endif
"./" + DISTRO_DIR + "/libstdc++-6.dll",
});
extraPath = "./" + DISTRO_DIR + "2";
#endif
runTestParams({"-bin", bin, "clear" ,
"-libDir", extraPath,
"noCheckRPATH, noCheckPATH", "noQt"}, &comapareTreeExtraLib, true);
QDir(extraPath).removeRecursively();
}

23
tests/units/libdirstest.h Normal file

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef LIB_DIR_TEST_H
#define LIB_DIR_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class LibDirTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // LIB_DIR_TEST_H

103
tests/units/outdirtest.cpp Normal file

@ -0,0 +1,103 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "outdirtest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void OutDirTest::test() {
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 = TestModule.testOutLibs();
runTestParams({"-bin", bin, "clear" ,
"-binOut", "/lol",
"-libOut", "/lolLib",
"-trOut", "/lolTr",
"-pluginOut", "/p",
"-qmlOut", "/q",
"-qmake", qmake,
"-qmlDir", TestBinDir + "/../TestQMLWidgets"
}, &comapareTree);
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/"));
#ifdef Q_OS_WIN
runTestParams({"-bin", bin, "clear" ,
"-binOut", "/lol",
"-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();
qDebug() << "runScript =" << runScript;
QVERIFY(runScript.contains("SET BASE_DIR=%~dp0"));
QVERIFY(runScript.contains("SET PATH=%BASE_DIR%\\lol\\;%BASE_DIR%\\lolLib\\;%PATH%"));
QVERIFY(runScript.contains("start \"TestQMLWidgets\" /B \"%BASE_DIR%\\lol\\TestQMLWidgets.exe\" %*"));
runTestParams({"-bin", TestBinDir + "TestOnlyC.exe", "clear",
}, nullptr);
file.setFileName( "./" + DISTRO_DIR + "/TestOnlyC.bat");
QVERIFY(file.open(QIODevice::ReadOnly));
runScript = file.readAll();
file.close();
qDebug() << "runScript =" << runScript;
QVERIFY(runScript.contains("call \"%BASE_DIR%\\TestOnlyC.exe\" %*"));
#endif
}

23
tests/units/outdirtest.h Normal file

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef OUT_DIR_TEST_H
#define OUT_DIR_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class OutDirTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // OUT_DIR_TEST_H

@ -0,0 +1,71 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "overwritetest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void OverwiriteTest::test() {
TestUtils utils;
#ifdef Q_OS_UNIX
QFile f("./" + DISTRO_DIR + "/bin/TestOnlyC");
auto comapareTree = utils.createTree(
{"./" + DISTRO_DIR + "/bin/TestOnlyC",
"./" + DISTRO_DIR + "/bin/qt.conf",
"./" + DISTRO_DIR + "/TestOnlyC.sh"});
QString bin = TestBinDir + "TestOnlyC";
#else
QFile f("./" + DISTRO_DIR + "/TestOnlyC.exe");
auto comapareTree = utils.createTree(
{"./" + DISTRO_DIR + "/TestOnlyC.exe",
"./" + DISTRO_DIR + "/TestOnlyC.bat",
"./" + DISTRO_DIR + "/qt.conf"});
QString bin = TestBinDir + "TestOnlyC.exe";
#endif
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);
runTestParams({"-bin", bin, "noOverwrite"}, &comapareTree);
QVERIFY(f.open(QIODevice::ReadOnly));
hashAfter = QCryptographicHash::hash(f.readAll(), QCryptographicHash::Md5);
f.close();
QVERIFY(hashAfter != hashBefor);
runTestParams({"-bin", bin}, &comapareTree);
QVERIFY(f.open(QIODevice::ReadOnly));
hashAfter = QCryptographicHash::hash(f.readAll(), QCryptographicHash::Md5);
f.close();
QVERIFY(hashAfter == hashBefor);
}

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef OVERWRITE_TEST_H
#define OVERWRITE_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class OverwiriteTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // OVERWRITE_TEST_H

@ -0,0 +1,50 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "overwritewithpackingtest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void OverwiriteWithPackingTest::test() {
TestUtils utils;
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "TestOnlyC," + TestBinDir + "TestCPPOnly";
#else
QString bin = TestBinDir + "TestOnlyC.exe," + TestBinDir + "TestCPPOnly.exe";
#endif
#ifdef Q_OS_UNIX
auto comapareTreeqif = utils.createTree(
{
"./" + DISTRO_DIR + "/InstallerTest.run",
"./" + DISTRO_DIR + "/InstallerTest.run.md5",
});
#else
auto comapareTreeqif = utils.createTree(
{
"./" + DISTRO_DIR + "/InstallerTest.exe",
"./" + DISTRO_DIR + "/InstallerTest.exe.md5",
});
#endif
runTestParams({"-bin", bin,
"force-clear",
"noOverwrite",
"qif",
"qifFromSystem",
"-name", "Test"}, &comapareTreeqif);
}

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef OVERWRITE_WITH_PACKING_TEST_H
#define OVERWRITE_WITH_PACKING_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class OverwiriteWithPackingTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // OVERWRITE_WITH_PACKING_TEST_H

@ -0,0 +1,87 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "packagestest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void PacakgesTest::test() {
TestUtils utils;
#ifdef Q_OS_UNIX
QFile f("./" + DISTRO_DIR + "/bin/TestOnlyC");
auto comapareTree = utils.createTree(
{
"./" + DISTRO_DIR + "/package/TestOnlyC.sh",
"./" + DISTRO_DIR + "/package/bin/TestOnlyC",
"./" + DISTRO_DIR + "/package/bin/qt.conf"
});
QString target1 = TestBinDir + "TestOnlyC";
#else
QFile f("./" + DISTRO_DIR + "/TestOnlyC.exe");
auto comapareTree = utils.createTree(
{"./" + DISTRO_DIR + "/package/TestOnlyC.exe",
"./" + DISTRO_DIR + "/package/TestOnlyC.bat",
"./" + DISTRO_DIR + "/package/qt.conf"});
QString target1 = TestBinDir + "TestOnlyC.exe";
#endif
QString bin = target1;
runTestParams({"-bin", bin, "force-clear",
"-targetPackage", "/package/;TestOn"}, &comapareTree);
runTestParams({"-bin", bin, "force-clear",
"-targetPackage", "/package/;" + QFileInfo(target1).absoluteFilePath()}, &comapareTree);
#ifdef Q_OS_UNIX
QString target2 = TestBinDir + "TestQMLWidgets";
QString target3 = TestBinDir + "QtWidgetsProject";
#else
QString target2 = TestBinDir + "TestQMLWidgets.exe";
QString target3 = TestBinDir + "QtWidgetsProject.exe";
#endif
bin += "," + target2;
bin += "," + target3;
auto packageString = "package1;" + QFileInfo(target1).absoluteFilePath() + ",package2/ZzZ;" + QFileInfo(target2).absoluteFilePath();
comapareTree = TestModule.testDistroLibs(DISTRO_DIR);
runTestParams({"-bin", bin, "force-clear",
"-binOut", "/lol",
"-libOut", "/lolLib",
"-trOut", "/lolTr",
"-pluginOut", "/p",
"-qmlOut", "package2/ZzZ;/q/and/q,/q",
"-qmlDir", "package2/ZzZ;" + TestBinDir + "/../TestQMLWidgets",
"-targetPackage", packageString}, &comapareTree);
#ifdef Q_OS_UNIX
// test a wrapers source
QFile wraper("./" + DISTRO_DIR + "/package2/ZzZ/TestQMLWidgets.sh");
QVERIFY(wraper.open(QIODevice::ReadOnly));
auto data = wraper.readAll();
wraper.close();
wraper.setFileName(":/testResurces/testRes/TestQMLWidgets.sh");
QVERIFY(wraper.open(QIODevice::ReadOnly));
QVERIFY(wraper.readAll() == data);
wraper.close();
#endif
}

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef PACKAGES_TEST_H
#define PACKAGES_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class PacakgesTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // PACKAGES_TEST_H

@ -0,0 +1,41 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "qifwachiveformattest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void QIFWArchiveFormatTest::test() {
TestUtils utils;
#ifdef Q_OS_UNIX
QString bin = {TestBinDir + "TestOnlyC"};
auto result = utils.createTree({{DISTRO_DIR + "/InstallerTestOnlyC.run"},
{DISTRO_DIR + "/InstallerTestOnlyC.run.md5"}});
#else
QString bin = {TestBinDir + "TestOnlyC.exe"};
auto result = utils.createTree({{DISTRO_DIR + "/InstallerTestOnlyC.exe"},
{DISTRO_DIR + "/InstallerTestOnlyC.exe.md5"}});
#endif
runTestParams({
"-bin", bin,
"qifFromSystem",
"clear",
"qif",
"-qifArchiveFormat", "zip"
}, &result
);
}

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef QIFW_ARCHIVE_FORMAT_TEST_H
#define QIFW_ARCHIVE_FORMAT_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class QIFWArchiveFormatTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // QIFW_ARCHIVE_FORMAT_TEST_H

@ -0,0 +1,63 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "qifwbinarycreatortest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void QIFWBinaryCreatorTest::test() {
TestUtils utils;
#ifdef Q_OS_UNIX
QString bin = {TestBinDir + "TestOnlyC"};
#else
QString bin = {TestBinDir + "TestOnlyC.exe"};
#endif
{
QuasarAppUtils::Params::parseParams({
"-bin", bin,
"qifFromSystem",
"clear",
"qif",
"-binarycreator", "test testValue"
});
Deploy deploy;
QVERIFY(deploy.prepare());
FileManager fm;
QIF qif(&fm);
auto command = qif.runCmd();
QVERIFY(command.size() == 1);
QVERIFY(command.first().command == "test");
QVERIFY(command.first().arguments.contains("testValue"));
}
{
QuasarAppUtils::Params::parseParams({
"-bin", bin,
"qifFromSystem",
"clear",
"qif",
"-binarycreator", "test"
});
Deploy deploy;
QVERIFY(deploy.prepare());
FileManager fm;
QIF qif(&fm);
auto command = qif.runCmd();
QVERIFY(command.size() == 1);
QVERIFY(command.first().command == "test");
}
}

@ -0,0 +1,24 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef QIFW_BINARY_CREATOR_TEST_H
#define QIFW_BINARY_CREATOR_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class QIFWBinaryCreatorTest: public TestBase, protected TestUtils
{
public:
void test();
};
#endif // QIFW_BINARY_CREATOR_TEST_H

@ -0,0 +1,45 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "qifwouttest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void QIFWOutTest::test() {
TestUtils utils;
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "TestOnlyC";
#else
QString bin = TestBinDir + "TestOnlyC.exe";
#endif
#ifdef Q_OS_UNIX
auto result = utils.createTree({{DISTRO_DIR + "/QIF_OUT.exe"}, {DISTRO_DIR + "/QIF_OUT.exe.md5"},
{DISTRO_DIR + "/DEB_OUT.deb"}, {DISTRO_DIR + "/DEB_OUT.deb.md5"},
{DISTRO_DIR + "/ZIP_OUT.zip"}, {DISTRO_DIR + "/ZIP_OUT.zip.md5"}});
// Run deploy installer
runTestParams({"-bin", bin, "clear",
"qif", "-qifOut", "QIF_OUT.exe",
"deb", "-debOut", "DEB_OUT.deb",
"zip", "-zipOut", "ZIP_OUT.zip"}, &result);
#else
auto result = utils.createTree({{DISTRO_DIR + "/QIF_OUT.exe"}, {DISTRO_DIR + "/QIF_OUT.exe.md5"},
{DISTRO_DIR + "/ZIP_OUT.zip"}, {DISTRO_DIR + "/ZIP_OUT.zip.md5"}});
// Run deploy installer
runTestParams({"-bin", bin, "clear",
"qif", "-qifOut", "QIF_OUT.exe",
"zip", "-zipOut", "ZIP_OUT.zip"}, &result);
#endif
}

23
tests/units/qifwouttest.h Normal file

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef QIFW_QUT_TEST_H
#define QIFW_QUT_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class QIFWOutTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // QIFW_QUT_TEST_H

@ -0,0 +1,44 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "qifwresourcestest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void QIFWResourcesTest::test() {
TestUtils utils;
#ifdef Q_OS_UNIX
QString bin = {TestBinDir + "TestOnlyC"};
auto result = utils.createTree({{DISTRO_DIR + "/InstallerTestOnlyC.run"},
{DISTRO_DIR + "/InstallerTestOnlyC.run.md5"}});
#else
QString bin = {TestBinDir + "TestOnlyC.exe"};
auto result = utils.createTree({{DISTRO_DIR + "/InstallerTestOnlyC.exe"},
{DISTRO_DIR + "/InstallerTestOnlyC.exe.md5"}});
#endif
auto templateDir = TestBinDir + "/../../UnitTests/testRes/QIFCustomTemplate";
runTestParams({
"-bin", bin,
"clear",
"qif",
"-qifConfig", templateDir + "/customconfig.xml",
"-qifPackages", templateDir + "/custompackages",
"-qifResources", templateDir + "customRes.qrc"
}, &result
);
}

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef QIFW_RSOURCES_TEST_H
#define QIFW_RSOURCES_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class QIFWResourcesTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // QIFW_RSOURCES_TEST_H

@ -0,0 +1,37 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "qmlextracttest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void QMLExtractTest::test() {
QmlCreator creator("./");
auto imports = creator.getQmlImports();
auto qmlFiles = creator.getCopyedQml();
QML scaner("./", QtMajorVersion::Qt5);
for (const auto &file : qAsConst(qmlFiles)) {
auto fileImports = scaner.extractImportsFromFile(file);
for (const auto &fil : imports.value(file)) {
QVERIFY(fileImports.contains(fil, Qt::CaseInsensitive));
}
}
}

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef QML_EXTRACT_TEST_H
#define QML_EXTRACT_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class QMLExtractTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // QML_EXTRACT_TEST_H

74
tests/units/qttest.cpp Normal file

@ -0,0 +1,74 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void QtTest::test() {
TestUtils utils;
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "QtWidgetsProject";
QString qmake = TestQtDir + "bin/qmake";
#else
QString bin = TestBinDir + "QtWidgetsProject.exe";
QString qmake = TestQtDir + "bin/qmake.exe";
#endif
auto comapareTree = TestModule.qtLibs();
runTestParams({"-bin", bin, "clear" ,
"-qmake", qmake}, &comapareTree);
// test auto detection of detection qmake from PATH
runTestParams({"-bin", bin, "clear", "noCheckRPATH"}, &comapareTree);
#ifdef Q_OS_UNIX
// test auto detection of detection qmake from RPATH
runTestParams({"-bin", bin, "clear", "noCheckPATH"}, &comapareTree);
#endif
comapareTree = TestModule.qtWithoutTr();
runTestParams({"-bin", bin, "clear" ,
"-qmake", qmake, "noTranslations"}, &comapareTree);
comapareTree = TestModule.qmlLibs();
#ifdef Q_OS_UNIX
bin = TestBinDir + "TestQMLWidgets";
#else
bin = TestBinDir + "TestQMLWidgets.exe";
#endif
runTestParams({"-bin", bin, "clear" ,
"-qmake", qmake,
"-qmlDir", TestBinDir + "/../TestQMLWidgets"}, &comapareTree);
#ifdef Q_OS_UNIX
runTestParams({"-bin", bin, "clear" ,
"-qmlDir", TestBinDir + "/../TestQMLWidgets"}, &comapareTree);
#endif
}

23
tests/units/qttest.h Normal file

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef QT_TEST_H
#define QT_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class QtTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // QT_TEST_H

@ -0,0 +1,50 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "releativelinktest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void ReleativeLinkTest::test() {
auto cases = QList<QList<QString>>{
{"", "", "./"},
{"/media", "/etc", "./../etc/"},
{"/media///", "/etc///", "./../etc/"},
{"/media/etc/usr", "/media/etc", "./../"},
{"/media/etc", "/media/etc/usr", "./usr/"},
{"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 (const auto &i: qAsConst(cases)) {
if (PathUtils::getRelativeLink(i[0], i[1]) != i[2])
QVERIFY(false);
}
for (int i = 1; i < cases.size() - 1; i++) {
if (!PathUtils::isAbsalutPath(cases[i][0]))
QVERIFY(false);
if (PathUtils::isAbsalutPath(cases[i][2]))
QVERIFY(false);
}
}

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef RELEATIVE_LINK_TEST_H
#define RELEATIVE_LINK_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class ReleativeLinkTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // RELEATIVE_LINK_TEST_H

@ -0,0 +1,40 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "settargetdirtest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void SetTargetDirTest::test() {
FileManager file;
DependenciesScanner scan;
Packing pac(&file);
PluginsParser _plugins;
ConfigParser dep(&file, &_plugins, &scan, &pac);
dep.setTargetDir();
QVERIFY(dep.config()->getTargetDir() == QFileInfo("./" + DISTRO_DIR + "").absoluteFilePath());
dep.setTargetDir("./ff");
QVERIFY(dep.config()->getTargetDir() == QFileInfo("./ff").absoluteFilePath());
QStringList argv = {"-targetDir", "./" + DISTRO_DIR + "2"};
QuasarAppUtils::Params::parseParams(argv);
dep.setTargetDir();
QVERIFY(dep.config()->getTargetDir() == QFileInfo("./" + DISTRO_DIR + "2").absoluteFilePath());
dep.setTargetDir("./ff");
QVERIFY(dep.config()->getTargetDir() == QFileInfo("./" + DISTRO_DIR + "2").absoluteFilePath());
}

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef SET_TARGET_DIR_TEST_H
#define SET_TARGET_DIR_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class SetTargetDirTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // SET_TARGET_DIR_TEST_H

@ -0,0 +1,143 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "targetdirtest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void TargetDirTest::test() {
TestUtils utils;
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "TestOnlyC";
auto comapareTree = utils.createTree(
{"./" + DISTRO_DIR + "Z/bin/TestOnlyC",
"./" + DISTRO_DIR + "Z/bin/qt.conf",
"./" + DISTRO_DIR + "Z/TestOnlyC.sh"});
#else
QString bin = TestBinDir + "TestOnlyC.exe";
auto comapareTree = utils.createTree(
{"./" + DISTRO_DIR + "Z/TestOnlyC.exe",
"./" + DISTRO_DIR + "Z/TestOnlyC.bat",
"./" + DISTRO_DIR + "Z/qt.conf"});
#endif
runTestParams({"-bin", bin, "clear" ,
"-targetDir", "./" + DISTRO_DIR + "Z"
}, &comapareTree);
}
void deploytest::testSystemLib() {
TestUtils utils;
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "TestOnlyC";
QString qmake = TestQtDir + "bin/qmake";
auto comapareTree = utils.createTree(
{
"./" + DISTRO_DIR + "/TestOnlyC.sh",
"./" + DISTRO_DIR + "/bin/qt.conf",
"./" + DISTRO_DIR + "/bin/TestOnlyC",
"./" + DISTRO_DIR + "/lib/systemLibs/libgcc_s.so",
"./" + DISTRO_DIR + "/lib/systemLibs/libstdc++.so"
});
#else
QString bin = TestBinDir + "TestOnlyC.exe";
QString qmake = TestQtDir + "bin/qmake.exe";
auto comapareTree = utils.createTree(
{
"./" + DISTRO_DIR + "/TestOnlyC.exe",
"./" + DISTRO_DIR + "/TestOnlyC.bat",
#if defined(Q_OS_WIN64)
"./" + DISTRO_DIR + "/systemLibs/libgcc_s_seh-1.dll",
#else
"./" + DISTRO_DIR + "/systemLibs/libgcc_s_dw2-1.dll",
#endif
"./" + DISTRO_DIR + "/systemLibs/libstdc++-6.dll",
"./" + DISTRO_DIR + "/systemLibs/libwinpthread-1.dll",
"./" + DISTRO_DIR + "/systemLibs/msvcrt.dll",
"./" + DISTRO_DIR + "/qt.conf"
});
#endif
runTestParams({"-bin", bin, "clear" ,
"deploySystem",
"-qmake", qmake,
}, &comapareTree);
#ifdef Q_OS_WIN
bin = TestBinDir + "QtWidgetsProject.exe";
comapareTree += TestModule.qtLibs();
comapareTree -= utils.createTree(
{
"./" + DISTRO_DIR + "/TestOnlyC.exe",
"./" + DISTRO_DIR + "/TestOnlyC.bat",
#if defined(Q_OS_WIN64)
"./" + DISTRO_DIR + "/systemLibs/libgcc_s_seh-1.dll",
#else
"./" + DISTRO_DIR + "/systemLibs/libgcc_s_dw2-1.dll",
#endif
"./" + DISTRO_DIR + "/systemLibs/libstdc++-6.dll",
"./" + DISTRO_DIR + "/systemLibs/libwinpthread-1.dll",
});
comapareTree += utils.createTree(
{
"./" + DISTRO_DIR + "/systemLibs/msvcrt.dll",
"./" + DISTRO_DIR + "/qt.conf",
"./" + DISTRO_DIR + "/systemLibs/mpr.dll",
"./" + DISTRO_DIR + "/systemLibs/profapi.dll",
"./" + DISTRO_DIR + "/systemLibs/rpcrt4.dll",
"./" + DISTRO_DIR + "/systemLibs/shell32.dll",
"./" + DISTRO_DIR + "/systemLibs/userenv.dll",
"./" + DISTRO_DIR + "/systemLibs/uxtheme.dll",
"./" + DISTRO_DIR + "/systemLibs/version.dll",
"./" + DISTRO_DIR + "/systemLibs/ucrtbase.dll",
"./" + DISTRO_DIR + "/systemLibs/oleaut32.dll",
"./" + DISTRO_DIR + "/systemLibs/bcryptprimitives.dll",
"./" + DISTRO_DIR + "/systemLibs/msvcp_win.dll",
"./" + DISTRO_DIR + "/systemLibs/wtsapi32.dll",
"./" + DISTRO_DIR + "/systemLibs/combase.dll",
#if !defined(Q_OS_WIN64)
"./" + DISTRO_DIR + "/systemLibs/sspicli.dll",
"./" + DISTRO_DIR + "/systemLibs/cryptbase.dll",
#endif
});
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
comapareTree += utils.createTree(
{
"./" + DISTRO_DIR + "/systemLibs/d3d11.dll",
"./" + DISTRO_DIR + "/systemLibs/dxgi.dll",
"./" + DISTRO_DIR + "/systemLibs/win32u.dll",
});
#endif
runTestParams({"-bin", bin, "clear" ,
"-qmake", qmake,
"deploySystem"
}, &comapareTree);
#endif
}

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef TARGET_DIR_TEST_H
#define TARGET_DIR_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class TargetDirTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // TARGET_DIR_TEST_H

@ -0,0 +1,31 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "ziparrchivetest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void ZIPArchiveTest::test() {
TestUtils utils;
ZipCompresser zip;
auto befor = utils.getTree("./test");
QVERIFY(zip.compress("./test", "./arr.zip"));
QVERIFY(QDir("./test").removeRecursively());
QVERIFY(zip.extract("./arr.zip", "./test"));
auto after = utils.getTree("./test");
QVERIFY(utils.compareTree(befor, after).size() == 0);
}

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef ZIP_ARCHIVE_TEST_H
#define ZIP_ARCHIVE_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class ZIPArchiveTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // ZIP_ARCHIVE_TEST_H

@ -0,0 +1,44 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 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 "zipmultitest.h"
#include <configparser.h>
#include <dependenciesscanner.h>
#include <filemanager.h>
#include <packing.h>
#include <pluginsparser.h>
void ZIPMultiTest::test() {
TestUtils utils;
auto comapareTreeMulti = utils.createTree({
"./" + DISTRO_DIR + "/package1.zip",
"./" + DISTRO_DIR + "/package2.zip",
"./" + DISTRO_DIR + "/package1.zip.md5",
"./" + DISTRO_DIR + "/package2.zip.md5",
});
#ifdef Q_OS_UNIX
QString target1 = TestBinDir + "TestCPPOnly";
QString target2 = TestBinDir + "TestOnlyC";
#else
QString target1 = TestBinDir + "TestCPPOnly.exe";
QString target2 = TestBinDir + "TestOnlyC.exe";
#endif
QString bin = target1;
bin += "," + target2;
auto packageString = "/package1/;" + QFileInfo(target1).absoluteFilePath() + ",/package2/;" + QFileInfo(target2).absoluteFilePath();
runTestParams({"-bin", bin, "force-clear",
"-targetPackage", packageString,
"zip"}, &comapareTreeMulti, true);
}

@ -0,0 +1,23 @@
//#
//# Copyright (C) 2020-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef ZIP_MULTI_TEST_H
#define ZIP_MULTI_TEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class ZIPMultiTest: public TestBase, protected TestUtils
{
public:
void test() override;
};
#endif // ZIP_MULTI_TEST_H

@ -39,30 +39,3 @@ void ZIPTest::test() {
}
void deploytest::testZIPMulti() {
TestUtils utils;
auto comapareTreeMulti = utils.createTree({
"./" + DISTRO_DIR + "/package1.zip",
"./" + DISTRO_DIR + "/package2.zip",
"./" + DISTRO_DIR + "/package1.zip.md5",
"./" + DISTRO_DIR + "/package2.zip.md5",
});
#ifdef Q_OS_UNIX
QString target1 = TestBinDir + "TestCPPOnly";
QString target2 = TestBinDir + "TestOnlyC";
#else
QString target1 = TestBinDir + "TestCPPOnly.exe";
QString target2 = TestBinDir + "TestOnlyC.exe";
#endif
QString bin = target1;
bin += "," + target2;
auto packageString = "/package1/;" + QFileInfo(target1).absoluteFilePath() + ",/package2/;" + QFileInfo(target2).absoluteFilePath();
runTestParams({"-bin", bin, "force-clear",
"-targetPackage", packageString,
"zip"}, &comapareTreeMulti, true);
}