Tcl Source Code

View Ticket
Login
Ticket UUID: 8413e79232449d82d512edfee22ded5701f683b5
Title: tcltest should not exit an application
Type: Bug Created on: 2020-01-29 16:47:09
Submitter: tombert Assigned to: jan.nijtmans
Subsystem: 34. tcltest Package Severity: Minor
Priority: 5 Medium Last modified: 2026-10-28 13:44:23
Status: Closed Closed by: jan.nijtmans
Resolution: Fixed Closed on: 2026-10-28 13:44:23
Version: 8.6.18, 9.0.5, 9.1.0
Description:
Well, the comment says it all.
From tcltest-2.5.1.tm:

# exit only if running Tk in non-interactive mode
#This should be changed to determine if an event
# loop is running, which is the real issue.
# Actually, this doesn't belong here at all.  A package
# really has no business [exit]-ing an application.
if {![catch {package present Tk}] && ![testConstraint interactive]} {
    exit
}

Took me an hour because I thought TCL is crashing. Here I see it's exiting.
Please fix/remove the exit from this code.

Regards
User Comments:
serhiy.storchaka added on 2026-10-20 19:51:17:

Still the case on main, 9.0 and 8.6. The exit is there so that wish foo.test does not stay in the event loop after the tests, so simply removing it would change how Tk test files run.

Proposed fix in branch [2052c30735|tcltest-no-exit-when-sourced]: cleanupTests exits only when, in addition, the test file is the main script of the application ([file normalize [info script]] eq [file normalize $::argv0]). An application that sources a test file keeps running. wish foo.test and Tk's all.tcl exit as before. The behaviour is now documented in tcltest.n; new test tcltest-29.1.


jan.nijtmans added on 2026-10-22 08:31:11:

Fixed in [891b7e7921|trunk], not backported yet to 9.0 and 8.6


jan.nijtmans added on 2026-10-28 13:44:23:

Now also backported to core-9-0-branch and core-8-6-branch

Closing. Many thanks!