From 1238920b60e9dc24b82a6105d25e2b2526ec9b07 Mon Sep 17 00:00:00 2001 From: MrMirDan Date: Tue, 28 Apr 2026 16:46:58 +0300 Subject: [PATCH] update: rewrited env's, qtest include and clear clients in some tests --- .github/workflows/deploy.yml | 113 +++++------------- client/tests/testAdminSelfHostedExport.cpp | 7 +- client/tests/testComplexOperations.cpp | 7 +- client/tests/testDefaultServerChange.cpp | 7 +- client/tests/testGatewayStacks.cpp | 7 +- client/tests/testMultipleExports.cpp | 14 +-- client/tests/testMultipleImports.cpp | 7 +- client/tests/testSelfHostedServerSetup.cpp | 7 +- client/tests/testSerialization.cpp | 17 ++- client/tests/testServerEdgeCases.cpp | 7 +- client/tests/testServerEdit.cpp | 7 +- client/tests/testServersModelSync.cpp | 7 +- client/tests/testSettingsSignals.cpp | 7 +- client/tests/testSignalOrder.cpp | 7 +- .../testUiAllowedDnsModelAndController.cpp | 13 +- .../tests/testUiAppSTModelAndController.cpp | 10 +- .../testUiLanguageModelAndController.cpp | 7 +- .../tests/testUiServersModelAndController.cpp | 7 +- .../tests/testUiSitesModelAndController.cpp | 13 +- 19 files changed, 64 insertions(+), 207 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index fda0cbfb4..dd58c8e09 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -743,6 +743,16 @@ jobs: env: QT_VERSION: 6.10.1 + TEST_SELF_HOSTED_CONFIG: ${{ secrets.TEST_SELF_HOSTED_CONFIG }} + TEST_APP_PATH: ${{ secrets.TEST_APP_PATH }} + TEST_SITES_LIST_PATH: ${{ secrets.TEST_SITES_LIST_PATH }} + TEST_DNS_LIST_PATH: ${{ secrets.TEST_DNS_LIST_PATH }} + TEST_EXPORT_PATH: ${{ secrets.TEST_EXPORT_PATH }} + TEST_KEY_VMESS_NEW: ${{ secrets.TEST_KEY_VMESS_NEW }} + TEST_KEY_VMESS: ${{ secrets.TEST_KEY_VMESS }} + TEST_KEY_TROJAN: ${{ secrets.TEST_KEY_TROJAN }} + TEST_KEY_SS: ${{ secrets.TEST_KEY_SS }} + TEST_KEY_SSD: ${{ secrets.TEST_KEY_SSD }} steps: - name: 'Get sources' @@ -812,6 +822,16 @@ jobs: env: QT_VERSION: 6.10.1 + TEST_SELF_HOSTED_CONFIG: ${{ secrets.TEST_SELF_HOSTED_CONFIG }} + TEST_APP_PATH: ${{ secrets.TEST_APP_PATH }} + TEST_SITES_LIST_PATH: ${{ secrets.TEST_SITES_LIST_PATH }} + TEST_DNS_LIST_PATH: ${{ secrets.TEST_DNS_LIST_PATH }} + TEST_EXPORT_PATH: ${{ secrets.TEST_EXPORT_PATH }} + TEST_KEY_VMESS_NEW: ${{ secrets.TEST_KEY_VMESS_NEW }} + TEST_KEY_VMESS: ${{ secrets.TEST_KEY_VMESS }} + TEST_KEY_TROJAN: ${{ secrets.TEST_KEY_TROJAN }} + TEST_KEY_SS: ${{ secrets.TEST_KEY_SS }} + TEST_KEY_SSD: ${{ secrets.TEST_KEY_SSD }} steps: - name: 'Get sources' @@ -871,6 +891,16 @@ jobs: env: QT_VERSION: 6.10.1 + TEST_SELF_HOSTED_CONFIG: ${{ secrets.TEST_SELF_HOSTED_CONFIG }} + TEST_APP_PATH: ${{ secrets.TEST_APP_PATH }} + TEST_SITES_LIST_PATH: ${{ secrets.TEST_SITES_LIST_PATH }} + TEST_DNS_LIST_PATH: ${{ secrets.TEST_DNS_LIST_PATH }} + TEST_EXPORT_PATH: ${{ secrets.TEST_EXPORT_PATH }} + TEST_KEY_VMESS_NEW: ${{ secrets.TEST_KEY_VMESS_NEW }} + TEST_KEY_VMESS: ${{ secrets.TEST_KEY_VMESS }} + TEST_KEY_TROJAN: ${{ secrets.TEST_KEY_TROJAN }} + TEST_KEY_SS: ${{ secrets.TEST_KEY_SS }} + TEST_KEY_SSD: ${{ secrets.TEST_KEY_SSD }} steps: - name: 'Setup xcode' @@ -921,86 +951,3 @@ jobs: ctest --test-dir build/client --output-on-failure -# ------------------------------------------------------ - - Test-Android: - runs-on: ubuntu-latest - - env: - QT_VERSION: 6.10.1 - QT_MODULES: 'qtremoteobjects qt5compat qtimageformats qtshadertools' - - steps: - - name: 'Get sources' - uses: actions/checkout@v4 - with: - submodules: 'true' - fetch-depth: 10 - - - name: 'Install Qt (host)' - uses: jurplel/install-qt-action@v4 - with: - version: ${{ env.QT_VERSION }} - host: 'linux' - target: 'desktop' - arch: 'linux_gcc_64' - modules: ${{ env.QT_MODULES }} - dir: ${{ runner.temp }} - set-env: 'true' - - - name: 'Install Qt (android arm64)' - uses: jurplel/install-qt-action@v4 - with: - version: ${{ env.QT_VERSION }} - host: 'linux' - target: 'android' - arch: 'android_arm64_v8a' - modules: ${{ env.QT_MODULES }} - dir: ${{ runner.temp }} - set-env: 'true' - - - name: 'Setup Java' - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: '17' - - - name: 'Setup Android NDK' - id: setup-ndk - uses: nttld/setup-ndk@v1 - with: - ndk-version: 'r26b' - - - name: 'Configure Android build' - run: | - QT_ANDROID=${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/android_arm64_v8a - QT_HOST=${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/gcc_64 - - cmake -B build-android -G Ninja \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_TOOLCHAIN_FILE=$QT_ANDROID/lib/cmake/Qt6/qt.toolchain.cmake \ - -DQT_HOST_PATH=$QT_HOST - - - name: 'Build Android' - run: cmake --build build-android - - - name: 'Configure tests (host)' - run: | - cmake -B build-host -G Ninja \ - -DCMAKE_BUILD_TYPE=Release \ - -DBUILD_TESTING=ON - - - name: 'Build tests' - run: cmake --build build-host - - - name: 'Run tests' - run: | - QT_ROOT=${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/gcc_64 - - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:\ - $QT_ROOT/lib:\ - $PWD/client/3rd-prebuilt/deploy-prebuilt/linux/x64 - - export QT_QPA_PLATFORM=offscreen - - ctest --test-dir build-host/client --output-on-failure diff --git a/client/tests/testAdminSelfHostedExport.cpp b/client/tests/testAdminSelfHostedExport.cpp index 439a93b27..4c6d326d0 100644 --- a/client/tests/testAdminSelfHostedExport.cpp +++ b/client/tests/testAdminSelfHostedExport.cpp @@ -5,12 +5,7 @@ #include #include #include - -#ifdef Q_OS_WIN - #include -#else - #include -#endif +#include #include "core/controllers/coreController.h" #include "core/models/serverConfig.h" diff --git a/client/tests/testComplexOperations.cpp b/client/tests/testComplexOperations.cpp index 931f6a51b..52103262c 100644 --- a/client/tests/testComplexOperations.cpp +++ b/client/tests/testComplexOperations.cpp @@ -2,12 +2,7 @@ #include #include #include - -#ifdef Q_OS_WIN - #include -#else - #include -#endif +#include #include "core/controllers/coreController.h" #include "core/models/serverConfig.h" diff --git a/client/tests/testDefaultServerChange.cpp b/client/tests/testDefaultServerChange.cpp index 675a8fa1e..e5288da42 100644 --- a/client/tests/testDefaultServerChange.cpp +++ b/client/tests/testDefaultServerChange.cpp @@ -2,12 +2,7 @@ #include #include #include - -#ifdef Q_OS_WIN - #include -#else - #include -#endif +#include #include "core/controllers/coreController.h" #include "core/models/serverConfig.h" diff --git a/client/tests/testGatewayStacks.cpp b/client/tests/testGatewayStacks.cpp index 2271f07f1..f51d99a07 100644 --- a/client/tests/testGatewayStacks.cpp +++ b/client/tests/testGatewayStacks.cpp @@ -2,12 +2,7 @@ #include #include #include - -#ifdef Q_OS_WIN - #include -#else - #include -#endif +#include #include "core/controllers/coreController.h" #include "core/models/serverConfig.h" diff --git a/client/tests/testMultipleExports.cpp b/client/tests/testMultipleExports.cpp index c88af391e..2b31d1b7d 100644 --- a/client/tests/testMultipleExports.cpp +++ b/client/tests/testMultipleExports.cpp @@ -4,12 +4,7 @@ #include #include #include - -#ifdef Q_OS_WIN - #include -#else - #include -#endif +#include #include "core/controllers/coreController.h" #include "core/models/serverConfig.h" @@ -28,8 +23,7 @@ private: QString getSHAdminConfig() { - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - return env.value("TEST_SELF_HOSTED_CONFIG"); + return QProcessEnvironment::systemEnvironment().value("TEST_SELF_HOSTED_CONFIG"); } private slots: @@ -53,6 +47,10 @@ private slots: void cleanupTestCase() { int serverIndex = m_coreController->m_serversRepository->defaultServerIndex(); + + for (int containerIndex = 1; containerIndex < 7; ++containerIndex) + m_coreController->m_installUiController->clearCachedProfile(serverIndex, containerIndex); + m_coreController->m_serversController->removeServer(serverIndex); qDebug() << "SERVER REMOVED\n"; diff --git a/client/tests/testMultipleImports.cpp b/client/tests/testMultipleImports.cpp index e4ad96d3c..a39235b58 100644 --- a/client/tests/testMultipleImports.cpp +++ b/client/tests/testMultipleImports.cpp @@ -3,12 +3,7 @@ #include #include #include - -#ifdef Q_OS_WIN - #include -#else - #include -#endif +#include #include "core/controllers/coreController.h" #include "core/models/serverConfig.h" diff --git a/client/tests/testSelfHostedServerSetup.cpp b/client/tests/testSelfHostedServerSetup.cpp index 184b40e32..842d76683 100644 --- a/client/tests/testSelfHostedServerSetup.cpp +++ b/client/tests/testSelfHostedServerSetup.cpp @@ -4,12 +4,7 @@ #include #include #include - -#ifdef Q_OS_WIN - #include -#else - #include -#endif +#include #include "core/controllers/coreController.h" #include "core/models/serverConfig.h" diff --git a/client/tests/testSerialization.cpp b/client/tests/testSerialization.cpp index 86717f3b9..f38d583ce 100644 --- a/client/tests/testSerialization.cpp +++ b/client/tests/testSerialization.cpp @@ -4,12 +4,7 @@ #include #include #include - -#ifdef Q_OS_WIN - #include -#else - #include -#endif +#include #include "core/controllers/coreController.h" #include "core/models/serverConfig.h" @@ -30,14 +25,12 @@ private: QString getSHAdminConfig() { - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - return env.value("TEST_SELF_HOSTED_CONFIG"); + return QProcessEnvironment::systemEnvironment().value("TEST_SELF_HOSTED_CONFIG"); } QString getKey(QString name) { - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - return env.value("TEST_KEY_" + name); + return QProcessEnvironment::systemEnvironment().value("TEST_KEY_" + name); } QJsonObject extractXrayConfig(const QString &data, ConfigTypes configType, const QString &description = "") const @@ -106,6 +99,10 @@ private slots: void cleanupTestCase() { int serverIndex = m_coreController->m_serversRepository->defaultServerIndex(); + + for (int containerIndex = 1; containerIndex < 7; ++containerIndex) + m_coreController->m_installUiController->clearCachedProfile(serverIndex, containerIndex); + m_coreController->m_serversController->removeServer(serverIndex); qDebug() << "SERVER REMOVED\n"; diff --git a/client/tests/testServerEdgeCases.cpp b/client/tests/testServerEdgeCases.cpp index 82e0b6ee6..68b2ec9e7 100644 --- a/client/tests/testServerEdgeCases.cpp +++ b/client/tests/testServerEdgeCases.cpp @@ -2,12 +2,7 @@ #include #include #include - -#ifdef Q_OS_WIN - #include -#else - #include -#endif +#include #include "core/controllers/coreController.h" #include "core/models/serverConfig.h" diff --git a/client/tests/testServerEdit.cpp b/client/tests/testServerEdit.cpp index 45009dc1c..a66f69608 100644 --- a/client/tests/testServerEdit.cpp +++ b/client/tests/testServerEdit.cpp @@ -2,12 +2,7 @@ #include #include #include - -#ifdef Q_OS_WIN - #include -#else - #include -#endif +#include #include "core/controllers/coreController.h" #include "core/models/serverConfig.h" diff --git a/client/tests/testServersModelSync.cpp b/client/tests/testServersModelSync.cpp index 773d720b9..5c15e4f05 100644 --- a/client/tests/testServersModelSync.cpp +++ b/client/tests/testServersModelSync.cpp @@ -2,12 +2,7 @@ #include #include #include - -#ifdef Q_OS_WIN - #include -#else - #include -#endif +#include #include "core/controllers/coreController.h" #include "core/models/serverConfig.h" diff --git a/client/tests/testSettingsSignals.cpp b/client/tests/testSettingsSignals.cpp index eef42b54c..540b6ddc8 100644 --- a/client/tests/testSettingsSignals.cpp +++ b/client/tests/testSettingsSignals.cpp @@ -3,12 +3,7 @@ #include #include #include - -#ifdef Q_OS_WIN - #include -#else - #include -#endif +#include #include "core/controllers/coreController.h" #include "core/models/serverConfig.h" diff --git a/client/tests/testSignalOrder.cpp b/client/tests/testSignalOrder.cpp index 61304dd19..ea8e38559 100644 --- a/client/tests/testSignalOrder.cpp +++ b/client/tests/testSignalOrder.cpp @@ -2,12 +2,7 @@ #include #include #include - -#ifdef Q_OS_WIN - #include -#else - #include -#endif +#include #include "core/controllers/coreController.h" #include "core/models/serverConfig.h" diff --git a/client/tests/testUiAllowedDnsModelAndController.cpp b/client/tests/testUiAllowedDnsModelAndController.cpp index 18144a96a..73577e795 100644 --- a/client/tests/testUiAllowedDnsModelAndController.cpp +++ b/client/tests/testUiAllowedDnsModelAndController.cpp @@ -4,12 +4,7 @@ #include #include #include - -#ifdef Q_OS_WIN - #include -#else - #include -#endif +#include #include "core/controllers/coreController.h" #include "core/models/serverConfig.h" @@ -28,14 +23,12 @@ private: QString getPath() { - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - return env.value("TEST_PATH"); + return QProcessEnvironment::systemEnvironment().value("TEST_DNS_LIST_PATH"); } QString getExportPath() { - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - return env.value("TEST_EXPORT_PATH"); + return QProcessEnvironment::systemEnvironment().value("TEST_EXPORT_PATH"); } private slots: diff --git a/client/tests/testUiAppSTModelAndController.cpp b/client/tests/testUiAppSTModelAndController.cpp index f9966a28d..a597269ca 100644 --- a/client/tests/testUiAppSTModelAndController.cpp +++ b/client/tests/testUiAppSTModelAndController.cpp @@ -4,12 +4,7 @@ #include #include #include - -#ifdef Q_OS_WIN - #include -#else - #include -#endif +#include #include "core/controllers/coreController.h" #include "core/models/serverConfig.h" @@ -28,8 +23,7 @@ private: QString getPath() { - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - return env.value("TEST_PATH"); + return QProcessEnvironment::systemEnvironment().value("TEST_APP_PATH"); } private slots: diff --git a/client/tests/testUiLanguageModelAndController.cpp b/client/tests/testUiLanguageModelAndController.cpp index 539d7a333..fad16b351 100644 --- a/client/tests/testUiLanguageModelAndController.cpp +++ b/client/tests/testUiLanguageModelAndController.cpp @@ -4,12 +4,7 @@ #include #include #include - -#ifdef Q_OS_WIN - #include -#else - #include -#endif +#include #include "core/controllers/coreController.h" #include "core/models/serverConfig.h" diff --git a/client/tests/testUiServersModelAndController.cpp b/client/tests/testUiServersModelAndController.cpp index 9cb500e93..93acda6a3 100644 --- a/client/tests/testUiServersModelAndController.cpp +++ b/client/tests/testUiServersModelAndController.cpp @@ -5,12 +5,7 @@ #include #include #include - -#ifdef Q_OS_WIN - #include -#else - #include -#endif +#include #include "core/controllers/coreController.h" #include "core/models/serverConfig.h" diff --git a/client/tests/testUiSitesModelAndController.cpp b/client/tests/testUiSitesModelAndController.cpp index bc308140a..18ba72cba 100644 --- a/client/tests/testUiSitesModelAndController.cpp +++ b/client/tests/testUiSitesModelAndController.cpp @@ -4,12 +4,7 @@ #include #include #include - -#ifdef Q_OS_WIN - #include -#else - #include -#endif +#include #include "core/controllers/coreController.h" #include "core/models/serverConfig.h" @@ -28,14 +23,12 @@ private: QString getPath() { - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - return env.value("TEST_PATH"); + return QProcessEnvironment::systemEnvironment().value("TEST_SITES_LIST_PATH"); } QString getExportPath() { - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - return env.value("TEST_EXPORT_PATH"); + return QProcessEnvironment::systemEnvironment().value("TEST_EXPORT_PATH"); } QString normalizeHostname(const QString &hostname) const