Tcl Source Code

Artifact [3da397c468]
Login

Artifact 3da397c4688680d27b56fc17f3623cee285469ded895c0cd78eaed63b9d0d445:

Attachment "exercise.tcl" to ticket [77527e2f99] added by erikleunissen 2021-01-13 19:19:41. (unpublished)
#! /bin/sh
# If executed as a shell script, the next line replaces the shell \
exec tclsh "$0" ${1+"$@"}

set MyApp {
	interp create child
	proc someProc {} {
		child eval {
			puts "Hi from child."
			puts stderr "Error message from child."
		}
	}
}

package require tcltest 2.2
namespace import -force ::tcltest::*
tcltest::configure -verbose {body pass error}

test someProc-1.1 {capture output from child interp} -setup {
	eval $MyApp
} -body {
	someProc
} -result {} -output "Hi from child.\n" -errorOutput "Error message from child.\n" -cleanup {
	interp delete child
}
tcltest::cleanupTests