Tcl Source Code

View Ticket
Login
2026-11-17
14:06 • Ticket [2884e645a5] tcltest-29.2 fails status still Open with 3 other change... artifact: 36afc91474 user: serhiy.storchaka
12:10
Fix [7abc1460c0]: under Tk, runAllTests exited with status 0 before reporting errors check-in: f1c3430326 user: jan.nijtmans tags: core-8-6-branch
12:08
Fix [7abc1460c0]: under Tk, runAllTests exited with status 0 before reporting errors check-in: 6c569928e0 user: jan.nijtmans tags: core-9-0-branch
2026-11-16
14:44
Fix [7abc1460c0]: under Tk, runAllTests exited with status 0 before reporting errors check-in: fc10972b81 user: jan.nijtmans tags: trunk, main
10:27 • Ticket [7abc1460c0] tcltest: under Tk, runAllTests exits with status 0 before re... artifact: 51b6cc31ee user: serhiy.storchaka
10:10
Fix [7abc1460c0]: under Tk, runAllTests exited with status 0 before reporting errors. cleanupTests, ... closed check-in: 87296fe492 user: serhiy.storchaka tags: tcltest-runalltests-exit-status
09:58 • Ticket [7abc1460c0] tcltest: under Tk, runAllTests exits with status 0 before re... artifact: f212efc2c3 user: serhiy.storchaka
09:57 • New ticket [7abc1460c0]. artifact: 1fc1cb25ab user: serhiy.storchaka

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.