01-script-$0.sh, 01-script-$@.sh: add test and fix.
This commit is contained in:
parent
f81b526bd0
commit
b2f5004eb6
8
check.sh
8
check.sh
|
@ -4,7 +4,7 @@ fi
|
|||
DIFF=diff
|
||||
SHELL=${SHELL-bin/gash}
|
||||
|
||||
tests="
|
||||
tests='
|
||||
00-exit
|
||||
00-exit-0
|
||||
00-exit-1
|
||||
|
@ -15,6 +15,8 @@ tests="
|
|||
01-script-backslash
|
||||
01-script-backslash-space
|
||||
01-script-backslash-twice
|
||||
01-script-$0
|
||||
01-script-$@
|
||||
|
||||
03-echo
|
||||
03-echo-doublequotes
|
||||
|
@ -56,7 +58,7 @@ tests="
|
|||
|
||||
11-for
|
||||
11-for-split-sequence
|
||||
11-for-subshell
|
||||
11-for-done-subshell
|
||||
|
||||
20-semi
|
||||
20-or
|
||||
|
@ -112,7 +114,7 @@ tests="
|
|||
100-tar-Z
|
||||
100-tar-Z-old
|
||||
100-tar-Z-pipe
|
||||
"
|
||||
'
|
||||
|
||||
broken="
|
||||
"
|
||||
|
|
|
@ -67,6 +67,8 @@
|
|||
(lambda (n)
|
||||
(if (< n (length (%command-line))) (list-ref (%command-line) n)
|
||||
"")))
|
||||
((equal? name "@")
|
||||
(string-join (cdr (%command-line))))
|
||||
((equal? name "#")
|
||||
(number->string (length (%command-line))))
|
||||
(else
|
||||
|
|
|
@ -122,9 +122,11 @@ copyleft.
|
|||
(run ast))
|
||||
(exit (script-status))))
|
||||
((pair? files)
|
||||
(let ((asts (map file-to-ast files)))
|
||||
(if parse? (map pretty-print asts)
|
||||
(for-each run asts))
|
||||
(let* ((script (car files))
|
||||
(ast (file-to-ast script)))
|
||||
(if parse? (pretty-print ast)
|
||||
(parameterize ((%command-line files))
|
||||
(run ast)))
|
||||
(exit (script-status))))
|
||||
(builtin-command-line
|
||||
(let* ((builtin (car builtin-command-line))
|
||||
|
|
18
test.sh
18
test.sh
|
@ -5,21 +5,21 @@ fi
|
|||
DIFF=${DIFF-diff}
|
||||
SHELL=${SHELL-bin/gash}
|
||||
|
||||
t=$1
|
||||
b=test/$(basename $t .sh)
|
||||
t="$1"
|
||||
b=test/$(basename "$t" .sh)
|
||||
set +e
|
||||
timeout 1 $SHELL -e $b.sh > $b.1 2> $b.2
|
||||
timeout 1 $SHELL -e "$b".sh -s --long file0 file1 > "$b".1 2> "$b".2
|
||||
r=$?
|
||||
set -e
|
||||
if [ -f $b.exit ]; then
|
||||
e=$(cat $b.exit)
|
||||
if [ -f "$b".exit ]; then
|
||||
e=$(cat "$b".exit)
|
||||
else
|
||||
e=0
|
||||
fi
|
||||
[ $r = $e ] || exit 1
|
||||
if [ -f $b.stdout ]; then
|
||||
$DIFF -u $b.stdout $b.1
|
||||
if [ -f "$b".stdout ]; then
|
||||
$DIFF -u "$b".stdout $b.1
|
||||
fi
|
||||
if [ -f $b.stderr ]; then
|
||||
$DIFF -u $b.stderr $b.2
|
||||
if [ -f "$b".stderr ]; then
|
||||
$DIFF -u "$b".stderr "$b".2
|
||||
fi
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
echo $0
|
||||
|
|
@ -0,0 +1 @@
|
|||
echo $@
|
|
@ -0,0 +1 @@
|
|||
-s --long file0 file1
|
|
@ -0,0 +1 @@
|
|||
0
|
Loading…
Reference in New Issue