summaryrefslogtreecommitdiffstats
path: root/contrib/tcl/tests/exec.test
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/tcl/tests/exec.test')
-rw-r--r--contrib/tcl/tests/exec.test415
1 files changed, 244 insertions, 171 deletions
diff --git a/contrib/tcl/tests/exec.test b/contrib/tcl/tests/exec.test
index 4b00c44..169885a 100644
--- a/contrib/tcl/tests/exec.test
+++ b/contrib/tcl/tests/exec.test
@@ -10,7 +10,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# SCCS: @(#) exec.test 1.56 97/06/20 13:27:37
+# SCCS: @(#) exec.test 1.58 97/08/01 11:10:00
if {[string compare test [info procs test]] == 1} then {source defs}
@@ -20,181 +20,255 @@ if {[info commands exec] == ""} {
puts "exec not implemented for this machine"
return
}
+if {$testConfig(stdio) == 0} {
+ return
+}
-proc cat {name} {
- set f [open $name r]
- set x [read -nonewline $f]
- close $f
- set x
+set f [open echo w]
+puts $f {
+ puts -nonewline [lindex $argv 0]
+ foreach str [lrange $argv 1 end] {
+ puts -nonewline " $str"
+ }
+ puts {}
}
+close $f
+
+set f [open cat w]
+puts $f {
+ if {$argv == {}} {
+ set argv -
+ }
+ foreach name $argv {
+ if {$name == "-"} {
+ set f stdin
+ } elseif {[catch {open $name r} f] != 0} {
+ puts stderr $f
+ continue
+ }
+ while {[eof $f] == 0} {
+ puts -nonewline [read $f]
+ }
+ if {$f != "stdin"} {
+ close $f
+ }
+ }
+}
+close $f
+
+set f [open wc w]
+puts $f {
+ set data [read stdin]
+ set lines [regsub -all "\n" $data {} dummy]
+ set words [regsub -all "\[^ \t\n]+" $data {} dummy]
+ set chars [string length $data]
+ puts [format "%8.d%8.d%8.d" $lines $words $chars]
+}
+close $f
+
+set f [open sh w]
+puts $f {
+ if {[lindex $argv 0] != "-c"} {
+ error "sh: unexpected arguments $argv"
+ }
+ set cmd [lindex $argv 1]
+ lappend cmd ";"
+
+ set newcmd {}
+
+ foreach arg $cmd {
+ if {$arg == ";"} {
+ eval exec >@stdout 2>@stderr [list [info nameofexecutable]] $newcmd
+ set newcmd {}
+ continue
+ }
+ if {$arg == "1>&2"} {
+ set arg >@stderr
+ }
+ lappend newcmd $arg
+ }
+}
+close $f
+
+set f [open sleep w]
+puts $f {
+ after [expr $argv*1000]
+}
+close $f
+
+set f [open exit w]
+puts $f {
+ exit $argv
+}
+close $f
# Basic operations.
-test exec-1.1 {basic exec operation} {unixExecs} {
- exec echo a b c
+test exec-1.1 {basic exec operation} {
+ exec $tcltest echo a b c
} "a b c"
-test exec-1.2 {pipelining} {unixExecs} {
- exec echo a b c d | cat | cat
+test exec-1.2 {pipelining} {
+ exec $tcltest echo a b c d | $tcltest cat | $tcltest cat
} "a b c d"
-test exec-1.3 {pipelining} {unixExecs} {
- set a [exec echo a b c d | cat | wc]
+test exec-1.3 {pipelining} {
+ set a [exec $tcltest echo a b c d | $tcltest cat | $tcltest wc]
list [scan $a "%d %d %d" b c d] $b $c
} {3 1 4}
set arg {12345678901234567890123456789012345678901234567890}
set arg "$arg$arg$arg$arg$arg$arg"
-test exec-1.4 {long command lines} {unixExecs} {
- exec echo $arg
+test exec-1.4 {long command lines} {
+ exec $tcltest echo $arg
} $arg
set arg {}
# I/O redirection: input from Tcl command.
-test exec-2.1 {redirecting input from immediate source} {unixExecs} {
- exec cat << "Sample text"
+test exec-2.1 {redirecting input from immediate source} {
+ exec $tcltest cat << "Sample text"
} {Sample text}
-test exec-2.2 {redirecting input from immediate source} {unixExecs} {
- exec << "Sample text" cat | cat
+test exec-2.2 {redirecting input from immediate source} {
+ exec << "Sample text" $tcltest cat | $tcltest cat
} {Sample text}
-test exec-2.3 {redirecting input from immediate source} {unixExecs} {
- exec cat << "Sample text" | cat
+test exec-2.3 {redirecting input from immediate source} {
+ exec $tcltest cat << "Sample text" | $tcltest cat
} {Sample text}
-test exec-2.4 {redirecting input from immediate source} {unixExecs} {
- exec cat | cat << "Sample text"
+test exec-2.4 {redirecting input from immediate source} {
+ exec $tcltest cat | $tcltest cat << "Sample text"
} {Sample text}
-test exec-2.5 {redirecting input from immediate source} {unixExecs} {
- exec cat "<<Joined to arrows"
+test exec-2.5 {redirecting input from immediate source} {
+ exec $tcltest cat "<<Joined to arrows"
} {Joined to arrows}
# I/O redirection: output to file.
-catch {exec rm -f gorp.file}
-test exec-3.1 {redirecting output to file} {unixExecs} {
- exec echo "Some simple words" > gorp.file
- exec cat gorp.file
+file delete gorp.file
+test exec-3.1 {redirecting output to file} {
+ exec $tcltest echo "Some simple words" > gorp.file
+ exec $tcltest cat gorp.file
} "Some simple words"
-test exec-3.2 {redirecting output to file} {unixExecs} {
- exec echo "More simple words" | >gorp.file cat | cat
- exec cat gorp.file
+test exec-3.2 {redirecting output to file} {
+ exec $tcltest echo "More simple words" | >gorp.file $tcltest cat | $tcltest cat
+ exec $tcltest cat gorp.file
} "More simple words"
-test exec-3.3 {redirecting output to file} {unixExecs} {
- exec > gorp.file echo "Different simple words" | cat | cat
- exec cat gorp.file
+test exec-3.3 {redirecting output to file} {
+ exec > gorp.file $tcltest echo "Different simple words" | $tcltest cat | $tcltest cat
+ exec $tcltest cat gorp.file
} "Different simple words"
-test exec-3.4 {redirecting output to file} {unixExecs} {
- exec echo "Some simple words" >gorp.file
- exec cat gorp.file
+test exec-3.4 {redirecting output to file} {
+ exec $tcltest echo "Some simple words" >gorp.file
+ exec $tcltest cat gorp.file
} "Some simple words"
-test exec-3.5 {redirecting output to file} {unixExecs} {
- exec echo "First line" >gorp.file
- exec echo "Second line" >> gorp.file
- exec cat gorp.file
+test exec-3.5 {redirecting output to file} {
+ exec $tcltest echo "First line" >gorp.file
+ exec $tcltest echo "Second line" >> gorp.file
+ exec $tcltest cat gorp.file
} "First line\nSecond line"
-test exec-3.6 {redirecting output to file} {unixExecs} {
- exec echo "First line" >gorp.file
- exec echo "Second line" >>gorp.file
- exec cat gorp.file
+test exec-3.6 {redirecting output to file} {
+ exec $tcltest echo "First line" >gorp.file
+ exec $tcltest echo "Second line" >>gorp.file
+ exec $tcltest cat gorp.file
} "First line\nSecond line"
-test exec-3.7 {redirecting output to file} {unixExecs} {
+test exec-3.7 {redirecting output to file} {
set f [open gorp.file w]
puts $f "Line 1"
flush $f
- exec echo "More text" >@ $f
- exec echo >@$f "Even more"
+ exec $tcltest echo "More text" >@ $f
+ exec $tcltest echo >@$f "Even more"
puts $f "Line 3"
close $f
- exec cat gorp.file
+ exec $tcltest cat gorp.file
} "Line 1\nMore text\nEven more\nLine 3"
# I/O redirection: output and stderr to file.
-catch {exec rm -f gorp.file}
-test exec-4.1 {redirecting output and stderr to file} {unixExecs} {
- exec echo "test output" >& gorp.file
- exec cat gorp.file
+file delete gorp.file
+test exec-4.1 {redirecting output and stderr to file} {
+ exec $tcltest echo "test output" >& gorp.file
+ exec $tcltest cat gorp.file
} "test output"
-test exec-4.2 {redirecting output and stderr to file} {unixExecs} {
- list [exec sh -c "echo foo bar 1>&2" >&gorp.file] \
- [exec cat gorp.file]
+test exec-4.2 {redirecting output and stderr to file} {
+ list [exec $tcltest sh -c "echo foo bar 1>&2" >&gorp.file] \
+ [exec $tcltest cat gorp.file]
} {{} {foo bar}}
-test exec-4.3 {redirecting output and stderr to file} {unixExecs} {
- exec echo "first line" > gorp.file
- list [exec sh -c "echo foo bar 1>&2" >>&gorp.file] \
- [exec cat gorp.file]
+test exec-4.3 {redirecting output and stderr to file} {
+ exec $tcltest echo "first line" > gorp.file
+ list [exec $tcltest sh -c "echo foo bar 1>&2" >>&gorp.file] \
+ [exec $tcltest cat gorp.file]
} "{} {first line\nfoo bar}"
-test exec-4.4 {redirecting output and stderr to file} {unixExecs} {
+test exec-4.4 {redirecting output and stderr to file} {
set f [open gorp.file w]
puts $f "Line 1"
flush $f
- exec echo "More text" >&@ $f
- exec echo >&@$f "Even more"
+ exec $tcltest echo "More text" >&@ $f
+ exec $tcltest echo >&@$f "Even more"
puts $f "Line 3"
close $f
- exec cat gorp.file
+ exec $tcltest cat gorp.file
} "Line 1\nMore text\nEven more\nLine 3"
-test exec-4.5 {redirecting output and stderr to file} {unixExecs} {
+test exec-4.5 {redirecting output and stderr to file} {
set f [open gorp.file w]
puts $f "Line 1"
flush $f
- exec >&@ $f sh -c "echo foo bar 1>&2"
- exec >&@$f sh -c "echo xyzzy 1>&2"
+ exec >&@ $f $tcltest sh -c "echo foo bar 1>&2"
+ exec >&@$f $tcltest sh -c "echo xyzzy 1>&2"
puts $f "Line 3"
close $f
- exec cat gorp.file
+ exec $tcltest cat gorp.file
} "Line 1\nfoo bar\nxyzzy\nLine 3"
# I/O redirection: input from file.
-catch {exec echo "Just a few thoughts" > gorp.file}
-test exec-5.1 {redirecting input from file} {unixExecs} {
- exec cat < gorp.file
+exec $tcltest echo "Just a few thoughts" > gorp.file
+test exec-5.1 {redirecting input from file} {
+ exec $tcltest cat < gorp.file
} {Just a few thoughts}
-test exec-5.2 {redirecting input from file} {unixExecs} {
- exec cat | cat < gorp.file
+test exec-5.2 {redirecting input from file} {
+ exec $tcltest cat | $tcltest cat < gorp.file
} {Just a few thoughts}
-test exec-5.3 {redirecting input from file} {unixExecs} {
- exec cat < gorp.file | cat
+test exec-5.3 {redirecting input from file} {
+ exec $tcltest cat < gorp.file | $tcltest cat
} {Just a few thoughts}
-test exec-5.4 {redirecting input from file} {unixExecs} {
- exec < gorp.file cat | cat
+test exec-5.4 {redirecting input from file} {
+ exec < gorp.file $tcltest cat | $tcltest cat
} {Just a few thoughts}
-test exec-5.5 {redirecting input from file} {unixExecs} {
- exec cat <gorp.file
+test exec-5.5 {redirecting input from file} {
+ exec $tcltest cat <gorp.file
} {Just a few thoughts}
-test exec-5.6 {redirecting input from file} {unixExecs} {
+test exec-5.6 {redirecting input from file} {
set f [open gorp.file r]
- set result [exec cat <@ $f]
+ set result [exec $tcltest cat <@ $f]
close $f
set result
} {Just a few thoughts}
-test exec-5.7 {redirecting input from file} {unixExecs} {
+test exec-5.7 {redirecting input from file} {
set f [open gorp.file r]
- set result [exec <@$f cat]
+ set result [exec <@$f $tcltest cat]
close $f
set result
} {Just a few thoughts}
# I/O redirection: standard error through a pipeline.
-test exec-6.1 {redirecting stderr through a pipeline} {unixExecs} {
- exec sh -c "echo foo bar" |& cat
+test exec-6.1 {redirecting stderr through a pipeline} {
+ exec $tcltest sh -c "echo foo bar" |& $tcltest cat
} "foo bar"
-test exec-6.2 {redirecting stderr through a pipeline} {unixExecs} {
- exec sh -c "echo foo bar 1>&2" |& cat
+test exec-6.2 {redirecting stderr through a pipeline} {
+ exec $tcltest sh -c "echo foo bar 1>&2" |& $tcltest cat
} "foo bar"
-test exec-6.3 {redirecting stderr through a pipeline} {unixExecs} {
- exec sh -c "echo foo bar 1>&2" \
- |& sh -c "echo second msg 1>&2; cat" |& cat
+test exec-6.3 {redirecting stderr through a pipeline} {
+ exec $tcltest sh -c "echo foo bar 1>&2" \
+ |& $tcltest sh -c "echo second msg 1>&2 ; cat" |& $tcltest cat
} "second msg\nfoo bar"
# I/O redirection: combinations.
catch {exec rm -f gorp.file2}
-test exec-7.1 {multiple I/O redirections} {unixExecs} {
- exec << "command input" > gorp.file2 cat < gorp.file
- exec cat gorp.file2
+test exec-7.1 {multiple I/O redirections} {
+ exec << "command input" > gorp.file2 $tcltest cat < gorp.file
+ exec $tcltest cat gorp.file2
} {Just a few thoughts}
-test exec-7.2 {multiple I/O redirections} {unixExecs} {
- exec < gorp.file << "command input" cat
+test exec-7.2 {multiple I/O redirections} {
+ exec < gorp.file << "command input" $tcltest cat
} {command input}
# Long input to command and output from command.
@@ -204,8 +278,8 @@ set a [concat $a $a $a $a]
set a [concat $a $a $a $a]
set a [concat $a $a $a $a]
set a [concat $a $a $a $a]
-test exec-8.1 {long input and output} {unixExecs} {
- exec cat << $a
+test exec-8.1 {long input and output} {
+ exec $tcltest cat << $a
} $a
# Commands that return errors.
@@ -214,25 +288,25 @@ test exec-9.1 {commands returning errors} {
set x [catch {exec gorp456} msg]
list $x [string tolower $msg] [string tolower $errorCode]
} {1 {couldn't execute "gorp456": no such file or directory} {posix enoent {no such file or directory}}}
-test exec-9.2 {commands returning errors} {unixExecs} {
- string tolower [list [catch {exec echo foo | foo123} msg] $msg $errorCode]
+test exec-9.2 {commands returning errors} {
+ string tolower [list [catch {exec $tcltest 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} {unixExecs} {
- list [catch {exec sleep 1 | sh -c "exit 43" | sleep 1} msg] $msg
+test exec-9.3 {commands returning errors} {
+ list [catch {exec $tcltest sleep 1 | $tcltest exit 43 | $tcltest sleep 1} msg] $msg
} {1 {child process exited abnormally}}
-test exec-9.4 {commands returning errors} {unixExecs} {
- list [catch {exec sh -c "exit 43" | echo "foo bar"} msg] $msg
+test exec-9.4 {commands returning errors} {
+ list [catch {exec $tcltest exit 43 | $tcltest echo "foo bar"} msg] $msg
} {1 {foo bar
child process exited abnormally}}
-test exec-9.5 {commands returning errors} {unixExecs} {
- list [catch {exec gorp456 | echo a b c} msg] [string tolower $msg]
+test exec-9.5 {commands returning errors} {
+ list [catch {exec gorp456 | $tcltest 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} {unixExecs} {
- list [catch {exec sh -c "echo error msg 1>&2"} msg] $msg
+test exec-9.6 {commands returning errors} {
+ list [catch {exec $tcltest sh -c "echo error msg 1>&2"} msg] $msg
} {1 {error msg}}
-test exec-9.7 {commands returning errors} {unixExecs} {
- list [catch {exec sh -c "echo error msg 1>&2" \
- | sh -c "echo error msg 1>&2"} msg] $msg
+test exec-9.7 {commands returning errors} {
+ list [catch {exec $tcltest sh -c "echo error msg 1>&2" \
+ | $tcltest sh -c "echo error msg 1>&2"} msg] $msg
} {1 {error msg
error msg}}
@@ -281,13 +355,13 @@ test exec-10.13 {errors in exec invocation} {
test exec-10.14 {errors in exec invocation} {
list [catch {exec cat <@} msg] $msg
} {1 {can't specify "<@" as last word in command}}
-test exec-10.15 {errors in exec invocation} {unixExecs} {
+test exec-10.15 {errors in exec invocation} {
list [catch {exec cat < a/b/c} msg] [string tolower $msg]
} {1 {couldn't read file "a/b/c": no such file or directory}}
-test exec-10.16 {errors in exec invocation} {unixExecs} {
+test exec-10.16 {errors in exec invocation} {
list [catch {exec cat << foo > a/b/c} msg] [string tolower $msg]
} {1 {couldn't write file "a/b/c": no such file or directory}}
-test exec-10.17 {errors in exec invocation} {unixExecs} {
+test exec-10.17 {errors in exec invocation} {
list [catch {exec cat << foo > a/b/c} msg] [string tolower $msg]
} {1 {couldn't write file "a/b/c": no such file or directory}}
set f [open gorp.file w]
@@ -303,36 +377,36 @@ close $f
test exec-10.20 {errors in exec invocation} {
list [catch {exec ~non_existent_user/foo/bar} msg] $msg
} {1 {user "non_existent_user" doesn't exist}}
-test exec-10.21 {errors in exec invocation} {unixExecs} {
- list [catch {exec true | ~xyzzy_bad_user/x | false} msg] $msg
+test exec-10.21 {errors in exec invocation} {
+ list [catch {exec $tcltest true | ~xyzzy_bad_user/x | false} msg] $msg
} {1 {user "xyzzy_bad_user" doesn't exist}}
# Commands in background.
-test exec-11.1 {commands in background} {unixExecs} {
- set x [lindex [time {exec sleep 2 &}] 0]
+test exec-11.1 {commands in background} {
+ set x [lindex [time {exec $tcltest sleep 2 &}] 0]
expr $x<1000000
} 1
-test exec-11.2 {commands in background} {unixExecs} {
- list [catch {exec echo a &b} msg] $msg
+test exec-11.2 {commands in background} {
+ list [catch {exec $tcltest echo a &b} msg] $msg
} {0 {a &b}}
-test exec-11.3 {commands in background} {unixExecs} {
- llength [exec sleep 1 &]
+test exec-11.3 {commands in background} {
+ llength [exec $tcltest sleep 1 &]
} 1
-test exec-11.4 {commands in background} {unixExecs} {
- llength [exec sleep 1 | sleep 1 | sleep 1 &]
+test exec-11.4 {commands in background} {
+ llength [exec $tcltest sleep 1 | $tcltest sleep 1 | $tcltest sleep 1 &]
} 3
-test exec-11.5 {commands in background} {unixExecs} {
+test exec-11.5 {commands in background} {
set f [open gorp.file w]
- puts $f { catch { exec echo foo & } }
+ puts $f { catch { exec [info nameofexecutable] echo foo & } }
close $f
- string compare "foo" [exec [info nameofexecutable] gorp.file]
+ string compare "foo" [exec $tcltest gorp.file]
} 0
# Make sure that background commands are properly reaped when
# they eventually die.
-catch {exec sleep 3}
+exec $tcltest sleep 3
test exec-12.1 {reaping background processes} {unixOnly nonPortable} {
for {set i 0} {$i < 20} {incr i} {
exec echo foo > /dev/null &
@@ -341,7 +415,7 @@ test exec-12.1 {reaping background processes} {unixOnly nonPortable} {
catch {exec ps | fgrep "echo foo" | fgrep -v fgrep | wc} msg
lindex $msg 0
} 0
-test exec-12.2 {reaping background processes} {unixExecs nonPortable} {
+test exec-12.2 {reaping background processes} {unixOnly 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]
@@ -372,11 +446,11 @@ test exec-12.3 {reaping background processes} {unixOnly nonPortable} {
# Make sure "errorCode" is set correctly.
-test exec-13.1 {setting errorCode variable} {unixExecs} {
- list [catch {exec cat < a/b/c} msg] [string tolower $errorCode]
+test exec-13.1 {setting errorCode variable} {
+ list [catch {exec $tcltest cat < a/b/c} msg] [string tolower $errorCode]
} {1 {posix enoent {no such file or directory}}}
-test exec-13.2 {setting errorCode variable} {unixExecs} {
- list [catch {exec cat > a/b/c} msg] [string tolower $errorCode]
+test exec-13.2 {setting errorCode variable} {
+ list [catch {exec $tcltest cat > a/b/c} msg] [string tolower $errorCode]
} {1 {posix enoent {no such file or directory}}}
test exec-13.3 {setting errorCode variable} {
set x [catch {exec _weird_cmd_} msg]
@@ -386,8 +460,8 @@ test exec-13.3 {setting errorCode variable} {
# Switches before the first argument
-test exec-14.1 {-keepnewline switch} {unixExecs} {
- exec -keepnewline echo foo
+test exec-14.1 {-keepnewline switch} {
+ exec -keepnewline $tcltest echo foo
} "foo\n"
test exec-14.2 {-keepnewline switch} {
list [catch {exec -keepnewline} msg] $msg
@@ -401,75 +475,77 @@ test exec-14.4 {-- switch} {
# Redirecting standard error separately from standard output
-test exec-15.1 {standard error redirection} {unixExecs} {
- exec echo "First line" > gorp.file
- list [exec sh -c "echo foo bar 1>&2" 2> gorp.file] \
- [exec cat gorp.file]
+test exec-15.1 {standard error redirection} {
+ exec $tcltest echo "First line" > gorp.file
+ list [exec $tcltest sh -c "echo foo bar 1>&2" 2> gorp.file] \
+ [exec $tcltest cat gorp.file]
} {{} {foo bar}}
-test exec-15.2 {standard error redirection} {unixExecs} {
- list [exec sh -c "echo foo bar 1>&2" | echo biz baz >gorp.file \
- 2> gorp.file2] [exec cat gorp.file] \
- [exec cat gorp.file2]
+test exec-15.2 {standard error redirection} {
+ list [exec $tcltest sh -c "echo foo bar 1>&2" \
+ | $tcltest echo biz baz >gorp.file 2> gorp.file2] \
+ [exec $tcltest cat gorp.file] \
+ [exec $tcltest cat gorp.file2]
} {{} {biz baz} {foo bar}}
-test exec-15.3 {standard error redirection} {unixExecs} {
- list [exec sh -c "echo foo bar 1>&2" | echo biz baz 2>gorp.file \
- > gorp.file2] [exec cat gorp.file] \
- [exec cat gorp.file2]
+test exec-15.3 {standard error redirection} {
+ list [exec $tcltest sh -c "echo foo bar 1>&2" \
+ | $tcltest echo biz baz 2>gorp.file > gorp.file2] \
+ [exec $tcltest cat gorp.file] \
+ [exec $tcltest cat gorp.file2]
} {{} {foo bar} {biz baz}}
-test exec-15.4 {standard error redirection} {unixExecs} {
+test exec-15.4 {standard error redirection} {
set f [open gorp.file w]
puts $f "Line 1"
flush $f
- exec sh -c "echo foo bar 1>&2" 2>@ $f
+ exec $tcltest sh -c "echo foo bar 1>&2" 2>@ $f
puts $f "Line 3"
close $f
- exec cat gorp.file
+ exec $tcltest cat gorp.file
} {Line 1
foo bar
Line 3}
-test exec-15.5 {standard error redirection} {unixExecs} {
- exec echo "First line" > gorp.file
- exec sh -c "echo foo bar 1>&2" 2>> gorp.file
- exec cat gorp.file
+test exec-15.5 {standard error redirection} {
+ exec $tcltest echo "First line" > gorp.file
+ exec $tcltest sh -c "echo foo bar 1>&2" 2>> gorp.file
+ exec $tcltest cat gorp.file
} {First line
foo bar}
-test exec-15.6 {standard error redirection} {unixExecs} {
- exec sh -c "echo foo bar 1>&2" > gorp.file2 2> gorp.file \
- >& gorp.file 2> gorp.file2 | echo biz baz
- list [exec cat gorp.file] [exec cat gorp.file2]
+test exec-15.6 {standard error redirection} {
+ exec $tcltest sh -c "echo foo bar 1>&2" > gorp.file2 2> gorp.file \
+ >& gorp.file 2> gorp.file2 | $tcltest echo biz baz
+ list [exec $tcltest cat gorp.file] [exec $tcltest cat gorp.file2]
} {{biz baz} {foo bar}}
-test exec-16.1 {flush output before exec} {unixExecs} {
+test exec-16.1 {flush output before exec} {
set f [open gorp.file w]
puts $f "First line"
- exec echo "Second line" >@ $f
+ exec $tcltest echo "Second line" >@ $f
puts $f "Third line"
close $f
- exec cat gorp.file
+ exec $tcltest cat gorp.file
} {First line
Second line
Third line}
test exec-16.2 {flush output before exec} {} {
set f [open gorp.file w]
puts $f "First line"
- exec [lindex $tcltest 0] << {puts stderr {Second line}} >&@ $f > gorp.file2
+ exec $tcltest << {puts stderr {Second line}} >&@ $f > gorp.file2
puts $f "Third line"
close $f
- cat gorp.file
+ exec $tcltest cat gorp.file
} {First line
Second line
Third line}
-test exec-17.1 { inheriting standard I/O } {unixOrPc unixExecs} {
+test exec-17.1 { inheriting standard I/O } {
set f [open script w]
puts $f {close stdout
set f [open gorp.file w]
- catch {exec echo foobar &}
- exec sleep 2
+ catch {exec [info nameofexecutable] echo foobar &}
+ exec [info nameofexecutable] sleep 2
close $f
}
close $f
- catch {eval exec $tcltest script} result
+ catch {exec $tcltest script} result
set f [open gorp.file r]
lappend result [read $f]
close $f
@@ -477,8 +553,5 @@ test exec-17.1 { inheriting standard I/O } {unixOrPc unixExecs} {
} {{foobar
}}
-removeFile script
-removeFile gorp.file
-removeFile gorp.file2
-
-return {}
+file delete script gorp.file gorp.file2
+file delete echo cat wc sh sleep exit
OpenPOWER on IntegriCloud