summaryrefslogtreecommitdiffstats
path: root/tests/main.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/main.test')
-rw-r--r--tests/main.test146
1 files changed, 79 insertions, 67 deletions
diff --git a/tests/main.test b/tests/main.test
index 4aadd79..324b594 100644
--- a/tests/main.test
+++ b/tests/main.test
@@ -1,8 +1,8 @@
# This file contains a collection of tests for generic/tclMain.c.
-if {"::tcltest" ni [namespace children]} {
- package require tcltest 2.5
- namespace import -force ::tcltest::*
+if {[catch {package require tcltest 2.0.2}]} {
+ puts stderr "Skipping tests in [info script]. tcltest 2.0.2 required."
+ return
}
namespace eval ::tcl::test::main {
@@ -11,10 +11,12 @@ namespace eval ::tcl::test::main {
# Is [exec] defined?
testConstraint exec [llength [info commands exec]]
- # Is the tcl::test package loaded?
- testConstraint tcl::test [expr {
- [llength [package provide tcl::test]]
- && [package vsatisfies [package provide tcl::test] 8.5-]}]
+ # Is the Tcltest package loaded?
+ # - that is, the special C-coded testing commands in tclTest.c
+ # - tests use testing commands introduced in Tcltest 8.4
+ testConstraint Tcltest [expr {
+ [llength [package provide Tcltest]]
+ && [package vsatisfies [package provide Tcltest] 8.4]}]
# Procedure to simulate interactive typing of commands, line by line
proc type {chan script} {
@@ -64,60 +66,68 @@ namespace eval ::tcl::test::main {
} -result [list [interpreter] -script 0]\n
test Tcl_Main-1.3 {
+ Tcl_Main: encoding of arguments: done by system encoding
+ Note the shortcoming explained in Tcl Feature Request 491789
} -constraints {
stdio
} -setup {
makeFile {puts [list $argv0 $argv $tcl_interactive]} script
- catch {set f [open "|[list [interpreter] script À]" r]}
+ catch {set f [open "|[list [interpreter] script \u00c0]" r]}
} -body {
read $f
} -cleanup {
close $f
removeFile script
} -result [list script [list [encoding convertfrom [encoding system] \
- [encoding convertto [encoding system] À]]] 0]\n
+ [encoding convertto [encoding system] \u00c0]]] 0]\n
test Tcl_Main-1.4 {
+ Tcl_Main: encoding of arguments: done by system encoding
+ Note the shortcoming explained in Tcl Feature Request 491789
} -constraints {
- stdio
+ stdio tempNotWin
} -setup {
makeFile {puts [list $argv0 $argv $tcl_interactive]} script
- catch {set f [open "|[list [interpreter] script €]" r]}
+ catch {set f [open "|[list [interpreter] script \u20ac]" r]}
} -body {
read $f
} -cleanup {
close $f
removeFile script
} -result [list script [list [encoding convertfrom [encoding system] \
- [encoding convertto [encoding system] €]]] 0]\n
+ [encoding convertto [encoding system] \u20ac]]] 0]\n
test Tcl_Main-1.5 {
+ Tcl_Main: encoding of script name: system encoding loss
+ Note the shortcoming explained in Tcl Feature Request 491789
} -constraints {
stdio
} -setup {
- makeFile {puts [list $argv0 $argv $tcl_interactive]} À
- catch {set f [open "|[list [interpreter] À]" r]}
+ makeFile {puts [list $argv0 $argv $tcl_interactive]} \u00c0
+ catch {set f [open "|[list [interpreter] \u00c0]" r]}
} -body {
read $f
} -cleanup {
close $f
- removeFile À
+ removeFile \u00c0
} -result [list [list [encoding convertfrom [encoding system] \
- [encoding convertto [encoding system] À]]] {} 0]\n
+ [encoding convertto [encoding system] \u00c0]]] {} 0]\n
test Tcl_Main-1.6 {
+ Tcl_Main: encoding of script name: system encoding loss
+ Note the shortcoming explained in Tcl Feature Request 491789
} -constraints {
- stdio
+ stdio tempNotWin
} -setup {
- makeFile {puts [list $argv0 $argv $tcl_interactive]} €
- catch {set f [open "|[list [interpreter] €]" r]}
+ makeFile {puts [list $argv0 $argv $tcl_interactive]} \u20ac
+ catch {set f [open "|[list [interpreter] \u20ac]" r]}
} -body {
read $f
} -cleanup {
close $f
- removeFile €
+ removeFile \u20ac
} -result [list [list [encoding convertfrom [encoding system] \
- [encoding convertto [encoding system] €]]] {} 0]\n
+ [encoding convertto [encoding system] \u20ac]]] {} 0]\n
test Tcl_Main-1.7 {
Tcl_Main: startup script - -encoding option
@@ -129,8 +139,8 @@ namespace eval ::tcl::test::main {
set f [open $script w]
chan configure $f -encoding utf-8
puts $f {puts [list $argv0 $argv $tcl_interactive]}
- puts -nonewline $f {puts [string equal € }
- puts $f "€]"
+ puts -nonewline $f {puts [string equal \u20ac }
+ puts $f "\u20ac]"
close $f
catch {set f [open "|[list [interpreter] -encoding utf-8 script]" r]}
} -body {
@@ -151,9 +161,9 @@ namespace eval ::tcl::test::main {
chan configure $f -encoding utf-8
puts $f {puts [list $argv0 $argv $tcl_interactive]}
puts -nonewline $f {puts [string equal \u20ac }
- puts $f "€]"
+ puts $f "\u20ac]"
close $f
- catch {set f [open "|[list [interpreter] -encoding iso8859-1 script]" r]}
+ catch {set f [open "|[list [interpreter] -encoding ascii script]" r]}
} -body {
read $f
} -cleanup {
@@ -172,7 +182,7 @@ namespace eval ::tcl::test::main {
chan configure $f -encoding utf-8
puts $f {puts [list $argv0 $argv $tcl_interactive]}
puts -nonewline $f {puts [string equal \u20ac }
- puts $f "€]"
+ puts $f "\u20ac]"
close $f
catch {set f [open "|[list [interpreter] -enc utf-8 script]" r+]}
} -body {
@@ -190,7 +200,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-2.1 {
Tcl_Main: appInitProc returns error
} -constraints {
- exec tcl::test
+ exec Tcltest
} -setup {
makeFile {puts "In script"} script
} -body {
@@ -206,7 +216,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-2.2 {
Tcl_Main: appInitProc returns error
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {puts "In script"} -appinitprocerror >& result
set f [open result]
@@ -219,7 +229,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-2.3 {
Tcl_Main: appInitProc deletes interp
} -constraints {
- exec tcl::test
+ exec Tcltest
} -setup {
makeFile {puts "In script"} script
} -body {
@@ -235,7 +245,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-2.4 {
Tcl_Main: appInitProc deletes interp
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {puts "In script"} \
-appinitprocdeleteinterp >& result
@@ -249,7 +259,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-2.5 {
Tcl_Main: appInitProc closes stderr
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {puts "In script"} \
-appinitprocclosestderr >& result
@@ -334,7 +344,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-3.5 {
Tcl_Main: startup script sets main loop
} -constraints {
- exec tcl::test
+ exec Tcltest
} -setup {
makeFile {
rename exit _exit
@@ -362,7 +372,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-3.6 {
Tcl_Main: startup script sets main loop and closes stdin
} -constraints {
- exec tcl::test
+ exec Tcltest
} -setup {
makeFile {
close stdin
@@ -391,7 +401,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-3.7 {
Tcl_Main: startup script deletes interp
} -constraints {
- exec tcl::test
+ exec Tcltest
} -setup {
makeFile {
rename exit _exit
@@ -415,7 +425,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-3.8 {
Tcl_Main: startup script deletes interp and sets mainloop
} -constraints {
- exec tcl::test
+ exec Tcltest
} -setup {
makeFile {
testsetmainloop
@@ -459,7 +469,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-4.1 {
Tcl_Main: rcFile evaluation deletes interp
} -constraints {
- exec tcl::test
+ exec Tcltest
} -setup {
set rc [makeFile {testinterpdelete {}} rc]
} -body {
@@ -476,7 +486,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-4.2 {
Tcl_Main: rcFile evaluation closes stdin
} -constraints {
- exec tcl::test
+ exec Tcltest
} -setup {
set rc [makeFile {close stdin} rc]
} -body {
@@ -493,7 +503,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-4.3 {
Tcl_Main: rcFile evaluation closes stdin and sets main loop
} -constraints {
- exec tcl::test
+ exec Tcltest
} -setup {
set rc [makeFile {
close stdin
@@ -521,7 +531,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-4.4 {
Tcl_Main: rcFile evaluation sets main loop
} -constraints {
- exec tcl::test
+ exec Tcltest
} -setup {
set rc [makeFile {
testsetmainloop
@@ -548,7 +558,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-4.5 {
Tcl_Main: Bug 1481986
} -constraints {
- exec tcl::test
+ exec Tcltest
} -setup {
set rc [makeFile {
testsetmainloop
@@ -606,12 +616,12 @@ namespace eval ::tcl::test::main {
catch {set f [open "|[list [interpreter]]" w+]}
catch {chan configure $f -blocking 0}
} -body {
- type $f "chan configure stdin -eofchar \"\\x1A {}\"
- if 1 \{\n\x1A"
+ type $f "chan configure stdin -eofchar \\032
+ if 1 \{\n\032"
variable wait
chan event $f readable \
[list set [namespace which -variable wait] "child exit"]
- set id [after 5000 [list set [namespace which -variable wait] timeout]]
+ set id [after 2000 [list set [namespace which -variable wait] timeout]]
vwait [namespace which -variable wait]
after cancel $id
set wait
@@ -634,7 +644,7 @@ namespace eval ::tcl::test::main {
variable wait
chan event $f readable \
[list set [namespace which -variable wait] "child exit"]
- set id [after 5000 [list set [namespace which -variable wait] timeout]]
+ set id [after 2000 [list set [namespace which -variable wait] timeout]]
vwait [namespace which -variable wait]
after cancel $id
set wait
@@ -696,7 +706,7 @@ namespace eval ::tcl::test::main {
Tcl_Main: interactive mode: close stdin
-> main loop & [exit] & exit handlers
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {
rename exit _exit
@@ -717,10 +727,10 @@ namespace eval ::tcl::test::main {
} -result "Exit MainLoop\nIn exit\neven 0\n"
test Tcl_Main-5.9 {
- Tcl_Main: interactive mode: delete interp
+ Tcl_Main: interactive mode: delete interp
-> main loop & exit handlers, but no [exit]
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {
rename exit _exit
@@ -743,7 +753,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-5.10 {
Tcl_Main: exit main loop in mid-interactive command
} -constraints {
- exec tcl::test
+ exec Tcltest
} -setup {
catch {set f [open "|[list [interpreter]]" w+]}
catch {chan configure $f -blocking 0}
@@ -764,7 +774,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-5.11 {
Tcl_Main: EOF in interactive main loop
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {
rename exit _exit
@@ -786,7 +796,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-5.12 {
Tcl_Main: close stdin in interactive main loop
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {
rename exit _exit
@@ -839,7 +849,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-6.2 {
Tcl_Main: prompt deletes interp
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {
set tcl_prompt1 {testinterpdelete {}}
@@ -891,7 +901,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-6.5 {
Tcl_Main: interactive entry to main loop
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {
set tcl_interactive 1
@@ -941,7 +951,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-7.1 {
Tcl_Main: [exit] defined as no-op -> still have exithandlers
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {
proc exit args {}
@@ -957,7 +967,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-7.2 {
Tcl_Main: [exit] defined as no-op -> still have exithandlers
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {
proc exit args {}
@@ -977,7 +987,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-8.1 {
StdinProc: handles non-blocking stdin
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {
testsetmainloop
@@ -994,7 +1004,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-8.2 {
StdinProc: handles stdin EOF
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {
testsetmainloop
@@ -1016,7 +1026,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-8.3 {
StdinProc: handles interactive stdin EOF
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {
testsetmainloop
@@ -1037,7 +1047,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-8.4 {
StdinProc: handles stdin close
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {
testsetmainloop
@@ -1060,7 +1070,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-8.5 {
StdinProc: handles interactive stdin close
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {
testsetmainloop
@@ -1084,7 +1094,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-8.6 {
StdinProc: handles event loop re-entry
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {
testsetmainloop
@@ -1103,7 +1113,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-8.7 {
StdinProc: handling of errors
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {
testsetmainloop
@@ -1120,7 +1130,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-8.8 {
StdinProc: handling of errors, closed stderr
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {
testsetmainloop
@@ -1138,7 +1148,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-8.9 {
StdinProc: interactive output
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {
testsetmainloop
@@ -1154,7 +1164,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-8.10 {
StdinProc: interactive output, closed stdout
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {
testsetmainloop
@@ -1172,7 +1182,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-8.11 {
StdinProc: prompt deletes interp
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {
testsetmainloop
@@ -1188,7 +1198,7 @@ namespace eval ::tcl::test::main {
test Tcl_Main-8.12 {
StdinProc: prompt closes stdin
} -constraints {
- exec tcl::test
+ exec Tcltest
} -body {
exec [interpreter] << {
testsetmainloop
@@ -1207,7 +1217,9 @@ namespace eval ::tcl::test::main {
test Tcl_Main-8.13 {
Bug 1775878
} -constraints {
- exec tcl::test
+ exec Tcltest
+ } -setup {
+ catch {set f [open "|[list [interpreter]]" w+]}
} -body {
exec [interpreter] << "testsetmainloop\nputs \\\npwd\ntestexitmainloop" >& result
set f [open result]