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