1
2 #### --debug-file
3 $SH --debug-file $TMP/debug.txt -c 'true'
4 grep 'OSH started with' $TMP/debug.txt >/dev/null && echo yes
5 ## stdout: yes
6
7 #### crash dump
8 rm -f $TMP/*.json
9 OSH_CRASH_DUMP_DIR=$TMP $SH -c '
10 g() {
11 local glocal="glocal"
12 echo $(( 1 / 0 ))
13 }
14 f() {
15 local flocal="flocal"
16 shift
17 FOO=bar g
18 }
19 readonly array=(A B C)
20 f "${array[@]}"
21 ' dummy a b c
22 echo status=$?
23 # Just check that we can parse it. TODO: Test properties.
24 python2 -m json.tool $TMP/*.json > /dev/null
25 echo status=$?
26 ## STDOUT:
27 status=1
28 status=0
29 ## END
30
31 #### crash dump with source
32 # TODO: The failure is not propagated through 'source'. Failure only happens
33 # on 'errexit'.
34 #rm -f $TMP/*.json
35 OSH_CRASH_DUMP_DIR=$TMP $SH -c '
36 set -o errexit
37 source spec/testdata/crash.sh
38 '
39 echo status=$?
40
41 # Now try to parse crash dumps
42 set -o xtrace
43 set -o errexit
44 ok=0
45 for dump in $TMP/*.json; do
46 # Workaround for test issue: release binaries leave empty files because they
47 # don't have the json module.
48 if test -s $dump; then # non-empty
49 python -m json.tool $dump > /dev/null
50 echo "OK $dump" >&2
51 (( ++ok ))
52 fi
53 done
54 if test $ok -ge 1; then # make sure we parsed at least once crash dump
55 echo OK
56 fi
57 ## STDOUT:
58 status=1
59 OK
60 ## END
61
62 # NOTE: strict_arith has one case in arith.test.sh), strict_word-eval has a case in var-op-other.
63
64
65 #### help osh and oil
66 help osh > $TMP/osh.txt
67 echo osh $?
68 help oil > $TMP/oil.txt
69 echo oil $?
70
71 help index ZZZ > $TMP/index.txt
72 echo index ZZZ $?
73 ## STDOUT:
74 osh 0
75 oil 0
76 index ZZZ 1
77 ## END
78