aboutsummaryrefslogtreecommitdiff
path: root/tests/jimsh.test
blob: 8faf2d81de2458911601d26b9e0b69d9c104cca5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
source [file dirname [info script]]/testing.tcl

needs constraint jim

test jimsh-1.1 {jimsh --help} -body {
	exec [info nameofexecutable] --help
} -match glob -result {jimsh version *Usage: *}

test jimsh-1.2 {jimsh -} {
	exec [info nameofexecutable] - << {puts $(1 + 2)}
} {3}

test jimsh-1.3 {jimsh - arg list} jim {
	exec [info nameofexecutable] - arg list << {puts [join $argv]}
} {arg list}

test jimsh-1.4 {jimsh -e} {
	exec [info nameofexecutable] -e {expr {4 + 5}}
} {9}

test jimsh-1.4 {jimsh -e with args} {
	exec [info nameofexecutable] -e {set argv} arg1 arg2
} {arg1 arg2}

test jimsh-1.5 {jimsh --version} {
	exec [info nameofexecutable] --version
} [info version]

test jimsh-1.6 {jimsh -e with error} -body {
	exec [info nameofexecutable] -e blah
} -returnCodes error -match glob -result {invalid command name "blah"*}

test jimsh-1.7 {jimsh exit code} -body {
	set script "set x 3\nincr x\nexit \$x\n"
	set rc [catch {exec [info nameofexecutable] << $script} msg opts]
	lassign [dict get $opts -errorcode] status pid exitcode
	list $rc $status $exitcode
} -result {1 CHILDSTATUS 4}

test jimsh-1.8 {jimsh error} -body {
	exec [info nameofexecutable] << "blah\n"
} -returnCodes error -match glob -result {stdin:1: Error: invalid command name "blah"*}

testreport