diff options
| author | Dimitrios Apostolou <[email protected]> | 2025-10-18 03:01:16 +0200 |
|---|---|---|
| committer | Dimitrios Apostolou <[email protected]> | 2025-12-12 00:11:08 +0100 |
| commit | 79a34b923351ac36252618c43b9f614cfa2e86f2 (patch) | |
| tree | 9fc804a11506be3e26abc64bf979d7a85d9c3523 | |
| parent | c6aa0ac70fe6c37ec7dcaa8df1a892580b43cac6 (diff) | |
qt_testrunner: fix execution of qt_mock_test.py under testing on windows
tst_qt_testrunner.py invokes qt_testrunner.py which invokes qt_mock_test.py.
On Windows a python script is not directly executable. It needs to be
executed as "python.exe script.py". To achieve that when testing,
the tests set the env var QT_TESTRUNNER_TESTING. When qt-testrunner
detects that, it prepends the command line with
sys.executable which is the currently used python interpreter.
Doing so also ensures that all sub-scripts are executed with the same
Python version.
Pick-to: 6.11 6.10 6.8
Change-Id: I4786e4015ded328077fd9cc7b443f4b4d9d69de7
Reviewed-by: MÃ¥rten Nordheim <[email protected]>
Reviewed-by: Edward Welbourne <[email protected]>
| -rwxr-xr-x | util/testrunner/qt-testrunner.py | 6 | ||||
| -rwxr-xr-x | util/testrunner/tests/tst_testrunner.py | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/util/testrunner/qt-testrunner.py b/util/testrunner/qt-testrunner.py index 6437c3fe7f1..52d11dfeee6 100755 --- a/util/testrunner/qt-testrunner.py +++ b/util/testrunner/qt-testrunner.py @@ -299,6 +299,12 @@ def parse_log(results_file) -> WhatFailed: def run_test(arg_list: List[str], **kwargs): + if (os.environ.get("QT_TESTRUNNER_TESTING", "0") == "1" + and os.name == "nt" + and arg_list[0].endswith(".py") + ): + # For executing qt_mock_test.py under the same Python interpreter when testing. + arg_list = [ sys.executable ] + arg_list L.debug("Running test command line: %s", arg_list) proc = subprocess.run(arg_list, **kwargs) L.info("Test process exited with code: %d", proc.returncode) diff --git a/util/testrunner/tests/tst_testrunner.py b/util/testrunner/tests/tst_testrunner.py index ab376741aa0..89e98191c13 100755 --- a/util/testrunner/tests/tst_testrunner.py +++ b/util/testrunner/tests/tst_testrunner.py @@ -40,6 +40,7 @@ def setUpModule(): os.environ["QT_MOCK_TEST_STATE_FILE"] = filename os.environ["QT_MOCK_TEST_XML_TEMPLATE_FILE"] = xml_log_template + os.environ["QT_TESTRUNNER_TESTING"] = "1" def tearDownModule(): print("\ntearDownModule(): Cleaning up temporary directory:", |
