1 #!/usr/bin/env bash
2
3 #### --debug-file
4 $SH --debug-file $TMP/debug.txt -c 'true'
5 grep 'Debug file' $TMP/debug.txt >/dev/null && echo yes
6 ## stdout: yes
7
8 #### debug-completion option
9 set -o debug-completion
10 ## status: 0
11
12 #### debug-completion from command line
13 $SH -o debug-completion
14 ## status: 0
15
16 #### repr
17 x=42
18 repr x
19 echo status=$?
20 repr nonexistent
21 echo status=$?
22 ## STDOUT:
23 x = (value.Str s:42)
24 status=0
25 'nonexistent' is not defined
26 status=1
27 ## END
28
29
30 #### crash dump
31 rm -f $TMP/*.json
32 OSH_CRASH_DUMP_DIR=$TMP $SH -c '
33 g() {
34 local glocal="glocal"
35 echo $(( 1 / 0 ))
36 }
37 f() {
38 local flocal="flocal"
39 shift
40 FOO=bar g
41 }
42 readonly array=(A B C)
43 f "${array[@]}"
44 ' dummy a b c
45 echo status=$?
46 # Just check that we can parse it. TODO: Test properties.
47 python -m json.tool $TMP/*.json > /dev/null
48 echo status=$?
49 ## STDOUT:
50 status=1
51 status=0
52 ## END
53
54 #### crash dump with source
55 # TODO: The failure is not propagated through 'source'. Failure only happens
56 # on 'errexit'.
57 #rm -f $TMP/*.json
58 OSH_CRASH_DUMP_DIR=$TMP $SH -c '
59 set -o errexit
60 source spec/testdata/crash.sh
61 '
62 echo status=$?
63 python -m json.tool $TMP/*.json > /dev/null
64 echo status=$?
65 ## STDOUT:
66 status=1
67 status=0
68 ## END
69
70 # NOTE: strict-arith has one case in arith.test.sh), strict-word-eval has a case in var-op-other.
71