From a2858a883b73707ab2a226975201c8558d6a991d Mon Sep 17 00:00:00 2001 From: Ming Rui Zhang <mingrui.zhang@savoirfairelinux.com> Date: Fri, 7 May 2021 10:38:19 -0400 Subject: [PATCH] test: change the location of local storage files when running tests Change-Id: I6ee537ee1ee3928c93b9a579e2b55b6ef97af779 --- INSTALL.md | 16 +++++++++++++--- make-client.py | 12 ++++++++++++ tests/qml/main.cpp | 2 ++ tests/unittests/main_unittest.cpp | 4 ++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index c00ce13fa..7dabb8a45 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -127,8 +127,8 @@ Only 64-bit MSVC build can be compiled. ```sh git clone https://review.jami.net/ring-project cd ring-project/ - git submodule update --init daemon lrc client-windows - git submodule update --recursive --remote daemon lrc client-windows + git submodule update --init daemon lrc client-qt + git submodule update --recursive --remote daemon lrc client-qt ``` - Using **Elevated Command Prompt** ```sh @@ -212,7 +212,7 @@ Only 64-bit MSVC build can be compiled. - In Visual Studio, download WiX Toolset Visual Studio Extension. - Build client-windows project first, then the JamiInstaller project, msi package should be stored in ring-project\client-windows\JamiInstaller\bin\Release -## Testing For Client-qt +## Testing for Client-qt on Windows - We currently use [GoogleTest](https://github.com/google/googletest) and [Qt Quick Test](https://doc.qt.io/qt-5/qtquicktest-index.html#introduction) in our product. To build and run tests, you could use the following command. @@ -221,6 +221,16 @@ Only 64-bit MSVC build can be compiled. python make-client.py runtests ``` +- Note that, for tests, the path of local storage files for jami will be changed based on following environment variables. + +``` + %JAMI_DATA_HOME% = %TEMP% + '\\jami_test\\jami' + %JAMI_CONFIG_HOME% = %TEMP% + '\\jami_test\\.config' + %JAMI_CACHE_HOME% = %TEMP% + '\\jami_test\\.cache' +``` + +- These environment variables will be temporarily set when using make-client.py to run tests. + ## Debugging Compile the client with `BUILD=Debug` and compile LibRingClient with diff --git a/make-client.py b/make-client.py index 7a7a1cec8..30800e75a 100644 --- a/make-client.py +++ b/make-client.py @@ -21,6 +21,7 @@ vs_where_path = os.path.join( host_is_64bit = (False, True)[platform.machine().endswith('64')] this_dir = os.path.dirname(os.path.realpath(__file__)) build_dir = this_dir + '\\build' +temp_path = os.environ['TEMP'] # project path jami_qt_project = build_dir + '\\jami-qt.vcxproj' @@ -31,6 +32,11 @@ qml_test_project = build_dir + '\\tests\\qml_tests.vcxproj' qml_test_exe = this_dir + '\\x64\\test\\qml_tests.exe -input ' + this_dir + '\\tests\\qml' unit_test_exe = this_dir + '\\x64\\test\\unittests.exe' +# test env path +test_data_dir = temp_path + '\\jami_test\\jami' +test_config_dir = temp_path + '\\jami_test\\.config' +test_cache_dir = temp_path + '\\jami_test\\.cache' + class QtVerison(Enum): Major = 0 Minor = 1 @@ -308,6 +314,12 @@ def run_tests(mute_dring, output_to_files): # make sure that the tests are rendered offscreen os.environ["QT_QPA_PLATFORM"] = 'offscreen' os.environ["QT_QUICK_BACKEND"] = 'software' + + # set test env variables + os.environ["JAMI_DATA_HOME"] = test_data_dir + os.environ["JAMI_CONFIG_HOME"] = test_config_dir + os.environ["JAMI_CACHE_HOME"] = test_cache_dir + for test_exe_command in test_exe_command_list: if (execute_cmd(test_exe_command, True)): test_result_code = 1 diff --git a/tests/qml/main.cpp b/tests/qml/main.cpp index 89d11c3ad..93f26b6d6 100644 --- a/tests/qml/main.cpp +++ b/tests/qml/main.cpp @@ -195,6 +195,8 @@ main(int argc, char** argv) argc = std::distance(argv, end); } + QStandardPaths::setTestModeEnabled(true); + QTEST_SET_MAIN_SOURCE_PATH Setup setup(muteDring); return quick_test_main_with_setup(argc, argv, "qml_test", nullptr, &setup); diff --git a/tests/unittests/main_unittest.cpp b/tests/unittests/main_unittest.cpp index 45a025d9d..8a28e5b45 100644 --- a/tests/unittests/main_unittest.cpp +++ b/tests/unittests/main_unittest.cpp @@ -20,6 +20,8 @@ #include "globaltestenvironment.h" #include <QApplication> +#include <QStandardPaths> + #include <gtest/gtest.h> bool muteDring; @@ -40,6 +42,8 @@ main(int argc, char* argv[]) argc = std::distance(argv, end); } + QStandardPaths::setTestModeEnabled(true); + QApplication a(argc, argv); a.processEvents(); ::testing::InitGoogleTest(&argc, argv); -- GitLab