Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-05-22
09:45 • Closed ticket [5d70d14a09]: tcltest: test result differs for different singlepro... artifact: f09f3dac48 user: apnadkarni
2025-01-12
07:34 • Ticket [5d70d14a09]: 3 changes artifact: 7606176846 user: anonymous
07:19 • Ticket [5d70d14a09]: 3 changes artifact: fd26621362 user: anonymous
2025-01-11
23:52 • Ticket [5d70d14a09]: 3 changes artifact: ed366cc5f7 user: jan.nijtmans
23:03 • Ticket [5d70d14a09]: 3 changes artifact: c419b5ca92 user: jan.nijtmans
21:57
Possible fix for [5d70d14a09]: tcltest: test result differs for different singleproc values. Edit: d... leaf check-in: 5e8914a8ad user: jan.nijtmans tags: bug-5d70d14a09
11:28 • New ticket [5d70d14a09] tcltest: test result differs for different singleproc va... artifact: 3804b42113 user: anonymous

tcltest: test result differs for different singleproc values

Closed / Wont Fix5d70d14a092160d19d913d8fa2b36a01e1c3a9b4Created 2 years agoUpdated 195 days ago
Descriptionplain2025-01-11 11:28:45
I have a following test (sources encoded as utf-8)

--- all.tcl ---
package require tcltest
::tcltest::runAllTests
---------------

--- utf8.test ---
package require tcltest 2.5
::tcltest::test notascii {string corrupted when singleproc == 0} {
    string length "äöü"
} 3
-----------------

Test passes in singleproc mode:
> tclsh all.tcl -singleproc 1

Test fails for default run:
> tclsh all.tcl
Test files run in separate interpreters
Running tests that match:  *
Skipping test files that match:  l.*.test
Only running test files that match:  *.test
Tests began at Sat Jan 11 13:04:12 EET 2025
utf-8.test


==== notascii string corrupted when singleproc == 0 FAILED
==== Contents of test case:

    string length "äöü"

---- Result was:
6
---- Result should have been (exact matching):
3
==== notascii FAILED

Environment:

tcl_platform(byteOrder)     = littleEndian
tcl_platform(engine)        = Tcl
tcl_platform(machine)       = amd64
tcl_platform(os)            = Windows NT
tcl_platform(osVersion)     = 10.0
tcl_platform(pathSeparator) = ;
tcl_platform(platform)      = windows
tcl_platform(pointerSize)   = 8
tcl_platform(threaded)      = 1
tcl_platform(user)          = user
tcl_platform(wordSize)      = 4
tcl = 8.6.17
tcltest = 2.5.9

Problem:

tcltest's runAllTests sources test file as utf-8 for singleProc:
--- tcltest-2.5.9.tm ---
...
2926: uplevel 1 [list ::source -encoding utf-8 $file]
...
---

and runAllTests runs test file using system defaults otherwise
--- tcltest-2.5.9.tm ---
...
2950: set cmd [linsert $childargv 0 | $shell $file]
...
2953: set pipeFd [open $cmd "r"]
...
---
Referenced by1
  • 5e8914a8adPossible fix for [5d70d14a09]: tcltest: test result differs for different singleproc values. Edit: doesn't work check-in2025-01-11 21:57:35
jan.nijtmanswiki2025-01-11 23:03:46

Let me guess. What does "encoding system" give on your system? Does it look like?:

$ tclsh86
% encoding system
cp1252
If so, the answer with -singleproc is wrong, the default run is right. Since the source-file is considered cp1252, the length of the string is indeed 6.

What we can do is sourcing "all.tcl" in utf-8 regardless of the system-encoding. See [here]

jan.nijtmanswiki2025-01-11 23:52:28

Hm. that doesn't work .....

anonymousplain2025-01-12 07:19:54
Sorry, I didn't make it clear that the test file should be saved in utf-8 encoding.

C:\Temp>tclsh
% encoding system
cp1251

C:\Temp>file utf-8.test
utf-8.test: Tcl script, Unicode text, UTF-8 text, with CRLF line terminators

My system encoding is cyrillic cp1251 but the test with cyrillic chars also failed

--- utf-8.test ---
package require tcltest 2.5

::tcltest::test notascii_cyr {string corrupted when singleproc == 0} {
    string length "іїє"
} 3
------------------

==== notascii_cyr string corrupted when singleproc == 0 FAILED
==== Contents of test case:

    string length "їіє"

---- Result was:
6
---- Result should have been (exact matching):
3
==== notascii_cyr FAILED
anonymousplain2025-01-12 07:34:06
And yes, am using -encoding utf-8 for tclsh

But runAllTest (when singleproc==0) 'exec' secondary tclsh without '-encoding utf-8'.

> tclsh -encoding utf-8 all.tcl -singleproc 0
fails

> tclsh -encoding utf-8 utf-8.test
works
apnadkarniplain2026-05-22 09:45:34
Closing as won't fix. Issues does not exist in 9.0 and 8.6 is EOL.
Log in (anonymous is fine) to add a comment.