Debian Codegraph @

test/mhshow/test-exec

raw
1 #! /bin/sh
2
3 # Test production and execution of user's commands.
4
5 set -e
6
7 if test -z "${MH_OBJ_DIR}"; then
8 srcdir=`dirname "$0"`/../..
9 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
10 fi
11
12 . "$MH_OBJ_DIR/test/common.sh"
13
14 setup_test
15
16 got="$MH_TEST_DIR"/$$.got
17 want="$MH_TEST_DIR"/$$.want
18
19 # The third word, if it exists, of the command executed is plucked as
20 # the name to display on the faulty assumption the arguments start ["sh",
21 # "-c"]. Plucking occurred for NULL in the past so test it here.
22 start_test 'plucking of third word for command'\''s display name'
23 email=`mhpath new`
24 cat >"$email" <<\E
25 From: [email protected]
26 MIME-Version: 1.0
27 Content-Type: text/foo
28 Date: Sun, 18 Dec 2005 00:52:39 +0100
29
30 E
31 cp "$MH" "$MH.orig"
32 cmd= argv2=
33 for w in false foo bar xyzzy; do
34 cmd="$cmd $w"
35 if test $w = bar; then argv2="$w: "; fi
36 cp "$MH.orig" "$MH"
37 echo "mhshow-show-text/foo: $cmd" >>"$MH"
38 set +e
39 #### map 255, which is the status on Solaris, to 1
40 run_prog mhshow last | sed 's/\(exited\) 255/\1 1/' >"$got" 2>&1
41 set -e
42 cat >"$want" <<\E
43 [ Message inbox:11 ]
44 Date: Sun, 18 Dec 2005 00:52:39 +0100
45 From: [email protected]
46
47 MIME-Version: 1.0
48
49 E
50 echo "${argv2}exited 1" >>"$want"
51 check "$want" "$got" : check "word $w"
52 done
53 mv "$MH.orig" "$MH"
54
55 finish_test