diff mbox series

[1/2] tcl: rewrite ptest (again)

Message ID 20260303172009.2064612-1-ross.burton@arm.com
State New
Headers show
Series [1/2] tcl: rewrite ptest (again) | expand

Commit Message

Ross Burton March 3, 2026, 5:20 p.m. UTC
I discovered that running a single test case with tcltest doesn't let
you know if the test failed or not, so when run-ptest moved away from
using all.tcl[1] we were always marking the tests as passing.

So, revert that commit and use all.tcl as a test runner. This is more
noisy, but importantly will let us know if a test failed.

Remove our un-upstreamable tweaks to the interp tests and instead skip
the test that is known to be fragile, so we don't have to carry a patch
forever.

Don't install another copy of the entire Tcl library for the tests, as
there is no real point.  This does then expose a bug in the tests where
clock-59.2 assumes that it is running in a source tree and behaves
differently if the system tzdata is being used.  This is being worked on
upstream[2], for now skip this test.

Clean up musl overriding so it's more resiliant.

Exit 1 if a test fails.

[1] oe-core 9c41887f2a ("tcl: improve test execution loop")
[2] https://core.tcl-lang.org/tcl/tktview/51aa53616067cb63900b17ca1d71f07b094ffa1a

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 .../0005-tcl-fix-race-in-interp.test.patch    | 40 -------------------
 meta/recipes-devtools/tcltk/tcl/run-ptest     | 24 +++++++++--
 meta/recipes-devtools/tcltk/tcl_9.0.3.bb      |  6 +--
 3 files changed, 21 insertions(+), 49 deletions(-)
 delete mode 100644 meta/recipes-devtools/tcltk/tcl/0005-tcl-fix-race-in-interp.test.patch
diff mbox series

Patch

diff --git a/meta/recipes-devtools/tcltk/tcl/0005-tcl-fix-race-in-interp.test.patch b/meta/recipes-devtools/tcltk/tcl/0005-tcl-fix-race-in-interp.test.patch
deleted file mode 100644
index 07912da5b3..0000000000
--- a/meta/recipes-devtools/tcltk/tcl/0005-tcl-fix-race-in-interp.test.patch
+++ /dev/null
@@ -1,40 +0,0 @@ 
-From fd75e3613613726786c54a25ee611c5176b33510 Mon Sep 17 00:00:00 2001
-From: Ross Burton <ross.burton@arm.com>
-Date: Mon, 12 Jul 2021 14:50:13 +0100
-Subject: [PATCH] tcl: fix race in interp.test
-
-The interp-36.7 patch has race conditions and is missing cleanup.  This patch by
-a Tcl maintainer should improve matters.
-
-Upstream-Status: Pending
-Signed-off-by: Ross Burton <ross.burton@arm.com>
----
- tests/interp.test | 7 ++++---
- 1 file changed, 4 insertions(+), 3 deletions(-)
-
-diff --git a/tests/interp.test b/tests/interp.test
-index 0092a03..eecfd3b 100644
---- a/tests/interp.test
-+++ b/tests/interp.test
-@@ -3614,17 +3614,18 @@ test interp-36.7 {ChildBgerror sets error handler of child [1999035]} -setup {
- 	variable result
- 	set result [lindex $args 0]
-     }
-+    set tout [after 5000 {set result timeout}]
- } -body {
-     child eval {
- 	variable done {}
- 	after 0 error foo
--	after 10 [list ::set [namespace which -variable done] {}]
--	vwait [namespace which -variable done]
-     }
-+    vwait result
-     set result
- } -cleanup {
-+    after cancel $tout
-     variable result {}
--    unset -nocomplain result
-+    unset -nocomplain result tout
-     interp delete child
- } -result foo
- 
diff --git a/meta/recipes-devtools/tcltk/tcl/run-ptest b/meta/recipes-devtools/tcltk/tcl/run-ptest
index 506529eada..dc61d66cc1 100644
--- a/meta/recipes-devtools/tcltk/tcl/run-ptest
+++ b/meta/recipes-devtools/tcltk/tcl/run-ptest
@@ -1,13 +1,19 @@ 
 #!/bin/sh
 
-export TCL_LIBRARY=@libdir@/tcl/ptest/library
-export ERROR_ON_FAILURES=1
+set -u
+
 export LANG=en-US.UTF-8
 
+# Tell all.tcl to exit with an error code if there are failing tests
+export ERROR_ON_FAILURES=1
+
 # Some tests are overly strict with timings and fail on loaded systems.
 SKIP=""
 # 15321
 SKIP="$SKIP async-\* event-\*"
+# This test behaves differently when using a system tzdata, skip until fixed upstream
+# https://core.tcl-lang.org/tcl/tktview/51aa53616067cb63900b17ca1d71f07b094ffa1a
+SKIP="$SKIP clock-59.2\*"
 # 14882
 SKIP="$SKIP cmdMZ-6.6"
 # 15081
@@ -16,6 +22,8 @@  SKIP="$SKIP exit-1.\*"
 SKIP="$SKIP \*io-46.1"
 # io-13.6 explicitly says it can fail on slow/loaded machines
 SKIP="$SKIP \*io-13.6"
+# Has race conditions and is missing cleanup
+SKIP="$SKIP interp-36.7"
 # The socket tests seem to be problematic with tight timing conditions, skip them all.
 # 14825 15495
 SKIP="$SKIP socket-\* socket_inet\* socket_inet6\*"
@@ -25,11 +33,19 @@  SKIP="$SKIP http11-\*"
 # tries to access google.com
 SKIP="$SKIP httpProxy-\*"
 
-for name in tests/*.test; do
-    ./tcltest $name -skip "$SKIP"
+# Run all tests in tests/*.test unless tests are specified as arguments
+TESTS=${*:-tests/*.test}
+
+exitcode=0
+for name in $TESTS; do
+    ./tcltest tests/all.tcl -file $(basename $name) -tmpdir /tmp -skip "$SKIP"
     if [ $? -eq 0 ]; then
         echo "PASS: $name"
     else
         echo "FAIL: $name"
+        exitcode=1
     fi
+    echo
 done
+
+exit $exitcode
diff --git a/meta/recipes-devtools/tcltk/tcl_9.0.3.bb b/meta/recipes-devtools/tcltk/tcl_9.0.3.bb
index 21a6cbb23d..3c0a257238 100644
--- a/meta/recipes-devtools/tcltk/tcl_9.0.3.bb
+++ b/meta/recipes-devtools/tcltk/tcl_9.0.3.bb
@@ -21,7 +21,6 @@  SRC_URI = "${SOURCEFORGE_MIRROR}/tcl/tcl-core${PV}-src.tar.gz \
            file://0002-tcl-fix-a-build-issue.patch \
            file://0003-tcl-install-tcl-to-lib64-instead-of-lib-on-64bit-tar.patch \
            file://0004-tcl-update-the-header-location.patch \
-           file://0005-tcl-fix-race-in-interp.test.patch \
            "
 SRC_URI[sha256sum] = "407a073ee8f718200c3a004bc2186deccc33356ee5112a71d8b01b55230f4ee4"
 
@@ -80,15 +79,12 @@  do_compile_ptest() {
 
 do_install_ptest() {
 	cp ${B}/tcltest ${D}${PTEST_PATH}
-	cp -r ${S}/library ${D}${PTEST_PATH}
 	cp -r ${S}/tests ${D}${PTEST_PATH}
-        # handle multilib
-        sed -i s:@libdir@:${libdir}:g ${D}${PTEST_PATH}/run-ptest
 }
 
 do_install_ptest:append:libc-musl () {
 	# Assumes locales other than provided by musl-locales
-	sed -i '/SKIP="$SKIP socket.*$/a # unixInit-3* is suppressed due to hardcoded locale assumptions\nSKIP="$SKIP unixInit-3\\\*"' ${D}${PTEST_PATH}/run-ptest
+	sed -i '/SKIP="$SKIP.*$/a # unixInit-3* is suppressed due to hardcoded locale assumptions\nSKIP="$SKIP unixInit-3\\\*"' ${D}${PTEST_PATH}/run-ptest
 }
 
 # Fix some paths that might be used by Tcl extensions