| Ticket UUID: | 7abc1460c04b46880ae4e950befea5a5b45133d6 | ||
| Title: | tcltest: under Tk, runAllTests exits with status 0 before reporting errors | ||
| Type: | Bug | Created on: | 2026-11-16 09:57:55 |
| Submitter: | serhiy.storchaka | Assigned to: | nobody |
| Subsystem: | 34. tcltest Package | Severity: | Minor |
| Priority: | 5 Medium | Last modified: | 2026-11-16 10:27:54 |
| Status: | Open | Closed by: | nobody |
| Resolution: | None | Closed on: | |
| Version: | 8.6.18, 9.0.5, 9.1.0 | ||
| Description: | ||||
|
Under Tk, cleanupTests exits so that a test file run as the main script (wish foo.test) does not wait in the event loop. But runAllTests also calls cleanupTests 1 after the last test file, and when the all file is the main script, this exits too, with status 0, before runAllTests lists the test files that exited with errors and before it returns its result. So under Tk, if {[tcltest::runAllTests]} {exit 1} never exits with 1, and "Test files exiting with errors" is never printed. all.tcl:
package require Tk
package require tcltest
tcltest::configure -testdir [file dirname [file normalize [info script]]] {*}$argv
if {[tcltest::runAllTests]} {
exit 1
}
fail.test:
package require tcltest
namespace import tcltest::*
test fail-1.1 {a failing test} -body {expr 1} -result 2
cleanupTests
wish all.tcl prints Failed 1 but exits with status 0, with Tcl 8.6.18 and with the current main, with -singleproc 0 and 1.
This makes the CI of Tk report success when tests fail at startup. Suggested fix: do not exit in cleanupTests when it is called from runAllTests. At the end of runAllTests, where the exit is needed (under Tk, with the all file as the main script), exit with status 1 if there were failures or test file errors, and 0 otherwise; elsewhere return the result as documented. Scripts which do not check the result keep working, but such runs then end with a non-zero status when tests fail. | ||||
| User Comments: | ||||
serhiy.storchaka added on 2026-11-16 09:58:21:
Tk ticket: ead4782b08, with a workaround in Tk branch ci-test-exit-status. serhiy.storchaka added on 2026-11-16 10:27:54:
Proposed fix in branch tcltest-runalltests-exit-status. | ||||
