Adding command-line option tests.

This commit is contained in:
Alex Shinn 2015-06-21 23:14:38 +09:00
parent 74cc4372be
commit 854f2f09ed
46 changed files with 142 additions and 7 deletions

View file

@ -202,18 +202,15 @@ test-memory: chibi-scheme-ulimit$(EXE)
test-build: test-build:
MAKE=$(MAKE) ./tests/build/build-tests.sh MAKE=$(MAKE) ./tests/build/build-tests.sh
test-run:
./tests/run/command-line-tests.sh
test-ffi: chibi-scheme$(EXE) test-ffi: chibi-scheme$(EXE)
$(CHIBI) tests/ffi/ffi-tests.scm $(CHIBI) tests/ffi/ffi-tests.scm
test-snow: chibi-scheme$(EXE) test-snow: chibi-scheme$(EXE)
$(CHIBI) tests/snow/snow-tests.scm $(CHIBI) tests/snow/snow-tests.scm
test-numbers: chibi-scheme$(EXE)
$(CHIBI) -xchibi tests/numeric-tests.scm
test-flonums: chibi-scheme$(EXE)
$(CHIBI) -xchibi tests/flonum-tests.scm
test-unicode: chibi-scheme$(EXE) test-unicode: chibi-scheme$(EXE)
$(CHIBI) -xchibi tests/unicode-tests.scm $(CHIBI) -xchibi tests/unicode-tests.scm
@ -239,7 +236,8 @@ bench-gabriel: chibi-scheme$(EXE)
# Packaging # Packaging
clean: clean-libs clean: clean-libs
-$(RM) *.o *.i *.s *.8 tests/basic/*.out tests/basic/*.err -$(RM) *.o *.i *.s *.8 tests/basic/*.out tests/basic/*.err \
tests/run/*.out tests/run/*.err
cleaner: clean cleaner: clean
-$(RM) chibi-scheme$(EXE) chibi-scheme-static$(EXE) chibi-scheme-ulimit$(EXE) \ -$(RM) chibi-scheme$(EXE) chibi-scheme-static$(EXE) chibi-scheme-ulimit$(EXE) \

33
tests/run/command-line-tests.sh Executable file
View file

@ -0,0 +1,33 @@
#!/bin/sh
# Test chibi-scheme command-line options.
# Should be run from a standard build.
TESTDIR=$(dirname $0)
FAILURES=0
i=0
run_chibi() {
LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH DYLD_LIBRARY_PATH=.:$DYLD_LIBRARY_PATH CHIBI_MODULE_PATH=lib ./chibi-scheme "$@"
}
for t in $TESTDIR/*.args; do
IFS=$'\r\n' GLOBIGNORE='*' :; args=($(cat $t))
run_chibi ${args[@]} 2> ${t%.args}.err > ${t%.args}.out
if diff -w -q ${t%.args}.out ${t%.args}.res \
&& ([ ! -e ${t%.args}.err-res ] || \
diff -w -q ${t%.args}.err ${t%.args}.err-res); then
echo "[PASS] $(basename ${t%.args})"
else
echo "[FAIL] $(basename ${t%.args})"
FAILURES=$((FAILURES + 1))
fi
i=$((i+1))
done
if [ $FAILURES = 0 ]; then
echo "command-line-tests: all ${i} tests passed"
else
echo "command-line-tests: ${FAILURES} out of ${i} tests failed"
exit 1
fi

8
tests/run/lib/fact.sld Normal file
View file

@ -0,0 +1,8 @@
(define-library (fact)
(export fact)
(import (scheme base))
(begin
(define (fact n)
(if (< n 2)
1
(* n (fact (- n 1)))))))

4
tests/run/lib/fib.scm Normal file
View file

@ -0,0 +1,4 @@
(define (fib n)
(if (< n 2)
1
(+ (fib (- n 1)) (fib (- n 2)))))

11
tests/run/lib/hello.sld Normal file
View file

@ -0,0 +1,11 @@
(define-library (hello)
(import (scheme base))
(begin
(define (main args)
(write-string "Hello, ")
(write-string (if (pair? (cdr args)) (cadr args) "world!"))
(newline))
(define (bye args)
(write-string "Goodbye, ")
(write-string (if (pair? (cdr args)) (cadr args) "world!"))
(newline))))

2
tests/run/test00-p.args Normal file
View file

@ -0,0 +1,2 @@
-p
(map (lambda (x) (* x x)) '(0 1 2 3 4 5))

1
tests/run/test00-p.res Normal file
View file

@ -0,0 +1 @@
(0 1 4 9 16 25)

View file

@ -0,0 +1 @@
-p(map (lambda (x) (* x x)) '(0 1 2 3 4 5))

View file

@ -0,0 +1 @@
(0 1 4 9 16 25)

2
tests/run/test02-h.args Normal file
View file

@ -0,0 +1,2 @@
-h1M
-p(map (lambda (x) (* x x)) '(0 1 2 3 4 5))

1
tests/run/test02-h.res Normal file
View file

@ -0,0 +1 @@
(0 1 4 9 16 25)

2
tests/run/test03-q.args Normal file
View file

@ -0,0 +1,2 @@
-q
-p(map (lambda (x) (* x x)) '(0 1 2 3 4 5))

1
tests/run/test03-q.res Normal file
View file

@ -0,0 +1 @@
(0 1 4 9 16 25)

2
tests/run/test04-Q.args Normal file
View file

@ -0,0 +1,2 @@
-Q
-p(+ 2 2)

1
tests/run/test04-Q.res Normal file
View file

@ -0,0 +1 @@
4

View file

@ -0,0 +1,2 @@
-x(scheme r5rs)
-p(map (lambda (x) (* x x)) '(0 1 2 3 4 5))

View file

@ -0,0 +1 @@
(0 1 4 9 16 25)

View file

@ -0,0 +1,2 @@
-xscheme.base
-p(map (lambda (x) (* x x)) '(0 1 2 3 4 5))

View file

@ -0,0 +1 @@
(0 1 4 9 16 25)

View file

@ -0,0 +1,2 @@
-x(chibi)
-p(map (lambda (x) (* x x)) '(0 1 2 3 4 5))

View file

@ -0,0 +1 @@
(0 1 4 9 16 25)

View file

@ -0,0 +1,2 @@
-x(chibi primitive)
-p(+ 2 2)

View file

@ -0,0 +1 @@
4

4
tests/run/test09-m.args Normal file
View file

@ -0,0 +1,4 @@
-m
srfi.1
-p
(iota 5)

1
tests/run/test09-m.res Normal file
View file

@ -0,0 +1 @@
(0 1 2 3 4)

View file

@ -0,0 +1,3 @@
-x(scheme base)
-m(srfi 1)
-p(iota 5)

View file

@ -0,0 +1 @@
(0 1 2 3 4)

View file

@ -0,0 +1,3 @@
-xscheme.r5rs
-m(srfi 1)
-p(iota 5)

View file

@ -0,0 +1 @@
(0 1 2 3 4)

View file

@ -0,0 +1,3 @@
-xchibi
-m(srfi 1)
-p(iota 5)

View file

@ -0,0 +1 @@
(0 1 2 3 4)

View file

@ -0,0 +1,3 @@
-Atests/run/lib
-mfact
-p(fact 5)

1
tests/run/test13-A-m.res Normal file
View file

@ -0,0 +1 @@
120

2
tests/run/test14-R.args Normal file
View file

@ -0,0 +1,2 @@
-Atests/run/lib
-Rhello

1
tests/run/test14-R.res Normal file
View file

@ -0,0 +1 @@
Hello, world!

View file

@ -0,0 +1,4 @@
-Atests/run/lib
-Rhello
--
Schemer!

View file

@ -0,0 +1 @@
Hello, Schemer!

View file

@ -0,0 +1,3 @@
-Atests/run/lib
-Rhello
-rbye

1
tests/run/test16-R-r.res Normal file
View file

@ -0,0 +1 @@
Goodbye, world!

View file

@ -0,0 +1,5 @@
-Atests/run/lib
-Rhello
-rbye
--
Schemer!

View file

@ -0,0 +1 @@
Goodbye, Schemer!

3
tests/run/test18-t.args Normal file
View file

@ -0,0 +1,3 @@
-msrfi.1
-tsrfi.1.append-reverse
-p(append-reverse (quote(3 2 1)) (quote(4 5)))

View file

@ -0,0 +1,8 @@
> (append-reverse (3 2 1) (4 5))
| > (append-reverse (2 1) (3 4 5))
| | > (append-reverse (1) (2 3 4 5))
| | | > (append-reverse () (1 2 3 4 5))
| | | (1 2 3 4 5)
| | (1 2 3 4 5)
| (1 2 3 4 5)
(1 2 3 4 5)

1
tests/run/test18-t.res Normal file
View file

@ -0,0 +1 @@
(1 2 3 4 5)

3
tests/run/test19-l.args Normal file
View file

@ -0,0 +1,3 @@
-Atests/run/lib
-lfib.scm
-p(fib 5)

1
tests/run/test19-l.res Normal file
View file

@ -0,0 +1 @@
8