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