mirror of
https://github.com/QuasarApp/CQtDeployer.git
synced 2025-04-30 19:54:35 +00:00
added tests for deployUtils
This commit is contained in:
parent
da943a9fd0
commit
ac1adbe38d
@ -9,7 +9,10 @@ TEMPLATE = subdirs
|
|||||||
CONFIG += ordered
|
CONFIG += ordered
|
||||||
|
|
||||||
SUBDIRS += QuasarAppLib \
|
SUBDIRS += QuasarAppLib \
|
||||||
CQtDeployer
|
Deploy \
|
||||||
|
CQtDeployer \
|
||||||
|
UnitTests
|
||||||
|
|
||||||
|
|
||||||
contains(DEFINES, WITH_TESTS) {
|
contains(DEFINES, WITH_TESTS) {
|
||||||
SUBDIRS += \
|
SUBDIRS += \
|
||||||
@ -19,7 +22,18 @@ contains(DEFINES, WITH_TESTS) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CQtDeployer.depends=QuasarAppLib
|
CQtDeployer.depends=QuasarAppLib
|
||||||
|
CQtDeployer.depends=Deploy
|
||||||
|
|
||||||
QuasarAppLib.file = $$PWD/QuasarAppLib/QuasarApp.pro
|
QuasarAppLib.file = $$PWD/QuasarAppLib/QuasarApp.pro
|
||||||
|
|
||||||
win32:include('$$PWD/CQtDeployerWinBuild.pri')
|
win32:include('$$PWD/CQtDeployerWinBuild.pri')
|
||||||
|
|
||||||
|
DISTFILES += \
|
||||||
|
snapBuild.sh \
|
||||||
|
staticBuild.sh \
|
||||||
|
snap/snapcraft.yaml \
|
||||||
|
README.md \
|
||||||
|
sharedBuild.sh \
|
||||||
|
README.md \
|
||||||
|
staticBuildCrossWin.sh \
|
||||||
|
sharedBuild.bat
|
||||||
|
@ -22,51 +22,18 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
|||||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
CONFIG(release, debug|release): {
|
CONFIG(release, debug|release): {
|
||||||
DESTDIR="$$PWD/../build/release"
|
DESTDIR="$$PWD/build/release"
|
||||||
} else {
|
} else {
|
||||||
DESTDIR="$$PWD/../build/debug"
|
DESTDIR="$$PWD/build/debug"
|
||||||
}
|
}
|
||||||
|
|
||||||
isEmpty(PREFIX){
|
|
||||||
PREFIX=$$PWD/../distro
|
|
||||||
}
|
|
||||||
include('$$PWD/../QuasarAppLib/QuasarLib.pri')
|
include('$$PWD/../QuasarAppLib/QuasarLib.pri')
|
||||||
include('$$PWD/../QuasarAppLib/Etalons/qmake/install_prefix.pri')
|
include('$$PWD/../Deploy/Deploy.pri')
|
||||||
win32:include('$$PWD/CQtDeployerWinBuild.pri')
|
|
||||||
|
|
||||||
install_data.files += $$DESTDIR/$$runfiletype
|
|
||||||
install_data.files += $$QUASARAPP_LIB_OUTPUT_DIR/$$libfiletype
|
|
||||||
|
|
||||||
|
|
||||||
TARGET = cqtdeployer
|
TARGET = cqtdeployer
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
deploy.cpp \
|
|
||||||
deployutils.cpp \
|
|
||||||
windependenciesscanner.cpp \
|
|
||||||
../qtTools/src/windeployqt/elfreader.cpp \
|
|
||||||
../qtTools/src/windeployqt/utils.cpp
|
|
||||||
|
|
||||||
HEADERS += \
|
|
||||||
deploy.h \
|
|
||||||
deployutils.h \
|
|
||||||
windependenciesscanner.h \
|
|
||||||
../qtTools/src/windeployqt/elfreader.h \
|
|
||||||
../qtTools/src/windeployqt/utils.h
|
|
||||||
|
|
||||||
|
|
||||||
DISTFILES += \
|
|
||||||
../snapBuild.sh \
|
|
||||||
../staticBuild.sh \
|
|
||||||
../snap/snapcraft.yaml \
|
|
||||||
../README.md \
|
|
||||||
../sharedBuild.sh \
|
|
||||||
../README.md \
|
|
||||||
../staticBuildCrossWin.sh \
|
|
||||||
../sharedBuild.bat
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
win32: LIBS += -lshlwapi
|
|
||||||
win32: RC_ICONS = $$PWD/../res/icon.ico
|
win32: RC_ICONS = $$PWD/../res/icon.ico
|
||||||
|
23
Deploy/Deploy.pri
Normal file
23
Deploy/Deploy.pri
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
!isEmpty(DEPLOY_LIB):error("Deploy.pri already included")
|
||||||
|
DEPLOY_LIB = 1
|
||||||
|
|
||||||
|
#DEPENDS
|
||||||
|
CONFIG(release, debug|release): {
|
||||||
|
DEPLOY_LIB_OUTPUT_DIR="$$PWD/build/release"
|
||||||
|
} else {
|
||||||
|
DEPLOY_LIB_OUTPUT_DIR="$$PWD/build/debug"
|
||||||
|
}
|
||||||
|
|
||||||
|
LIBS += -L$$DEPLOY_LIB_OUTPUT_DIR -lDeploy
|
||||||
|
|
||||||
|
INCLUDEPATH += "$$PWD/"
|
||||||
|
|
||||||
|
|
||||||
|
|
57
Deploy/Deploy.pro
Normal file
57
Deploy/Deploy.pro
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------
|
||||||
|
#
|
||||||
|
# Project created by QtCreator 2019-01-26T13:55:47
|
||||||
|
#
|
||||||
|
#-------------------------------------------------
|
||||||
|
|
||||||
|
QT -= gui
|
||||||
|
|
||||||
|
TARGET = Deploy
|
||||||
|
TEMPLATE = lib
|
||||||
|
|
||||||
|
DEFINES += DEPLOY_LIBRARY
|
||||||
|
|
||||||
|
# The following define makes your compiler emit warnings if you use
|
||||||
|
# any feature of Qt which has been marked as deprecated (the exact warnings
|
||||||
|
# depend on your compiler). Please consult the documentation of the
|
||||||
|
# deprecated API in order to know how to port your code away from it.
|
||||||
|
DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
|
|
||||||
|
# You can also make your code fail to compile if you use deprecated APIs.
|
||||||
|
# In order to do so, uncomment the following line.
|
||||||
|
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||||
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
|
CONFIG(release, debug|release): {
|
||||||
|
DESTDIR="$$PWD/build/release"
|
||||||
|
} else {
|
||||||
|
DESTDIR="$$PWD/build/debug"
|
||||||
|
}
|
||||||
|
|
||||||
|
include('$$PWD/../QuasarAppLib/QuasarLib.pri')
|
||||||
|
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
deploy.cpp \
|
||||||
|
deployutils.cpp \
|
||||||
|
windependenciesscanner.cpp \
|
||||||
|
../qtTools/src/windeployqt/elfreader.cpp \
|
||||||
|
../qtTools/src/windeployqt/utils.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
deploy.h \
|
||||||
|
deploy_global.h \
|
||||||
|
deployutils.h \
|
||||||
|
windependenciesscanner.h\
|
||||||
|
../qtTools/src/windeployqt/elfreader.h \
|
||||||
|
../qtTools/src/windeployqt/utils.h
|
||||||
|
|
||||||
|
win32: LIBS += -lshlwapi
|
19
Deploy/deploy_global.h
Normal file
19
Deploy/deploy_global.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DEPLOY_GLOBAL_H
|
||||||
|
#define DEPLOY_GLOBAL_H
|
||||||
|
|
||||||
|
#include <QtCore/qglobal.h>
|
||||||
|
|
||||||
|
#if defined(DEPLOY_LIBRARY)
|
||||||
|
# define DEPLOYSHARED_EXPORT Q_DECL_EXPORT
|
||||||
|
#else
|
||||||
|
# define DEPLOYSHARED_EXPORT Q_DECL_IMPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // DEPLOY_GLOBAL_H
|
@ -165,7 +165,7 @@ bool DeployUtils::parseQt(Deploy *deploy) {
|
|||||||
|
|
||||||
bool DeployUtils::isQtLib(const QString &lib) {
|
bool DeployUtils::isQtLib(const QString &lib) {
|
||||||
QFileInfo info(lib);
|
QFileInfo info(lib);
|
||||||
return !qtDir.isEmpty() && info.absolutePath().contains(qtDir);
|
return !qtDir.isEmpty() && info.absoluteFilePath().contains(qtDir);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ bool DeployUtils::isExtraLib(const QString &lib) {
|
|||||||
QFileInfo info(lib);
|
QFileInfo info(lib);
|
||||||
|
|
||||||
for (auto i : extraPaths) {
|
for (auto i : extraPaths) {
|
||||||
if (info.absolutePath().contains(i)) {
|
if (info.absoluteFilePath().contains(i)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
73
UnitTests/.gitignore
vendored
Normal file
73
UnitTests/.gitignore
vendored
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
# This file is used to ignore files which are generated
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
*~
|
||||||
|
*.autosave
|
||||||
|
*.a
|
||||||
|
*.core
|
||||||
|
*.moc
|
||||||
|
*.o
|
||||||
|
*.obj
|
||||||
|
*.orig
|
||||||
|
*.rej
|
||||||
|
*.so
|
||||||
|
*.so.*
|
||||||
|
*_pch.h.cpp
|
||||||
|
*_resource.rc
|
||||||
|
*.qm
|
||||||
|
.#*
|
||||||
|
*.*#
|
||||||
|
core
|
||||||
|
!core/
|
||||||
|
tags
|
||||||
|
.DS_Store
|
||||||
|
.directory
|
||||||
|
*.debug
|
||||||
|
Makefile*
|
||||||
|
*.prl
|
||||||
|
*.app
|
||||||
|
moc_*.cpp
|
||||||
|
ui_*.h
|
||||||
|
qrc_*.cpp
|
||||||
|
Thumbs.db
|
||||||
|
*.res
|
||||||
|
*.rc
|
||||||
|
/.qmake.cache
|
||||||
|
/.qmake.stash
|
||||||
|
|
||||||
|
# qtcreator generated files
|
||||||
|
*.pro.user*
|
||||||
|
|
||||||
|
# xemacs temporary files
|
||||||
|
*.flc
|
||||||
|
|
||||||
|
# Vim temporary files
|
||||||
|
.*.swp
|
||||||
|
|
||||||
|
# Visual Studio generated files
|
||||||
|
*.ib_pdb_index
|
||||||
|
*.idb
|
||||||
|
*.ilk
|
||||||
|
*.pdb
|
||||||
|
*.sln
|
||||||
|
*.suo
|
||||||
|
*.vcproj
|
||||||
|
*vcproj.*.*.user
|
||||||
|
*.ncb
|
||||||
|
*.sdf
|
||||||
|
*.opensdf
|
||||||
|
*.vcxproj
|
||||||
|
*vcxproj.*
|
||||||
|
|
||||||
|
# MinGW generated files
|
||||||
|
*.Debug
|
||||||
|
*.Release
|
||||||
|
|
||||||
|
# Python byte code
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Binaries
|
||||||
|
# --------
|
||||||
|
*.dll
|
||||||
|
*.exe
|
||||||
|
|
26
UnitTests/UnitTests.pro
Normal file
26
UnitTests/UnitTests.pro
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
QT += testlib
|
||||||
|
QT -= gui
|
||||||
|
|
||||||
|
CONFIG(release, debug|release): {
|
||||||
|
DESTDIR="$$PWD/build/release"
|
||||||
|
} else {
|
||||||
|
DESTDIR="$$PWD/build/debug"
|
||||||
|
}
|
||||||
|
|
||||||
|
include('$$PWD/../QuasarAppLib/QuasarLib.pri')
|
||||||
|
include('$$PWD/../Deploy/Deploy.pri')
|
||||||
|
|
||||||
|
CONFIG += qt console warn_on depend_includepath testcase
|
||||||
|
CONFIG -= app_bundle
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
SOURCES += tst_deploytest.cpp
|
120
UnitTests/tst_deploytest.cpp
Normal file
120
UnitTests/tst_deploytest.cpp
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
/*
|
||||||
|
* 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>
|
||||||
|
#include <deployutils.h>
|
||||||
|
#include <deploy.h>
|
||||||
|
#include <windependenciesscanner.h>
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
// add necessary includes here
|
||||||
|
|
||||||
|
class deploytest : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
deploytest();
|
||||||
|
~deploytest();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void initTestCase();
|
||||||
|
void cleanupTestCase();
|
||||||
|
void testDeployUtils();
|
||||||
|
void testDeploy();
|
||||||
|
void testDeployScaner();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
deploytest::deploytest(){}
|
||||||
|
|
||||||
|
deploytest::~deploytest(){}
|
||||||
|
|
||||||
|
void deploytest::initTestCase() {
|
||||||
|
QDir qt;
|
||||||
|
qt.mkpath("./test/Qt/5.12/");
|
||||||
|
qt.mkpath("./test/extraPath/");
|
||||||
|
qt.mkpath("./test/extra/");
|
||||||
|
qt.mkpath("./test/warning/");
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void deploytest::cleanupTestCase() {
|
||||||
|
QDir qt("./test");
|
||||||
|
qt.removeRecursively();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void deploytest::testDeployUtils() {
|
||||||
|
QString qtDir = "./test/Qt/5.12/";
|
||||||
|
QStringList extraPathes = QStringList() << QFileInfo("./test/extraPath/").absoluteFilePath();
|
||||||
|
|
||||||
|
DeployUtils::qtDir = QFileInfo(qtDir).absoluteFilePath();
|
||||||
|
DeployUtils::extraPaths = extraPathes;
|
||||||
|
|
||||||
|
// qt Dir
|
||||||
|
QVERIFY(DeployUtils::isQtLib("./test/Qt/5.12/myLib.so"));
|
||||||
|
QVERIFY(!DeployUtils::isQtLib("/myQtDur/Qt/5.11/myLib.so"));
|
||||||
|
QVERIFY(!DeployUtils::isQtLib("/mQtDur/Qt/5.12/myLib.so"));
|
||||||
|
QVERIFY(DeployUtils::isQtLib("./test/Qt/5.12/myLib/testlibs/mylib.so"));
|
||||||
|
|
||||||
|
// extra Dir
|
||||||
|
QVERIFY(!DeployUtils::isExtraLib("./test/Qt/5.12/myLib.so"));
|
||||||
|
QVERIFY(!DeployUtils::isExtraLib("/myQtDur/Qt/5.11/myLib.so"));
|
||||||
|
QVERIFY(!DeployUtils::isExtraLib("/mQtDur/Qt/5.12/myLib.so"));
|
||||||
|
QVERIFY(!DeployUtils::isExtraLib("./test/Qt/5.12/myLib/testlibs/mylib.so"));
|
||||||
|
|
||||||
|
QVERIFY(DeployUtils::isExtraLib("./test/extraPath/Qt/5.12/myLib.so"));
|
||||||
|
QVERIFY(DeployUtils::isExtraLib("./test/extraPath/Qt/5/myLib.so"));
|
||||||
|
QVERIFY(DeployUtils::isExtraLib("./test/extraPath/myLib.so"));
|
||||||
|
QVERIFY(DeployUtils::isExtraLib("./test/extraPath/Qt/5.12/myLib/testlibs/mylib.so"));
|
||||||
|
|
||||||
|
//getLibPriority
|
||||||
|
|
||||||
|
QVERIFY(DeployUtils::getLibPriority("./tst/Qt/5.12/generalLib.so") == 0);
|
||||||
|
QVERIFY(DeployUtils::getLibPriority("./test/Qt/5.12/generalLib.so") == 3);
|
||||||
|
QVERIFY(DeployUtils::getLibPriority("./test/extraPath/ExtraLib.so") == 2);
|
||||||
|
QVERIFY(DeployUtils::getLibPriority("./test/extra/ExtraLib.so") == 1);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void deploytest::testDeploy() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void deploytest::testDeployScaner() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QTEST_APPLESS_MAIN(deploytest)
|
||||||
|
|
||||||
|
#include "tst_deploytest.moc"
|
Loading…
x
Reference in New Issue
Block a user