diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-09-16 18:45:38 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-09-16 18:45:38 (GMT) |
commit | 21ad94030ac5757eefe70e335cf8dc57e7b06338 (patch) | |
tree | 42ed4343209e8ad6a84af3f060a4c159f65429c6 | |
parent | 7d5b0dc33c13fa1026a537ab90b201ed1ce43666 (diff) | |
parent | e10b32c27a1f48c45ea90e6af530c75fa3fff7a2 (diff) | |
download | tcl-21ad94030ac5757eefe70e335cf8dc57e7b06338.zip tcl-21ad94030ac5757eefe70e335cf8dc57e7b06338.tar.gz tcl-21ad94030ac5757eefe70e335cf8dc57e7b06338.tar.bz2 |
Add 32-bit Windows builds, both with MSVC and GCC, to Travis.
Backport various test-suite changes fro 8.6 to 8.5, mainly "knownBug" markers and comments
-rw-r--r-- | .travis.yml | 81 | ||||
-rw-r--r-- | tests/compile.test | 161 | ||||
-rw-r--r-- | tests/exec.test | 245 | ||||
-rw-r--r-- | tests/execute.test | 36 | ||||
-rw-r--r-- | tests/fCmd.test | 2 | ||||
-rw-r--r-- | tests/registry.test | 2 |
6 files changed, 295 insertions, 232 deletions
diff --git a/.travis.yml b/.travis.yml index 2a04faf..29b9e7f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,18 +15,15 @@ matrix: dist: xenial compiler: gcc env: - - CFGOPT=--disable-shared + - CFGOPT="--disable-shared" - BUILD_DIR=unix -# Debug build. Running test-cases disabled, because it is currently failing. - - name: "Linux/GCC/Debug/no test" + - name: "Linux/GCC/Debug" os: linux dist: xenial compiler: gcc env: - BUILD_DIR=unix - - CFGOPT=--enable-symbols=all - script: - - make all tcltest + - CFGOPT="--enable-symbols" # Older versions of GCC... - name: "Linux/GCC 7/Shared" os: linux @@ -88,24 +85,22 @@ matrix: dist: xenial compiler: clang env: - - CFGOPT=--disable-shared + - CFGOPT="--disable-shared" - BUILD_DIR=unix -# Debug build. Running test-cases disabled, because it is currently failing. - - name: "Linux/Clang/Debug/no test" + - name: "Linux/Clang/Debug" os: linux dist: xenial compiler: clang env: - BUILD_DIR=unix - - CFGOPT=--enable-symbols=all - script: - - make all tcltest + - CFGOPT="--enable-symbols" # Testing on Mac, various styles - name: "macOS/Xcode 11/Shared/Unix-like" os: osx osx_image: xcode11 env: - BUILD_DIR=unix + - CFGOPT="--enable-threads" - name: "macOS/Xcode 11/Shared" os: osx osx_image: xcode11 @@ -118,7 +113,7 @@ matrix: - make test styles=develop - name: "macOS/Xcode 10/Shared" os: osx - osx_image: xcode10.2 + osx_image: xcode10.3 env: - BUILD_DIR=macosx install: [] @@ -246,6 +241,34 @@ matrix: script: - cmd.exe /C 'vcvarsall.bat x64 && nmake OPTS=symbols,msvcrt,threads -f makefile.vc all tcltest' - cmd.exe /C 'vcvarsall.bat x64 && nmake OPTS=symbols,msvcrt,threads -f makefile.vc test' +# Test on Windows with MSVC native (32-bit) + - name: "Windows/MSVC-x86/Shared" + os: windows + compiler: cl + env: *vcenv + before_install: *vcpreinst + install: [] + script: + - cmd.exe /C 'vcvarsall.bat x86 && nmake OPTS=threads -f makefile.vc all tcltest' + - cmd.exe /C 'vcvarsall.bat x86 && nmake OPTS=threads -f makefile.vc test' + - name: "Windows/MSVC-x86/Static" + os: windows + compiler: cl + env: *vcenv + before_install: *vcpreinst + install: [] + script: + - cmd.exe /C 'vcvarsall.bat x86 && nmake OPTS=static,msvcrt,threads -f makefile.vc all tcltest' + - cmd.exe /C 'vcvarsall.bat x86 && nmake OPTS=static,msvcrt,threads -f makefile.vc test' + - name: "Windows/MSVC-x86/Debug" + os: windows + compiler: cl + env: *vcenv + before_install: *vcpreinst + install: [] + script: + - cmd.exe /C 'vcvarsall.bat x86 && nmake OPTS=symbols,msvcrt,threads -f makefile.vc all tcltest' + - cmd.exe /C 'vcvarsall.bat x86 && nmake OPTS=symbols,msvcrt,threads -f makefile.vc test' # Test on Windows with GCC native - name: "Windows/GCC/Shared" os: windows @@ -253,7 +276,7 @@ matrix: env: - BUILD_DIR=win - CFGOPT="--enable-64bit --enable-threads" - before_install: + before_install: &makepreinst - choco install make - cd ${BUILD_DIR} - name: "Windows/GCC/Static" @@ -262,18 +285,36 @@ matrix: env: - BUILD_DIR=win - CFGOPT="--enable-64bit --enable-threads --disable-shared" - before_install: - - choco install make - - cd ${BUILD_DIR} + before_install: *makepreinst - name: "Windows/GCC/Debug" os: windows compiler: gcc env: - BUILD_DIR=win - CFGOPT="--enable-64bit --enable-threads --enable-symbols" - before_install: - - choco install make - - cd ${BUILD_DIR} + before_install: *makepreinst +# Test on Windows with GCC native (32-bit) + - name: "Windows/GCC-x86/Shared" + os: windows + compiler: gcc + env: + - BUILD_DIR=win + - CFGOPT="--enable-threads" + before_install: *makepreinst + - name: "Windows/GCC-x86/Static" + os: windows + compiler: gcc + env: + - BUILD_DIR=win + - CFGOPT="--enable-threads --disable-shared" + before_install: *makepreinst + - name: "Windows/GCC-x86/Debug" + os: windows + compiler: gcc + env: + - BUILD_DIR=win + - CFGOPT="--enable-threads --enable-symbols" + before_install: *makepreinst before_install: - cd ${BUILD_DIR} install: diff --git a/tests/compile.test b/tests/compile.test index f027197..11d42dd 100644 --- a/tests/compile.test +++ b/tests/compile.test @@ -1,15 +1,15 @@ -# This file contains tests for the files tclCompile.c, tclCompCmds.c -# and tclLiteral.c +# This file contains tests for the files tclCompile.c, tclCompCmds.c and +# tclLiteral.c # -# This file contains a collection of tests for one or more of the Tcl -# built-in commands. Sourcing this file into Tcl runs the tests and -# generates output for errors. No output means no errors were found. +# This file contains a collection of tests for one or more of the Tcl built-in +# commands. Sourcing this file into Tcl runs the tests and generates output +# for errors. No output means no errors were found. # # Copyright (c) 1997 by Sun Microsystems, Inc. # Copyright (c) 1998-1999 by Scriptics Corporation. # -# See the file "license.terms" for information on usage and redistribution -# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# See the file "license.terms" for information on usage and redistribution of +# this file, and for a DISCLAIMER OF ALL WARRANTIES. package require tcltest 2 namespace import -force ::tcltest::* @@ -26,10 +26,11 @@ catch {namespace delete test_ns_compile} catch {unset x} catch {unset y} catch {unset a} - -test compile-1.1 {TclCompileString: look up cmds in proc ns, not current ns} { + +test compile-1.1 {TclCompileString: look up cmds in proc ns, not current ns} -setup { catch {namespace delete test_ns_compile} catch {unset x} +} -body { set x 123 namespace eval test_ns_compile { proc set {args} { @@ -41,29 +42,33 @@ test compile-1.1 {TclCompileString: look up cmds in proc ns, not current ns} { } } list [test_ns_compile::p] [set x] -} {{123 test_ns_compile::set} {123 test_ns_compile::set}} +} -result {{123 test_ns_compile::set} {123 test_ns_compile::set}} test compile-1.2 {TclCompileString, error result is reset if TclGetLong determines word isn't an integer} { proc p {x} {info commands 3m} list [catch {p} msg] $msg } {1 {wrong # args: should be "p x"}} -test compile-2.1 {TclCompileDollarVar: global scalar name with ::s} { + +test compile-2.1 {TclCompileDollarVar: global scalar name with ::s} -setup { catch {unset x} +} -body { set x 123 list $::x [expr {[lsearch -exact [info globals] x] != 0}] -} {123 1} -test compile-2.2 {TclCompileDollarVar: global scalar name with ::s} { +} -result {123 1} +test compile-2.2 {TclCompileDollarVar: global scalar name with ::s} -setup { catch {unset y} +} -body { proc p {} { set ::y 789 return $::y } list [p] $::y [expr {[lsearch -exact [info globals] y] != 0}] -} {789 789 1} -test compile-2.3 {TclCompileDollarVar: global array name with ::s} { +} -result {789 789 1} +test compile-2.3 {TclCompileDollarVar: global array name with ::s} -setup { catch {unset a} +} -body { set ::a(1) 2 list $::a(1) [set ::a($::a(1)) 3] $::a(2) [expr {[lsearch -exact [info globals] a] != 0}] -} {2 3 3 1} +} -result {2 3 3 1} test compile-2.4 {TclCompileDollarVar: global scalar name with ::s} { catch {unset a} proc p {} { @@ -82,15 +87,16 @@ test compile-2.5 {TclCompileDollarVar: global array, called as ${arrName(0)}} { list [p] $::a(1) [expr {[lsearch -exact [info globals] a] != 0}] } {111 1 1} -test compile-3.1 {TclCompileCatchCmd: only catch cmds with scalar vars are compiled inline} { +test compile-3.1 {TclCompileCatchCmd: only catch cmds with scalar vars are compiled inline} -setup { catch {unset a} +} -body { set a(1) xyzzyx proc p {} { global a catch {set x 123} a(1) } list [p] $a(1) -} {0 123} +} -result {0 123} test compile-3.2 {TclCompileCatchCmd: non-local variables} { set ::foo 1 proc catch-test {} { @@ -111,7 +117,7 @@ test compile-3.4 {TclCompileCatchCmd: bcc'ed [return] is caught} { proc foo {} { set fail [catch { return 1 - }] ; # {} + }] ; # {} return 2 } foo @@ -121,8 +127,8 @@ test compile-3.5 {TclCompileCatchCmd: recover from error, [Bug 705406]} { catch { if {[a]} { if b {} - } - } + } + } } list [catch foo msg] $msg } {0 1} @@ -185,9 +191,10 @@ test compile-5.2 {TclCompileForeachCmd: non-local variables} { set ::foo } 3 -test compile-6.1 {TclCompileSetCmd: global scalar names with ::s} { +test compile-6.1 {TclCompileSetCmd: global scalar names with ::s} -setup { catch {unset x} catch {unset y} +} -body { set x 123 proc p {} { set ::y 789 @@ -195,19 +202,21 @@ test compile-6.1 {TclCompileSetCmd: global scalar names with ::s} { } list $::x [expr {[lsearch -exact [info globals] x] != 0}] \ [p] $::y [expr {[lsearch -exact [info globals] y] != 0}] -} {123 1 789 789 1} -test compile-6.2 {TclCompileSetCmd: global array names with ::s} { +} -result {123 1 789 789 1} +test compile-6.2 {TclCompileSetCmd: global array names with ::s} -setup { catch {unset a} +} -body { set ::a(1) 2 proc p {} { set ::a(1) 1 return $::a($::a(1)) } list $::a(1) [p] [set ::a($::a(1)) 3] $::a(1) [expr {[lsearch -exact [info globals] a] != 0}] -} {2 1 3 3 1} -test compile-6.3 {TclCompileSetCmd: namespace var names with ::s} { +} -result {2 1 3 3 1} +test compile-6.3 {TclCompileSetCmd: namespace var names with ::s} -setup { catch {namespace delete test_ns_compile} catch {unset x} +} -body { namespace eval test_ns_compile { variable v hello variable arr @@ -215,7 +224,7 @@ test compile-6.3 {TclCompileSetCmd: namespace var names with ::s} { set ::test_ns_compile::arr(1) 123 } list $::x $::test_ns_compile::arr(1) -} {hello 123} +} -result {hello 123} test compile-7.1 {TclCompileWhileCmd: command substituted test expression} { set i 0 @@ -298,11 +307,11 @@ test compile-11.9 {Tcl_Append*: ensure Tcl_ResetResult is used properly} { list [catch {p} msg] $msg } {1 {unmatched open brace in list}} -# +# # Special section for tests of tclLiteral.c # The following tests check for incorrect memory handling in -# TclReleaseLiteral. They are only effective when tcl is compiled -# with TCL_MEM_DEBUG +# TclReleaseLiteral. They are only effective when tcl is compiled with +# TCL_MEM_DEBUG # # Special test for leak on interp delete [Bug 467523]. test compile-12.1 {testing literal leak on interp delete} -setup { @@ -313,10 +322,10 @@ test compile-12.1 {testing literal leak on interp delete} -setup { } -constraints memory -body { set end [getbytes] for {set i 0} {$i < 5} {incr i} { - interp create foo - foo eval { + interp create foo + foo eval { namespace eval bar {} - } + } interp delete foo set tmp $end set end [getbytes] @@ -326,9 +335,9 @@ test compile-12.1 {testing literal leak on interp delete} -setup { rename getbytes {} unset -nocomplain end i tmp leakedBytes } -result 0 -# Special test for a memory error in a preliminary fix of [Bug 467523]. -# It requires executing a helpfile. Presumably the child process is -# used because when this test fails, it crashes. +# Special test for a memory error in a preliminary fix of [Bug 467523]. It +# requires executing a helpfile. Presumably the child process is used because +# when this test fails, it crashes. test compile-12.2 {testing error on literal deletion} -constraints {memory exec} -body { set sourceFile [makeFile { for {set i 0} {$i < 5} {incr i} { @@ -337,7 +346,7 @@ test compile-12.2 {testing error on literal deletion} -constraints {memory exec} } puts 0 } source.file] - exec [interpreter] $sourceFile + exec [interpreter] $sourceFile } -cleanup { catch {removeFile $sourceFile} } -result 0 @@ -353,29 +362,28 @@ test compile-12.3 {check for a buffer overrun} -body { test compile-12.4 {TclCleanupLiteralTable segfault} -body { # Tcl Bug 1001997 # Here, we're trying to test a case that causes a crash in - # TclCleanupLiteralTable. The conditions that we're trying to - # establish are: - # - TclCleanupLiteralTable is attempting to clean up a bytecode - # object in the literal table. - # - The bytecode object in question contains the only reference - # to another literal. + # TclCleanupLiteralTable. The conditions that we're trying to establish + # are: + # - TclCleanupLiteralTable is attempting to clean up a bytecode object in + # the literal table. + # - The bytecode object in question contains the only reference to another + # literal. # - The literal in question is in the same hash bucket as the bytecode # object, and immediately follows it in the chain. - # Since newly registered literals are added at the FRONT of the - # bucket chains, and since the bytecode object is registered before - # its literals, this is difficult to achieve. What we do is: - # (a) do a [namespace eval] of a string that's calculated to - # hash into the same bucket as a literal that it contains. - # In this case, the script and the variable 'bugbug' - # land in the same bucket. - # (b) do a [namespace eval] of a string that contains enough - # literals to force TclRegisterLiteral to rebuild the global - # literal table. The newly created hash buckets will contain - # the literals, IN REVERSE ORDER, thus putting the bytecode - # immediately ahead of 'bugbug' and 'bug4345bug'. The bytecode - # object will contain the only references to those two literals. - # (c) Delete the interpreter to invoke TclCleanupLiteralTable - # and tickle the bug. + # Since newly registered literals are added at the FRONT of the bucket + # chains, and since the bytecode object is registered before its literals, + # this is difficult to achieve. What we do is: + # (a) do a [namespace eval] of a string that's calculated to hash into + # the same bucket as a literal that it contains. In this case, the + # script and the variable 'bugbug' land in the same bucket. + # (b) do a [namespace eval] of a string that contains enough literals to + # force TclRegisterLiteral to rebuild the global literal table. The + # newly created hash buckets will contain the literals, IN REVERSE + # ORDER, thus putting the bytecode immediately ahead of 'bugbug' and + # 'bug4345bug'. The bytecode object will contain the only references + # to those two literals. + # (c) Delete the interpreter to invoke TclCleanupLiteralTable and tickle + # the bug. proc foo {} { set i [interp create] $i eval { @@ -409,9 +417,8 @@ test compile-12.4 {TclCleanupLiteralTable segfault} -body { rename foo {} } -result ok -# Special test for underestimating the maxStackSize required for a -# compiled command. A failure will cause a segfault in the child -# process. +# Special test for underestimating the maxStackSize required for a compiled +# command. A failure will cause a segfault in the child process. test compile-13.1 {testing underestimate of maxStackSize in list cmd} {exec} { set body {set x [list} for {set i 0} {$i < 3000} {incr i} { @@ -464,7 +471,7 @@ test compile-13.3 {TclCompileScript: testing check of max depth by nested script ti eval {set result {}} } -body { # Test different compilation variants (instructions evalStk, invokeStk, etc), - # with 500 nested scripts (bodies). It must generate "too many nested compilations" + # with 500 nested scripts (bodies). It must generate "too many nested compilations" # error for any variant we're testing here: ti eval {foreach cmd {eval "if 1" catch} { set c [gencode [expr {![info exists ::tcl_platform(debug)] ? 2000 : 1000}] $cmd] @@ -472,7 +479,7 @@ test compile-13.3 {TclCompileScript: testing check of max depth by nested script }} #puts $errors # all of nested calls exceed the limit, so must end with "too many nested compilations" - # (or evaluations, depending on compile method/instruction and "mixed" compile within + # (or evaluations, depending on compile method/instruction and "mixed" compile within # evaliation), so no one succeeds, the result must be empty: ti eval {set result} } -result {} @@ -493,7 +500,7 @@ test compile-14.1 {testing errors in element name; segfault?} {} { test compile-14.2 {testing element name "$"} -body { unset -nocomplain a set a() 1 - set a(1) 2 + set a(1) 2 set a($) 3 list [set a()] [set a(1)] [set a($)] [unset a() a(1); lindex [array names a] 0] } -cleanup {unset a} -result [list 1 2 3 {$}] @@ -603,17 +610,16 @@ test compile-16.17.$noComp {TclCompileScript: word expansion} $constraints { run {list {*}x y z} } {x y z} -# These tests note that expansion can in theory cause the number of -# arguments to a command to exceed INT_MAX, which is as big as objc -# is allowed to get. +# These tests note that expansion can in theory cause the number of arguments +# to a command to exceed INT_MAX, which is as big as objc is allowed to get. # -# In practice, it seems we will run out of memory before we confront -# this issue. Note that compiled operations run out of memory at -# smaller objc values than direct string evaluation. +# In practice, it seems we will run out of memory before we confront this +# issue. Note that compiled operations run out of memory at smaller objc +# values than direct string evaluation. # -# These tests are constrained as knownBug because they are likely -# to cause memory allocation panics somewhere, and we don't want -# panics in the test suite. +# These tests are constrained as knownBug because they are likely to cause +# memory allocation panics somewhere, and we don't want panics in the test +# suite. # test compile-16.18.$noComp {TclCompileScript: word expansion} -body { proc LongList {} {return [lrepeat [expr {1<<10}] x]} @@ -668,8 +674,8 @@ test compile-16.24.$noComp { } -returnCodes error -result {unmatched open brace in list} } ;# End of noComp loop -# These tests are messy because it wrecks the interpreter it runs in! -# They demonstrate issues arising from [FRQ 1101710] +# These tests are messy because it wrecks the interpreter it runs in! They +# demonstrate issues arising from [FRQ 1101710] test compile-17.1 {Command interpretation binding for compiled code} -constraints knownBug -setup { set i [interp create] } -body { @@ -707,3 +713,8 @@ catch {unset y} catch {unset a} ::tcltest::cleanupTests return + +# Local Variables: +# mode: tcl +# fill-column: 78 +# End: diff --git a/tests/exec.test b/tests/exec.test index 7bb8579..a180906 100644 --- a/tests/exec.test +++ b/tests/exec.test @@ -1,15 +1,15 @@ # Commands covered: exec # -# This file contains a collection of tests for one or more of the Tcl -# built-in commands. Sourcing this file into Tcl runs the tests and -# generates output for errors. No output means no errors were found. +# This file contains a collection of tests for one or more of the Tcl built-in +# commands. Sourcing this file into Tcl runs the tests and generates output +# for errors. No output means no errors were found. # # Copyright (c) 1991-1994 The Regents of the University of California. # Copyright (c) 1994-1997 Sun Microsystems, Inc. # Copyright (c) 1998-1999 by Scriptics Corporation. # -# See the file "license.terms" for information on usage and redistribution -# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# See the file "license.terms" for information on usage and redistribution of +# this file, and for a DISCLAIMER OF ALL WARRANTIES. package require tcltest 2 namespace import -force ::tcltest::* @@ -18,6 +18,8 @@ namespace import -force ::tcltest::* # Skip them if exec is not defined. testConstraint exec [llength [info commands exec]] unset -nocomplain path + +# Utilities that are like bourne shell stalwarts, but cross-platform. set path(echo) [makeFile { puts -nonewline [lindex $argv 0] foreach str [lrange $argv 1 end] { @@ -26,17 +28,16 @@ set path(echo) [makeFile { puts {} exit } echo] - set path(echo2) [makeFile { puts stdout [join $argv] puts stderr [lindex $argv 1] exit } echo2] - set path(cat) [makeFile { if {$argv == {}} { set argv - } + fconfigure stdout -translation binary foreach name $argv { if {$name == "-"} { set f stdin @@ -44,6 +45,7 @@ set path(cat) [makeFile { puts stderr $f continue } + fconfigure $f -translation binary while {[eof $f] == 0} { puts -nonewline [read $f] } @@ -53,7 +55,6 @@ set path(cat) [makeFile { } exit } cat] - set path(wc) [makeFile { set data [read stdin] set lines [regsub -all "\n" $data {} dummy] @@ -62,7 +63,6 @@ set path(wc) [makeFile { puts [format "%8.d%8.d%8.d" $lines $words $chars] exit } wc] - set path(sh) [makeFile { if {[lindex $argv 0] != "-c"} { error "sh: unexpected arguments $argv" @@ -71,7 +71,7 @@ set path(sh) [makeFile { lappend cmd ";" set newcmd {} - + foreach arg $cmd { if {$arg == ";"} { eval exec >@stdout 2>@stderr [list [info nameofexecutable]] $newcmd @@ -93,7 +93,7 @@ set path(sh2) [makeFile { lappend cmd ";" set newcmd {} - + foreach arg $cmd { if {$arg == ";"} { eval exec -ignorestderr >@stdout [list [info nameofexecutable]] $newcmd @@ -104,16 +104,22 @@ set path(sh2) [makeFile { } exit } sh2] - set path(sleep) [makeFile { after [expr $argv*1000] exit } sleep] - set path(exit) [makeFile { exit $argv } exit] +proc readfile filename { + set f [open $filename] + set d [read $f] + close $f + return [string trimright $d \n] +} + +# ---------------------------------------------------------------------- # Basic operations. test exec-1.1 {basic exec operation} {exec} { @@ -150,13 +156,24 @@ test exec-2.4 {redirecting input from immediate source} {exec stdio} { test exec-2.5 {redirecting input from immediate source} {exec} { exec [interpreter] $path(cat) "<<Joined to arrows" } {Joined to arrows} -test exec-2.6 {redirecting input from immediate source, with UTF} {exec} { - # If this fails, it may give back: - # "\uC3\uA9\uC3\uA0\uC3\uBC\uC3\uB1" - # If it does, this means that the UTF -> external conversion did not - # occur before writing out the temp file. - exec [interpreter] $path(cat) << "\uE9\uE0\uFC\uF1" -} "\uE9\uE0\uFC\uF1" +test exec-2.6 {redirecting input from immediate source, with UTF} -setup { + set sysenc [encoding system] + encoding system iso8859-1 + proc quotenonascii s { + regsub -all {\[|\\|\]} $s {\\&} s + regsub -all "\[\u007f-\uffff\]" $s \ + {[apply {c {format {\u%04x} [scan $c %c]}} &]} s + return [subst -novariables $s] + } +} -constraints {exec} -body { + # If this fails, it may give back: "\uC3\uA9\uC3\uA0\uC3\uBC\uC3\uB1" + # If it does, this means that the UTF -> external conversion did not occur + # before writing out the temp file. + quotenonascii [exec [interpreter] $path(cat) << "\uE9\uE0\uFC\uF1"] +} -cleanup { + encoding system $sysenc + rename quotenonascii {} +} -result {\u00e9\u00e0\u00fc\u00f1} # I/O redirection: output to file. @@ -205,37 +222,37 @@ test exec-3.7 {redirecting output to file} {exec} { file delete $path(gorp.file) test exec-4.1 {redirecting output and stderr to file} {exec} { - exec [interpreter] "$path(echo)" "test output" >& $path(gorp.file) - exec [interpreter] "$path(cat)" "$path(gorp.file)" + exec [interpreter] $path(echo) "test output" >& $path(gorp.file) + exec [interpreter] $path(cat) $path(gorp.file) } "test output" test exec-4.2 {redirecting output and stderr to file} {exec} { - list [exec [interpreter] "$path(sh)" -c "\"$path(echo)\" foo bar 1>&2" >&$path(gorp.file)] \ - [exec [interpreter] "$path(cat)" "$path(gorp.file)"] + list [exec [interpreter] $path(sh) -c "\"$path(echo)\" foo bar 1>&2" >&$path(gorp.file)] \ + [exec [interpreter] $path(cat) $path(gorp.file)] } {{} {foo bar}} test exec-4.3 {redirecting output and stderr to file} {exec} { exec [interpreter] $path(echo) "first line" > $path(gorp.file) - list [exec [interpreter] "$path(sh)" -c "\"$path(echo)\" foo bar 1>&2" >>&$path(gorp.file)] \ - [exec [interpreter] "$path(cat)" "$path(gorp.file)"] + list [exec [interpreter] $path(sh) -c "\"$path(echo)\" foo bar 1>&2" >>&$path(gorp.file)] \ + [exec [interpreter] $path(cat) $path(gorp.file)] } "{} {first line\nfoo bar}" test exec-4.4 {redirecting output and stderr to file} {exec} { - set f [open "$path(gorp.file)" w] + set f [open $path(gorp.file) w] puts $f "Line 1" flush $f - exec [interpreter] "$path(echo)" "More text" >&@ $f - exec [interpreter] "$path(echo)" >&@$f "Even more" + exec [interpreter] $path(echo) "More text" >&@ $f + exec [interpreter] $path(echo) >&@$f "Even more" puts $f "Line 3" close $f - exec [interpreter] "$path(cat)" "$path(gorp.file)" + exec [interpreter] $path(cat) $path(gorp.file) } "Line 1\nMore text\nEven more\nLine 3" test exec-4.5 {redirecting output and stderr to file} {exec} { - set f [open "$path(gorp.file)" w] + set f [open $path(gorp.file) w] puts $f "Line 1" flush $f - exec >&@ $f [interpreter] "$path(sh)" -c "\"$path(echo)\" foo bar 1>&2" - exec >&@$f [interpreter] "$path(sh)" -c "\"$path(echo)\" xyzzy 1>&2" + exec >&@ $f [interpreter] $path(sh) -c "\"$path(echo)\" foo bar 1>&2" + exec >&@$f [interpreter] $path(sh) -c "\"$path(echo)\" xyzzy 1>&2" puts $f "Line 3" close $f - exec [interpreter] "$path(cat)" "$path(gorp.file)" + exec [interpreter] $path(cat) $path(gorp.file) } "Line 1\nfoo bar\nxyzzy\nLine 3" # I/O redirection: input from file. @@ -258,30 +275,30 @@ test exec-5.4 {redirecting input from file} {exec stdio} { test exec-5.5 {redirecting input from file} {exec} { exec [interpreter] $path(cat) <$path(gorp.file) } {Just a few thoughts} -test exec-5.6 {redirecting input from file} {exec} { +test exec-5.6 {redirecting input from file} -constraints {exec} -body { set f [open $path(gorp.file) r] - set result [exec [interpreter] $path(cat) <@ $f] + exec [interpreter] $path(cat) <@ $f +} -cleanup { close $f - set result -} {Just a few thoughts} -test exec-5.7 {redirecting input from file} {exec} { +} -result {Just a few thoughts} +test exec-5.7 {redirecting input from file} -constraints {exec} -body { set f [open $path(gorp.file) r] - set result [exec <@$f [interpreter] $path(cat)] + exec <@$f [interpreter] $path(cat) +} -cleanup { close $f - set result -} {Just a few thoughts} +} -result {Just a few thoughts} # I/O redirection: standard error through a pipeline. test exec-6.1 {redirecting stderr through a pipeline} {exec stdio} { - exec [interpreter] "$path(sh)" -c "\"$path(echo)\" foo bar" |& [interpreter] "$path(cat)" + exec [interpreter] $path(sh) -c "\"$path(echo)\" foo bar" |& [interpreter] $path(cat) } "foo bar" test exec-6.2 {redirecting stderr through a pipeline} {exec stdio} { - exec [interpreter] "$path(sh)" -c "\"$path(echo)\" foo bar 1>&2" |& [interpreter] "$path(cat)" + exec [interpreter] $path(sh) -c "\"$path(echo)\" foo bar 1>&2" |& [interpreter] $path(cat) } "foo bar" test exec-6.3 {redirecting stderr through a pipeline} {exec stdio} { - exec [interpreter] "$path(sh)" -c "\"$path(echo)\" foo bar 1>&2" \ - |& [interpreter] "$path(sh)" -c "\"$path(echo)\" second msg 1>&2 ; \"$path(cat)\"" |& [interpreter] "$path(cat)" + exec [interpreter] $path(sh) -c "\"$path(echo)\" foo bar 1>&2" \ + |& [interpreter] $path(sh) -c "\"$path(echo)\" second msg 1>&2 ; \"$path(cat)\"" |& [interpreter] $path(cat) } "second msg\nfoo bar" # I/O redirection: combinations. @@ -297,7 +314,6 @@ test exec-7.2 {multiple I/O redirections} {exec} { } {command input} # Long input to command and output from command. - set a "0123456789 xxxxxxxxx abcdefghi ABCDEFGHIJK\n" set a [concat $a $a $a $a] set a [concat $a $a $a $a] @@ -306,9 +322,7 @@ set a [concat $a $a $a $a] test exec-8.1 {long input and output} {exec} { exec [interpreter] $path(cat) << $a } $a - # More than 20 arguments to exec. - test exec-8.2 {long input and output} {exec} { exec [interpreter] $path(echo) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 } {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23} @@ -322,40 +336,40 @@ test exec-9.1 {commands returning errors} {exec} { test exec-9.2 {commands returning errors} {exec} { string tolower [list [catch {exec [interpreter] echo foo | foo123} msg] $msg $errorCode] } {1 {couldn't execute "foo123": no such file or directory} {posix enoent {no such file or directory}}} -test exec-9.3 {commands returning errors} {exec stdio} { - list [catch {exec [interpreter] $path(sleep) 1 | [interpreter] $path(exit) 43 | [interpreter] $path(sleep) 1} msg] $msg -} {1 {child process exited abnormally}} -test exec-9.4 {commands returning errors} {exec stdio} { - list [catch {exec [interpreter] $path(exit) 43 | [interpreter] $path(echo) "foo bar"} msg] $msg -} {1 {foo bar -child process exited abnormally}} -test exec-9.5 {commands returning errors} {exec stdio} { - list [catch {exec gorp456 | [interpreter] echo a b c} msg] [string tolower $msg] -} {1 {couldn't execute "gorp456": no such file or directory}} -test exec-9.6 {commands returning errors} {exec} { - list [catch {exec [interpreter] "$path(sh)" -c "\"$path(echo)\" error msg 1>&2"} msg] $msg -} {1 {error msg}} -test exec-9.7 {commands returning errors} {exec stdio} { - list [catch {exec [interpreter] "$path(sh)" -c "\"$path(echo)\" error msg 1>&2 ; \"$path(sleep)\" 1" \ - | [interpreter] "$path(sh)" -c "\"$path(echo)\" error msg 1>&2 ; \"$path(sleep)\" 1"} msg] $msg -} {1 {error msg -error msg}} - +test exec-9.3 {commands returning errors} -constraints {exec stdio} -body { + exec [interpreter] $path(sleep) 1 | [interpreter] $path(exit) 43 | [interpreter] $path(sleep) 1 +} -returnCodes error -result {child process exited abnormally} +test exec-9.4 {commands returning errors} -constraints {exec stdio} -body { + exec [interpreter] $path(exit) 43 | [interpreter] $path(echo) "foo bar" +} -returnCodes error -result {foo bar +child process exited abnormally} +test exec-9.5 {commands returning errors} -constraints {exec stdio} -body { + exec gorp456 | [interpreter] echo a b c +} -returnCodes error -result {couldn't execute "gorp456": no such file or directory} +test exec-9.6 {commands returning errors} -constraints {exec} -body { + exec [interpreter] $path(sh) -c "\"$path(echo)\" error msg 1>&2" +} -returnCodes error -result {error msg} +test exec-9.7 {commands returning errors} -constraints {exec stdio nonPortable} -body { + # This test can fail easily on multiprocessor machines + exec [interpreter] $path(sh) -c "\"$path(echo)\" error msg 1>&2 ; \"$path(sleep)\" 1" \ + | [interpreter] $path(sh) -c "\"$path(echo)\" error msg 1>&2 ; \"$path(sleep)\" 1" +} -returnCodes error -result {error msg +error msg} set path(err) [makeFile {} err] - -test exec-9.8 {commands returning errors} {exec} { +test exec-9.8 {commands returning errors} -constraints {exec} -setup { set f [open $path(err) w] puts $f { puts stdout out puts stderr err } close $f - list [catch {exec [interpreter] $path(err)} msg] $msg -} {1 {out -err}} +} -body { + exec [interpreter] $path(err) +} -returnCodes error -result {out +err} -# Errors in executing the Tcl command, as opposed to errors in the -# processes that are invoked. +# Errors in executing the Tcl command, as opposed to errors in the processes +# that are invoked. test exec-10.1 {errors in exec invocation} {exec} { list [catch {exec} msg] $msg @@ -432,12 +446,12 @@ test exec-10.22 {errors in exec invocation} \ # Commands in background. test exec-11.1 {commands in background} {exec} { - set x [lindex [time {exec [interpreter] $path(sleep) 2 &}] 0] - expr $x<1000000 + set time [time {exec [interpreter] $path(sleep) 2 &}] + expr {[lindex $time 0] < 1000000} } 1 -test exec-11.2 {commands in background} {exec} { - list [catch {exec [interpreter] $path(echo) a &b} msg] $msg -} {0 {a &b}} +test exec-11.2 {commands in background} -constraints {exec} -body { + exec [interpreter] $path(echo) a &b +} -result {a &b} test exec-11.3 {commands in background} {exec} { llength [exec [interpreter] $path(sleep) 1 &] } 1 @@ -448,35 +462,33 @@ test exec-11.5 {commands in background} {exec} { set f [open $path(gorp.file) w] puts $f [list catch [list exec [info nameofexecutable] $path(echo) foo &]] close $f - string compare "foo" [exec [interpreter] $path(gorp.file)] -} 0 + exec [interpreter] $path(gorp.file) +} foo -# Make sure that background commands are properly reaped when -# they eventually die. +# Make sure that background commands are properly reaped when they +# eventually die. -if {[testConstraint exec]} { - exec [interpreter] $path(sleep) 3 +if {[testConstraint exec] && [testConstraint nonPortable]} { + after 1300 + exec [interpreter] $path(sleep) 1 } -test exec-12.1 {reaping background processes} \ - {exec unix nonPortable} { +test exec-12.1 {reaping background processes} {exec unix nonPortable} { for {set i 0} {$i < 20} {incr i} { exec echo foo > /dev/null & } - exec sleep 1 + after 1000 catch {exec ps | fgrep "echo foo" | fgrep -v fgrep | wc} msg lindex $msg 0 } 0 -test exec-12.2 {reaping background processes} \ - {exec unix nonPortable} { +test exec-12.2 {reaping background processes} {exec unix nonPortable} { exec sleep 2 | sleep 2 | sleep 2 & catch {exec ps | fgrep -i "sleep" | fgrep -i -v fgrep | wc} msg set x [lindex $msg 0] - exec sleep 3 + after 3000 catch {exec ps | fgrep -i "sleep" | fgrep -i -v fgrep | wc} msg list $x [lindex $msg 0] } {3 0} -test exec-12.3 {reaping background processes} \ - {exec unix nonPortable} { +test exec-12.3 {reaping background processes} {exec unix nonPortable} { exec sleep 1000 & exec sleep 1000 & set x [exec ps | fgrep "sleep" | fgrep -v fgrep] @@ -489,7 +501,6 @@ test exec-12.3 {reaping background processes} \ } catch {exec ps | fgrep "sleep" | fgrep -v fgrep | wc} msg set x [lindex $msg 0] - foreach i $pids { catch {exec kill -KILL $i} } @@ -541,7 +552,7 @@ test exec-13.5 {extended exit result codes: max value} { -result {1 {CHILDSTATUS {} 1073741823}} } -test exec-13.6 {extended exit result codes: signalled} { +test exec-13.6 {extended exit result codes: signalled} { -constraints {win} -setup { set tmp [makeFile {exit 0xC0000016} tmpfile.exec-13.6] @@ -578,37 +589,37 @@ test exec-14.5 {-ignorestderr switch} {exec} { # Redirecting standard error separately from standard output test exec-15.1 {standard error redirection} {exec} { - exec [interpreter] "$path(echo)" "First line" > "$path(gorp.file)" - list [exec [interpreter] "$path(sh)" -c "\"$path(echo)\" foo bar 1>&2" 2> "$path(gorp.file)"] \ - [exec [interpreter] "$path(cat)" "$path(gorp.file)"] + exec [interpreter] $path(echo) "First line" > $path(gorp.file) + list [exec [interpreter] $path(sh) -c "\"$path(echo)\" foo bar 1>&2" 2> $path(gorp.file)] \ + [exec [interpreter] $path(cat) $path(gorp.file)] } {{} {foo bar}} test exec-15.2 {standard error redirection} {exec stdio} { - list [exec [interpreter] "$path(sh)" -c "\"$path(echo)\" foo bar 1>&2" \ - | [interpreter] "$path(echo)" biz baz >$path(gorp.file) 2> "$path(gorp.file2)"] \ - [exec [interpreter] "$path(cat)" "$path(gorp.file)"] \ - [exec [interpreter] "$path(cat)" "$path(gorp.file2)"] + list [exec [interpreter] $path(sh) -c "\"$path(echo)\" foo bar 1>&2" \ + | [interpreter] $path(echo) biz baz >$path(gorp.file) 2> $path(gorp.file2)] \ + [exec [interpreter] $path(cat) $path(gorp.file)] \ + [exec [interpreter] $path(cat) $path(gorp.file2)] } {{} {biz baz} {foo bar}} test exec-15.3 {standard error redirection} {exec stdio} { - list [exec [interpreter] "$path(sh)" -c "\"$path(echo)\" foo bar 1>&2" \ - | [interpreter] "$path(echo)" biz baz 2>$path(gorp.file) > "$path(gorp.file2)"] \ - [exec [interpreter] "$path(cat)" "$path(gorp.file)"] \ - [exec [interpreter] "$path(cat)" "$path(gorp.file2)"] + list [exec [interpreter] $path(sh) -c "\"$path(echo)\" foo bar 1>&2" \ + | [interpreter] $path(echo) biz baz 2>$path(gorp.file) > $path(gorp.file2)] \ + [exec [interpreter] $path(cat) $path(gorp.file)] \ + [exec [interpreter] $path(cat) $path(gorp.file2)] } {{} {foo bar} {biz baz}} test exec-15.4 {standard error redirection} {exec} { - set f [open "$path(gorp.file)" w] + set f [open $path(gorp.file) w] puts $f "Line 1" flush $f - exec [interpreter] "$path(sh)" -c "\"$path(echo)\" foo bar 1>&2" 2>@ $f + exec [interpreter] $path(sh) -c "\"$path(echo)\" foo bar 1>&2" 2>@ $f puts $f "Line 3" close $f - exec [interpreter] "$path(cat)" "$path(gorp.file)" + readfile $path(gorp.file) } {Line 1 foo bar Line 3} test exec-15.5 {standard error redirection} {exec} { - exec [interpreter] "$path(echo)" "First line" > "$path(gorp.file)" - exec [interpreter] "$path(sh)" -c "\"$path(echo)\" foo bar 1>&2" 2>> "$path(gorp.file)" - exec [interpreter] "$path(cat)" "$path(gorp.file)" + exec [interpreter] $path(echo) "First line" > "$path(gorp.file)" + exec [interpreter] $path(sh) -c "\"$path(echo)\" foo bar 1>&2" 2>> "$path(gorp.file)" + readfile $path(gorp.file) } {First line foo bar} test exec-15.6 {standard error redirection} {exec stdio} { @@ -627,7 +638,7 @@ test exec-16.1 {flush output before exec} {exec} { exec [interpreter] $path(echo) "Second line" >@ $f puts $f "Third line" close $f - exec [interpreter] $path(cat) $path(gorp.file) + readfile $path(gorp.file) } {First line Second line Third line} @@ -637,7 +648,7 @@ test exec-16.2 {flush output before exec} {exec} { exec [interpreter] << {puts stderr {Second line}} >&@ $f > $path(gorp.file2) puts $f "Third line" close $f - exec [interpreter] $path(cat) $path(gorp.file) + readfile $path(gorp.file) } {First line Second line Third line} @@ -712,3 +723,7 @@ unset -nocomplain path ::tcltest::cleanupTests return + +# Local Variables: +# mode: tcl +# End: diff --git a/tests/execute.test b/tests/execute.test index b460cfe..2613edc 100644 --- a/tests/execute.test +++ b/tests/execute.test @@ -1,18 +1,18 @@ -# This file contains tests for the tclExecute.c source file. Tests appear -# in the same order as the C code that they test. The set of tests is -# currently incomplete since it currently includes only new tests for -# code changed for the addition of Tcl namespaces. Other execution- -# related tests appear in several other test files including -# namespace.test, basic.test, eval.test, for.test, etc. +# This file contains tests for the tclExecute.c source file. Tests appear in +# the same order as the C code that they test. The set of tests is currently +# incomplete since it currently includes only new tests for code changed for +# the addition of Tcl namespaces. Other execution-related tests appear in +# several other test files including namespace.test, basic.test, eval.test, +# for.test, etc. # -# Sourcing this file into Tcl runs the tests and generates output for -# errors. No output means no errors were found. +# Sourcing this file into Tcl runs the tests and generates output for errors. +# No output means no errors were found. # # Copyright (c) 1997 Sun Microsystems, Inc. # Copyright (c) 1998-1999 by Scriptics Corporation. # -# See the file "license.terms" for information on usage and redistribution -# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# See the file "license.terms" for information on usage and redistribution of +# this file, and for a DISCLAIMER OF ALL WARRANTIES. if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -48,7 +48,6 @@ testConstraint testexprlongobj [llength [info commands testexprlongobj]] # INST_EXPR_STK not tested # INST_LOAD_SCALAR1 - test execute-1.1 {TclExecuteByteCode, INST_LOAD_SCALAR1, small opnd} { proc foo {} { set x 1 @@ -66,7 +65,6 @@ test execute-1.2 {TclExecuteByteCode, INST_LOAD_SCALAR1, large opnd} { set y 1 return $y } - proc foo {} $body foo } 1 @@ -91,7 +89,6 @@ test execute-2.1 {TclExecuteByteCode, INST_LOAD_SCALAR4, simple case} { set y 1 return $y } - proc foo {} $body foo } 1 @@ -105,12 +102,10 @@ test execute-2.2 {TclExecuteByteCode, INST_LOAD_SCALAR4, error} { unset y return $y } - proc foo {} $body list [catch {foo} msg] $msg } {1 {can't read "y": no such variable}} - # INST_LOAD_SCALAR_STK not tested # INST_LOAD_ARRAY4 not tested # INST_LOAD_ARRAY1 not tested @@ -693,7 +688,7 @@ test execute-6.12 {Tcl_ExprObj: exprcode interp validation} { lappend result [e $e] interp delete slave interp create slave - interp alias {} e slave expr + interp alias {} e slave expr lappend result [e $e] interp delete slave set result @@ -888,8 +883,8 @@ test execute-7.34 {Wide int handling} { } 1099511627776 test execute-8.1 {Stack protection} -setup { - # If [Bug #804681] has not been properly - # taken care of, this should segfault + # If [Bug #804681] has not been properly taken care of, this should + # segfault proc whatever args {llength $args} trace add variable ::errorInfo {write unset} whatever } -body { @@ -915,7 +910,7 @@ test execute-8.2 {Stack restoration} -body { test execute-8.3 {Stack restoration} -body { # Test for [Bug #1055676], correct restoration - # of the stack top after the epoch is bumped and + # of the stack top after the epoch is bumped and # the stack is grown in a call from a nested evaluation set arglst [string repeat "a " 1000] proc f {args} "f $arglst" @@ -959,7 +954,7 @@ test execute-8.4 {Compile epoch bump effect on stack trace} -setup { test execute-9.1 {Interp result resetting [Bug 1522803]} { set c 0 catch { - catch {set foo} + catch {error foo} expr {1/$c} } if {[string match *foo* $::errorInfo]} { @@ -1000,4 +995,5 @@ return # Local Variables: # mode: tcl +# fill-column: 78 # End: diff --git a/tests/fCmd.test b/tests/fCmd.test index 76fecd4..040882b 100644 --- a/tests/fCmd.test +++ b/tests/fCmd.test @@ -2570,7 +2570,7 @@ cd [workingDirectory] test fCmd-30.1 {file writable on 'My Documents'} -setup { # Get the localized version of the folder name by looking in the registry. set mydocsname [registry get {HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders} Personal] -} -constraints {win reg} -body { +} -constraints {win reg nonPortable} -body { file writable $mydocsname } -result 1 test fCmd-30.2 {file readable on 'NTUSER.DAT'} -constraints {win} -body { diff --git a/tests/registry.test b/tests/registry.test index 79c6fba..539ba2d 100644 --- a/tests/registry.test +++ b/tests/registry.test @@ -535,7 +535,7 @@ test registry-7.3 {GetValueNames} -constraints {win reg} -setup { } -cleanup { registry delete HKEY_CURRENT_USER\\TclFoobar } -result {{} baz blat} -test registry-7.4 {GetValueNames: remote key} -constraints {win reg english} -body { +test registry-7.4 {GetValueNames: remote key} -constraints {win reg nonPortable english} -body { set hostname [info hostname] registry set \\\\$hostname\\HKEY_CURRENT_USER\\TclFoobar baz blat set result [registry values \\\\$hostname\\HKEY_CURRENT_USER\\TclFoobar] |