test: Add expectations.
* check.sh: New file, from test.sh. * test.sh: Run single test with expectations.
This commit is contained in:
parent
b433052b4a
commit
9d1d2be6a6
|
@ -17,3 +17,6 @@
|
|||
/doc/version.texi
|
||||
/gash/config.scm
|
||||
/pre-inst-env
|
||||
/test/*.1
|
||||
/test/*.2
|
||||
/test/*.log
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
if [ -n "$V" ]; then
|
||||
set -x
|
||||
fi
|
||||
DIFF=diff
|
||||
SHELL=${SHELL-bin/gash}
|
||||
#SHELL=bin/gash
|
||||
|
||||
tests="
|
||||
assign
|
||||
assign2
|
||||
for
|
||||
for-split-sequence
|
||||
find
|
||||
if2
|
||||
iohere
|
||||
list
|
||||
ls
|
||||
nesting
|
||||
pipe
|
||||
substitution
|
||||
00-exit
|
||||
01-exit-0
|
||||
02-exit-1
|
||||
03-echo
|
||||
04-echo-var
|
||||
05-assignment-doublequoted-doublequotes
|
||||
05-assignment
|
||||
06-assignment-echo
|
||||
06-assignment-singlequote
|
||||
07-assignment-double-quote
|
||||
08-assignment-variable-word
|
||||
09-compound-word
|
||||
0a-assign-substitute
|
||||
0b-command-compound-word
|
||||
10-if
|
||||
11-if-false
|
||||
20-pipe-exit-0
|
||||
21-pipe-exit-1
|
||||
22-semi-pipe-exit-0
|
||||
30-assignment-substitution
|
||||
30-eval
|
||||
31-eval-echo-variable
|
||||
32-for-substitute
|
||||
33-string-args
|
||||
35-assignment-eval-echo
|
||||
"
|
||||
|
||||
broken="
|
||||
|
||||
"
|
||||
|
||||
expect=$(echo $broken | wc -w)
|
||||
pass=0
|
||||
fail=0
|
||||
total=0
|
||||
for t in $tests; do
|
||||
sh test.sh "test/$t" &> test/"$t".log
|
||||
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
|
8
makefile
8
makefile
|
@ -11,9 +11,9 @@ bin/tar: bin/tar.in | do-configure
|
|||
do-configure:
|
||||
./configure --prefix=$(prefix)
|
||||
|
||||
all: all-go do-configure
|
||||
all: all-go
|
||||
|
||||
all-go:
|
||||
all-go: | do-configure
|
||||
build-aux/build-guile.sh
|
||||
|
||||
clean:
|
||||
|
@ -26,11 +26,11 @@ check: all check-bash check-gash
|
|||
|
||||
check-bash: all
|
||||
ifneq ($(BASH),)
|
||||
SHELL=$(BASH) ./test.sh
|
||||
SHELL=$(BASH) ./check.sh
|
||||
endif
|
||||
|
||||
check-gash: all
|
||||
SHELL=bin/gash ./test.sh
|
||||
SHELL=bin/gash ./check.sh
|
||||
|
||||
install: all
|
||||
mkdir -p $(DESTDIR)$(bindir)
|
||||
|
|
40
test.sh
40
test.sh
|
@ -1,19 +1,25 @@
|
|||
if [ -n "$BUILD_DEBUG" ]; then
|
||||
set -e
|
||||
if [ -n "$V" ]; then
|
||||
set -x
|
||||
fi
|
||||
#SHELL=${SHELL-bin/gash}
|
||||
SHELL=bin/gash
|
||||
for f in test/*.sh; do
|
||||
echo -n "$f: "
|
||||
b=test/$(basename $f .sh)
|
||||
# $SHELL --geesh -e $f
|
||||
$SHELL -e $f
|
||||
r=$?
|
||||
if [ -f $b.exit ]; then
|
||||
e=$(cat $b.exit)
|
||||
else
|
||||
e=0
|
||||
fi
|
||||
[ $r = $e ] || exit 1
|
||||
echo pass
|
||||
done
|
||||
DIFF=${DIFF-diff}
|
||||
SHELL=${SHELL-bin/gash}
|
||||
|
||||
t=$1
|
||||
b=test/$(basename $t .sh)
|
||||
set +e
|
||||
$SHELL -e $b.sh > $b.1 2> $b.2
|
||||
r=$?
|
||||
set -e
|
||||
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
|
||||
fi
|
||||
if [ -f $b.stderr ]; then
|
||||
$DIFF -u $b.stderr $b.2
|
||||
fi
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
/bin/bash
|
Loading…
Reference in New Issue