2018-10-31 06:30:14 +00:00
|
|
|
if [ -n "$V" ]; then
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
DIFF=diff
|
2018-12-16 02:29:23 +00:00
|
|
|
SHELL=${SHELL-scripts/gash}
|
2018-10-31 06:30:14 +00:00
|
|
|
|
2018-11-24 11:03:32 +00:00
|
|
|
tests='
|
2018-10-31 06:30:14 +00:00
|
|
|
00-exit
|
2018-11-03 11:53:39 +00:00
|
|
|
00-exit-0
|
|
|
|
00-exit-1
|
2018-11-13 08:02:35 +00:00
|
|
|
00-exit-2
|
2018-12-01 07:42:15 +00:00
|
|
|
00-exit-error
|
|
|
|
00-exit-var
|
2018-11-03 11:53:39 +00:00
|
|
|
|
|
|
|
01-script-newline
|
|
|
|
01-script-semi
|
|
|
|
01-script-backslash
|
2018-11-10 09:16:50 +00:00
|
|
|
01-script-backslash-space
|
|
|
|
01-script-backslash-twice
|
2018-11-24 11:03:32 +00:00
|
|
|
01-script-$0
|
2018-12-01 08:38:09 +00:00
|
|
|
01-script-$#
|
2018-11-24 11:03:32 +00:00
|
|
|
01-script-$@
|
2018-11-25 07:46:10 +00:00
|
|
|
01-script-shift
|
2018-11-03 10:29:34 +00:00
|
|
|
|
2018-10-31 06:30:14 +00:00
|
|
|
03-echo
|
2018-11-04 19:45:40 +00:00
|
|
|
03-echo-doublequotes
|
2018-11-03 10:29:34 +00:00
|
|
|
03-echo-nesting
|
|
|
|
03-echo-escaped-doublequotes
|
|
|
|
03-echo-quoted-doublequotes
|
2018-12-01 07:00:12 +00:00
|
|
|
03-echo-brace
|
2018-11-03 10:29:34 +00:00
|
|
|
|
2018-10-31 06:30:14 +00:00
|
|
|
04-echo-var
|
2018-11-03 10:29:34 +00:00
|
|
|
04-echo-equal
|
2018-12-02 08:42:35 +00:00
|
|
|
04-echo-word-at
|
2018-12-02 08:51:41 +00:00
|
|
|
04-echo-word-at-word
|
2018-11-03 10:29:34 +00:00
|
|
|
|
2018-10-31 06:30:14 +00:00
|
|
|
05-assignment
|
2018-10-31 19:22:13 +00:00
|
|
|
05-assignment-echo
|
2018-11-03 10:29:34 +00:00
|
|
|
05-assignment-empty
|
2018-10-31 19:22:13 +00:00
|
|
|
05-assignment-singlequote
|
|
|
|
05-assignment-double-quote
|
|
|
|
05-assignment-variable-word
|
2018-11-03 10:29:34 +00:00
|
|
|
05-assignment-word-variable
|
|
|
|
05-assignment-doublequoted-doublequotes
|
|
|
|
|
|
|
|
06-compound-word
|
|
|
|
06-command-compound-word
|
|
|
|
|
2018-11-03 09:04:26 +00:00
|
|
|
07-variable-or
|
|
|
|
07-variable-not-or
|
2018-11-10 10:55:13 +00:00
|
|
|
07-variable-or-slash
|
2018-11-18 14:36:04 +00:00
|
|
|
07-variable-or-variable
|
2018-11-24 11:55:57 +00:00
|
|
|
07-variable-or-doublequote
|
2018-11-25 10:53:29 +00:00
|
|
|
07-variable-or-empty
|
2018-11-03 09:04:26 +00:00
|
|
|
|
|
|
|
08-variable-and
|
|
|
|
08-variable-not-and
|
|
|
|
|
2018-10-31 06:30:14 +00:00
|
|
|
10-if
|
2018-11-03 10:29:34 +00:00
|
|
|
10-if-false
|
|
|
|
10-if-word-variable
|
2018-11-10 09:59:08 +00:00
|
|
|
10-if-multiple
|
|
|
|
10-if-else
|
|
|
|
10-else-multiple
|
|
|
|
10-if-elif
|
2018-12-01 08:42:40 +00:00
|
|
|
10-if-test
|
|
|
|
10-if-test-false
|
|
|
|
10-if-bracket
|
|
|
|
10-if-bracket-false
|
2018-11-10 11:07:07 +00:00
|
|
|
10-if-redirect
|
2018-11-10 09:59:08 +00:00
|
|
|
|
2018-11-03 10:29:34 +00:00
|
|
|
11-for
|
|
|
|
11-for-split-sequence
|
2018-11-24 11:03:32 +00:00
|
|
|
11-for-done-subshell
|
2018-11-03 10:29:34 +00:00
|
|
|
|
2018-11-12 09:52:39 +00:00
|
|
|
20-semi
|
|
|
|
20-or
|
|
|
|
20-and
|
2018-10-31 06:30:14 +00:00
|
|
|
20-pipe-exit-0
|
2018-11-03 10:29:34 +00:00
|
|
|
20-pipe-exit-1
|
|
|
|
20-pipe-sed
|
2018-12-01 07:03:04 +00:00
|
|
|
20-exec
|
2018-10-30 22:57:50 +00:00
|
|
|
|
2018-11-03 10:29:34 +00:00
|
|
|
30-substitution
|
2018-12-01 07:19:28 +00:00
|
|
|
30-substitution-word
|
2018-11-03 10:29:34 +00:00
|
|
|
30-substitution-backtick
|
|
|
|
30-substitution-assignment
|
|
|
|
30-for-substitution
|
2018-11-24 19:48:21 +00:00
|
|
|
30-substitution-assignment
|
2018-12-01 09:40:20 +00:00
|
|
|
30-substitution-assignment-at
|
2018-11-24 19:48:21 +00:00
|
|
|
30-substitution-redirect
|
2018-11-03 10:29:34 +00:00
|
|
|
|
|
|
|
40-eval
|
|
|
|
40-eval-echo-variable
|
2018-11-10 09:16:50 +00:00
|
|
|
40-assignment-eval-echo
|
2018-11-03 10:29:34 +00:00
|
|
|
|
2018-11-12 09:52:39 +00:00
|
|
|
41-dot
|
2018-11-24 12:17:21 +00:00
|
|
|
42-sh
|
2018-12-08 06:55:55 +00:00
|
|
|
42-sh-export
|
2018-11-10 09:25:02 +00:00
|
|
|
|
2018-11-03 10:29:34 +00:00
|
|
|
50-iohere
|
2018-11-14 21:49:06 +00:00
|
|
|
50-iohere-builtin
|
2018-11-14 21:41:24 +00:00
|
|
|
50-redirect
|
|
|
|
50-redirect-space
|
|
|
|
50-redirect-in
|
2018-11-24 10:05:46 +00:00
|
|
|
50-redirect-append
|
2018-11-24 20:05:59 +00:00
|
|
|
50-redirect-pipe
|
2018-11-24 20:57:34 +00:00
|
|
|
50-redirect-merge
|
2018-11-30 13:17:46 +00:00
|
|
|
50-redirect-sed
|
2018-12-02 06:15:45 +00:00
|
|
|
50-redirect-in-out
|
2018-11-03 10:29:34 +00:00
|
|
|
|
2018-11-04 19:45:40 +00:00
|
|
|
60-function
|
2018-12-01 08:38:09 +00:00
|
|
|
60-function-at
|
2018-11-04 19:45:40 +00:00
|
|
|
60-subst
|
|
|
|
|
2018-11-10 09:16:50 +00:00
|
|
|
70-hash
|
|
|
|
70-hash-hash
|
|
|
|
70-percent
|
|
|
|
70-percent-percent
|
|
|
|
70-percent-space
|
|
|
|
70-slash
|
|
|
|
70-slash-string
|
|
|
|
70-slash-string-slash
|
2018-11-05 21:37:55 +00:00
|
|
|
|
2018-11-24 10:32:33 +00:00
|
|
|
100-cd
|
|
|
|
100-cd-foo
|
|
|
|
|
2018-12-03 19:59:10 +00:00
|
|
|
100-test
|
2018-11-30 15:36:00 +00:00
|
|
|
100-test-file
|
|
|
|
100-bracket-file
|
|
|
|
|
2018-12-09 03:13:27 +00:00
|
|
|
100-basename-root
|
|
|
|
100-dirname-root
|
|
|
|
100-basename-autoconf
|
|
|
|
100-dirname-autoconf
|
|
|
|
|
2018-11-03 10:29:34 +00:00
|
|
|
100-sed
|
|
|
|
100-sed-once
|
|
|
|
100-sed-global
|
|
|
|
100-sed-case
|
|
|
|
100-sed-group
|
|
|
|
100-sed-group-extended
|
|
|
|
100-sed-twice
|
|
|
|
100-sed-undo
|
|
|
|
100-sed-file
|
2018-12-02 06:35:13 +00:00
|
|
|
100-sed-fooRbar
|
2018-12-09 19:03:27 +00:00
|
|
|
100-sed-pattern-address
|
2018-12-09 19:36:08 +00:00
|
|
|
100-sed-quit
|
2018-12-09 20:51:27 +00:00
|
|
|
100-sed-autoconf-basename
|
2018-11-03 10:29:34 +00:00
|
|
|
|
|
|
|
100-tar
|
|
|
|
100-tar-Z
|
|
|
|
100-tar-Z-old
|
|
|
|
100-tar-Z-pipe
|
2018-12-04 06:03:31 +00:00
|
|
|
100-tar-ro
|
2018-11-30 15:36:00 +00:00
|
|
|
|
2018-12-02 06:15:45 +00:00
|
|
|
100-tr
|
2018-11-24 11:03:32 +00:00
|
|
|
'
|
2018-10-31 06:30:14 +00:00
|
|
|
|
|
|
|
broken="
|
2018-10-30 22:57:50 +00:00
|
|
|
"
|
2018-10-31 06:30:14 +00:00
|
|
|
|
2018-10-30 22:57:50 +00:00
|
|
|
if [ "$(basename $SHELL)" = bash ]; then
|
|
|
|
broken="
|
|
|
|
00-sed
|
2018-10-31 06:30:14 +00:00
|
|
|
"
|
2018-10-30 22:57:50 +00:00
|
|
|
fi
|
2018-10-31 06:30:14 +00:00
|
|
|
|
|
|
|
expect=$(echo $broken | wc -w)
|
|
|
|
pass=0
|
|
|
|
fail=0
|
|
|
|
total=0
|
|
|
|
for t in $tests; do
|
2018-11-12 09:52:39 +00:00
|
|
|
if [ "$PARSE" ]; then
|
2018-12-16 03:30:08 +00:00
|
|
|
scripts/gash -p "tests/$t.sh"
|
2018-11-12 09:52:39 +00:00
|
|
|
else
|
2018-12-16 03:30:08 +00:00
|
|
|
sh test.sh "tests/$t" &> tests/"$t".log
|
2018-11-12 09:52:39 +00:00
|
|
|
fi
|
2018-10-31 06:30:14 +00:00
|
|
|
r=$?
|
|
|
|
total=$((total+1))
|
|
|
|
if [ $r = 0 ]; then
|
|
|
|
echo $t: [OK]
|
|
|
|
pass=$((pass+1))
|
|
|
|
else
|
|
|
|
echo $t: [FAIL]
|
|
|
|
fail=$((fail+1))
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
[ $expect != 0 ] && echo "expect: $expect"
|
|
|
|
[ $fail != 0 ] && echo "failed: $fail"
|
|
|
|
[ $fail -lt $expect ] && echo "solved: $(($expect - $fail))"
|
|
|
|
echo "passed: $pass"
|
|
|
|
echo "total: $total"
|
|
|
|
if [ $fail != 0 -a $fail -gt $expect ]; then
|
|
|
|
echo FAILED: $fail/$total
|
|
|
|
exit 1
|
|
|
|
elif [ $fail != 0 ]; then
|
|
|
|
echo PASS: $pass/$total
|
|
|
|
else
|
|
|
|
echo PASS: $total
|
|
|
|
fi
|