Overview
| Artifact ID: | 1fc1cb25ab54e5914e2e1f9d42022088f151b810ae0a1773f7aab0ca522245c5 |
|---|---|
| Ticket: | 7abc1460c04b46880ae4e950befea5a5b45133d6
tcltest: under Tk, runAllTests exits with status 0 before reporting errors |
| User & Date: | serhiy.storchaka on 2026-11-16 09:57:55 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-wiki"
- comment changed to:
Under Tk, <tt>cleanupTests</tt> exits so that a test file run as the main script (<tt>wish foo.test</tt>) does not wait in the event loop. But <tt>runAllTests</tt> also calls <tt>cleanupTests 1</tt> after the last test file, and when the all file is the main script, this exits too, with status 0, before <tt>runAllTests</tt> lists the test files that exited with errors and before it returns its result. So under Tk, <tt>if {[tcltest::runAllTests]} {exit 1}</tt> never exits with 1, and "Test files exiting with errors" is never printed. all.tcl: <pre> package require Tk package require tcltest tcltest::configure -testdir [file dirname [file normalize [info script]]] {*}$argv if {[tcltest::runAllTests]} { exit 1 } </pre> fail.test: <pre> package require tcltest namespace import tcltest::* test fail-1.1 {a failing test} -body {expr 1} -result 2 cleanupTests </pre> <tt>wish all.tcl</tt> prints <tt>Failed 1</tt> but exits with status 0, with Tcl 8.6.18 and with the current main, with <tt>-singleproc</tt> 0 and 1. This makes the CI of Tk report success when tests fail at startup. Suggested fix: do not exit in <tt>cleanupTests</tt> when it is called from <tt>runAllTests</tt>. At the end of <tt>runAllTests</tt>, 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. - foundin changed to: "8.6.18, 9.0.5, 9.1.0"
- is_private changed to: "0"
- login: "serhiy.storchaka"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- severity changed to: "Minor"
- status changed to: "Open"
- submitter changed to: "serhiy.storchaka"
- subsystem changed to: "34. tcltest Package"
- title changed to:
tcltest: under Tk, runAllTests exits with status 0 before reporting errors
- type changed to: "Bug"