summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorten Sørvig <[email protected]>2025-11-07 15:53:09 +0100
committerMorten Sørvig <[email protected]>2025-11-18 14:40:46 +0100
commit0b999525598d2a269b7249c51ab432946feb9c7e (patch)
tree3a2480f6d9ecc9193851e94035615695f48e5101
parenta687ee6f3ab4172c6ae48496c00b069e8e38104f (diff)
wasm: run the current test by default
Make the test runner run the current test by default in non-batched mode, without requiring a testname parameter. Change-Id: Ia74f5a3db4a5c4a8d9f6a41073520653781d0f17 Reviewed-by: Lorn Potter <[email protected]> Reviewed-by: Tor Arne Vestbø <[email protected]>
-rw-r--r--src/corelib/Qt6WasmMacros.cmake2
-rw-r--r--util/wasm/batchedtestrunner/README.md3
-rw-r--r--util/wasm/batchedtestrunner/batchedtestrunner.html4
-rw-r--r--util/wasm/batchedtestrunner/qwasmtestmain.js13
4 files changed, 17 insertions, 5 deletions
diff --git a/src/corelib/Qt6WasmMacros.cmake b/src/corelib/Qt6WasmMacros.cmake
index 8efdc63c5fe..9ab51bf3e70 100644
--- a/src/corelib/Qt6WasmMacros.cmake
+++ b/src/corelib/Qt6WasmMacros.cmake
@@ -40,7 +40,7 @@ function(_qt_internal_wasm_add_target_helpers target)
if(is_test AND NOT is_manual_test)
# Keep in sync with testrunner_files in testlib/CMakeLists.txt
configure_file("${WASM_BUILD_DIR}/libexec/batchedtestrunner.html"
- "${target_output_directory}/${_target_output_name}.html" COPYONLY)
+ "${target_output_directory}/${_target_output_name}.html" @ONLY)
configure_file("${WASM_BUILD_DIR}/libexec/qtestoutputreporter.css"
"${target_output_directory}/qtestoutputreporter.css" COPYONLY)
configure_file("${WASM_BUILD_DIR}/libexec/batchedtestrunner.js"
diff --git a/util/wasm/batchedtestrunner/README.md b/util/wasm/batchedtestrunner/README.md
index a5d165c6305..ae22c168351 100644
--- a/util/wasm/batchedtestrunner/README.md
+++ b/util/wasm/batchedtestrunner/README.md
@@ -49,6 +49,9 @@ Run all tests in a batch:
Run a single test in a batch:
- load the webpage batchedtestrunner.html?qtestname=tst_mytest
+Run a standalone test (non-batched mode):
+ - load the test-specific HTML file (e.g., tst_mytest.html)
+
Query for test execution state:
- qtTestRunner.onStatusChanged.addEventListener((runnerStatus) => (...)))
- qtTestRunner.onTestStatusChanged.addEventListener((testName, status) => (...))
diff --git a/util/wasm/batchedtestrunner/batchedtestrunner.html b/util/wasm/batchedtestrunner/batchedtestrunner.html
index 147cf34376a..682aeb010b0 100644
--- a/util/wasm/batchedtestrunner/batchedtestrunner.html
+++ b/util/wasm/batchedtestrunner/batchedtestrunner.html
@@ -7,9 +7,9 @@ SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-ex
<html>
<head>
<meta charset="utf-8">
- <title>WASM batched test runner (emrun-enabled)</title>
+ <title>@APPNAME@</title>
<link rel="stylesheet" href="qtestoutputreporter.css"></link>
- <script type="module" defer="defer" src="qwasmtestmain.js"></script>
+ <script type="module" defer="defer" src="qwasmtestmain.js" data-qtestname="@APPNAME@"></script>
</head>
<body></body>
</html>
diff --git a/util/wasm/batchedtestrunner/qwasmtestmain.js b/util/wasm/batchedtestrunner/qwasmtestmain.js
index a92a3a4b30a..ff74bd3b7ae 100644
--- a/util/wasm/batchedtestrunner/qwasmtestmain.js
+++ b/util/wasm/batchedtestrunner/qwasmtestmain.js
@@ -40,9 +40,18 @@ Object.defineProperty(StandardArg, 'isKnown', {
}
const parsed = parseQuery(location.search);
- const outputInPage = parsed.has(StandardArg.qVisualOutput);
- const testName = parsed.get(StandardArg.qTestName);
+
+ // Get test name from data attribute or query parameter
+ const getTestNameFromDataAttribute = () => {
+ const scriptTag = document.querySelector('script[data-qtestname]');
+ return scriptTag?.dataset?.qtestname;
+ };
+
const isBatch = parsed.has(StandardArg.qBatchedTest);
+ const testName = parsed.get(StandardArg.qTestName) ??
+ (isBatch ? undefined : getTestNameFromDataAttribute());
+ const outputInPage = parsed.has(StandardArg.qVisualOutput) ||
+ (!parsed.has(StandardArg.qUseEmrun) && testName !== undefined);
const useEmrun = parsed.has(StandardArg.qUseEmrun);
const functions = [...parsed.keys()].filter(arg => !StandardArg.isKnown(arg));