From 854f2f09ed194df20d6d9390259488ae5fdfc83a Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sun, 21 Jun 2015 23:14:38 +0900 Subject: [PATCH] Adding command-line option tests. --- Makefile | 12 ++++------ tests/run/command-line-tests.sh | 33 ++++++++++++++++++++++++++ tests/run/lib/fact.sld | 8 +++++++ tests/run/lib/fib.scm | 4 ++++ tests/run/lib/hello.sld | 11 +++++++++ tests/run/test00-p.args | 2 ++ tests/run/test00-p.res | 1 + tests/run/test01-p-short.args | 1 + tests/run/test01-p-short.res | 1 + tests/run/test02-h.args | 2 ++ tests/run/test02-h.res | 1 + tests/run/test03-q.args | 2 ++ tests/run/test03-q.res | 1 + tests/run/test04-Q.args | 2 ++ tests/run/test04-Q.res | 1 + tests/run/test05-xscheme-r5rs.args | 2 ++ tests/run/test05-xscheme-r5rs.res | 1 + tests/run/test06-xscheme-base.args | 2 ++ tests/run/test06-xscheme-base.res | 1 + tests/run/test07-xchibi.args | 2 ++ tests/run/test07-xchibi.res | 1 + tests/run/test08-xchibi-primitive.args | 2 ++ tests/run/test08-xchibi-primitive.res | 1 + tests/run/test09-m.args | 4 ++++ tests/run/test09-m.res | 1 + tests/run/test10-xscheme-base-m.args | 3 +++ tests/run/test10-xscheme-base-m.res | 1 + tests/run/test11-xscheme-r5rs-m.args | 3 +++ tests/run/test11-xscheme-r5rs-m.res | 1 + tests/run/test12-xchibi-m.args | 3 +++ tests/run/test12-xchibi-m.res | 1 + tests/run/test13-A-m.args | 3 +++ tests/run/test13-A-m.res | 1 + tests/run/test14-R.args | 2 ++ tests/run/test14-R.res | 1 + tests/run/test15-R-args.args | 4 ++++ tests/run/test15-R-args.res | 1 + tests/run/test16-R-r.args | 3 +++ tests/run/test16-R-r.res | 1 + tests/run/test17-R-r-args.args | 5 ++++ tests/run/test17-R-r-args.res | 1 + tests/run/test18-t.args | 3 +++ tests/run/test18-t.err-res | 8 +++++++ tests/run/test18-t.res | 1 + tests/run/test19-l.args | 3 +++ tests/run/test19-l.res | 1 + 46 files changed, 142 insertions(+), 7 deletions(-) create mode 100755 tests/run/command-line-tests.sh create mode 100644 tests/run/lib/fact.sld create mode 100644 tests/run/lib/fib.scm create mode 100644 tests/run/lib/hello.sld create mode 100644 tests/run/test00-p.args create mode 100644 tests/run/test00-p.res create mode 100644 tests/run/test01-p-short.args create mode 100644 tests/run/test01-p-short.res create mode 100644 tests/run/test02-h.args create mode 100644 tests/run/test02-h.res create mode 100644 tests/run/test03-q.args create mode 100644 tests/run/test03-q.res create mode 100644 tests/run/test04-Q.args create mode 100644 tests/run/test04-Q.res create mode 100644 tests/run/test05-xscheme-r5rs.args create mode 100644 tests/run/test05-xscheme-r5rs.res create mode 100644 tests/run/test06-xscheme-base.args create mode 100644 tests/run/test06-xscheme-base.res create mode 100644 tests/run/test07-xchibi.args create mode 100644 tests/run/test07-xchibi.res create mode 100644 tests/run/test08-xchibi-primitive.args create mode 100644 tests/run/test08-xchibi-primitive.res create mode 100644 tests/run/test09-m.args create mode 100644 tests/run/test09-m.res create mode 100644 tests/run/test10-xscheme-base-m.args create mode 100644 tests/run/test10-xscheme-base-m.res create mode 100644 tests/run/test11-xscheme-r5rs-m.args create mode 100644 tests/run/test11-xscheme-r5rs-m.res create mode 100644 tests/run/test12-xchibi-m.args create mode 100644 tests/run/test12-xchibi-m.res create mode 100644 tests/run/test13-A-m.args create mode 100644 tests/run/test13-A-m.res create mode 100644 tests/run/test14-R.args create mode 100644 tests/run/test14-R.res create mode 100644 tests/run/test15-R-args.args create mode 100644 tests/run/test15-R-args.res create mode 100644 tests/run/test16-R-r.args create mode 100644 tests/run/test16-R-r.res create mode 100644 tests/run/test17-R-r-args.args create mode 100644 tests/run/test17-R-r-args.res create mode 100644 tests/run/test18-t.args create mode 100644 tests/run/test18-t.err-res create mode 100644 tests/run/test18-t.res create mode 100644 tests/run/test19-l.args create mode 100644 tests/run/test19-l.res diff --git a/Makefile b/Makefile index 5a8a7f9a..dfee9663 100644 --- a/Makefile +++ b/Makefile @@ -202,18 +202,15 @@ test-memory: chibi-scheme-ulimit$(EXE) test-build: MAKE=$(MAKE) ./tests/build/build-tests.sh +test-run: + ./tests/run/command-line-tests.sh + test-ffi: chibi-scheme$(EXE) $(CHIBI) tests/ffi/ffi-tests.scm test-snow: chibi-scheme$(EXE) $(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) $(CHIBI) -xchibi tests/unicode-tests.scm @@ -239,7 +236,8 @@ bench-gabriel: chibi-scheme$(EXE) # Packaging 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 -$(RM) chibi-scheme$(EXE) chibi-scheme-static$(EXE) chibi-scheme-ulimit$(EXE) \ diff --git a/tests/run/command-line-tests.sh b/tests/run/command-line-tests.sh new file mode 100755 index 00000000..7e853e34 --- /dev/null +++ b/tests/run/command-line-tests.sh @@ -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 diff --git a/tests/run/lib/fact.sld b/tests/run/lib/fact.sld new file mode 100644 index 00000000..60604233 --- /dev/null +++ b/tests/run/lib/fact.sld @@ -0,0 +1,8 @@ +(define-library (fact) + (export fact) + (import (scheme base)) + (begin + (define (fact n) + (if (< n 2) + 1 + (* n (fact (- n 1))))))) diff --git a/tests/run/lib/fib.scm b/tests/run/lib/fib.scm new file mode 100644 index 00000000..271de0e6 --- /dev/null +++ b/tests/run/lib/fib.scm @@ -0,0 +1,4 @@ +(define (fib n) + (if (< n 2) + 1 + (+ (fib (- n 1)) (fib (- n 2))))) diff --git a/tests/run/lib/hello.sld b/tests/run/lib/hello.sld new file mode 100644 index 00000000..9ba023e6 --- /dev/null +++ b/tests/run/lib/hello.sld @@ -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)))) diff --git a/tests/run/test00-p.args b/tests/run/test00-p.args new file mode 100644 index 00000000..074224ee --- /dev/null +++ b/tests/run/test00-p.args @@ -0,0 +1,2 @@ +-p +(map (lambda (x) (* x x)) '(0 1 2 3 4 5)) \ No newline at end of file diff --git a/tests/run/test00-p.res b/tests/run/test00-p.res new file mode 100644 index 00000000..f7fded9b --- /dev/null +++ b/tests/run/test00-p.res @@ -0,0 +1 @@ +(0 1 4 9 16 25) \ No newline at end of file diff --git a/tests/run/test01-p-short.args b/tests/run/test01-p-short.args new file mode 100644 index 00000000..db6c7e19 --- /dev/null +++ b/tests/run/test01-p-short.args @@ -0,0 +1 @@ +-p(map (lambda (x) (* x x)) '(0 1 2 3 4 5)) diff --git a/tests/run/test01-p-short.res b/tests/run/test01-p-short.res new file mode 100644 index 00000000..f7fded9b --- /dev/null +++ b/tests/run/test01-p-short.res @@ -0,0 +1 @@ +(0 1 4 9 16 25) \ No newline at end of file diff --git a/tests/run/test02-h.args b/tests/run/test02-h.args new file mode 100644 index 00000000..331a9344 --- /dev/null +++ b/tests/run/test02-h.args @@ -0,0 +1,2 @@ +-h1M +-p(map (lambda (x) (* x x)) '(0 1 2 3 4 5)) diff --git a/tests/run/test02-h.res b/tests/run/test02-h.res new file mode 100644 index 00000000..f7fded9b --- /dev/null +++ b/tests/run/test02-h.res @@ -0,0 +1 @@ +(0 1 4 9 16 25) \ No newline at end of file diff --git a/tests/run/test03-q.args b/tests/run/test03-q.args new file mode 100644 index 00000000..f26f7591 --- /dev/null +++ b/tests/run/test03-q.args @@ -0,0 +1,2 @@ +-q +-p(map (lambda (x) (* x x)) '(0 1 2 3 4 5)) diff --git a/tests/run/test03-q.res b/tests/run/test03-q.res new file mode 100644 index 00000000..9303479a --- /dev/null +++ b/tests/run/test03-q.res @@ -0,0 +1 @@ +(0 1 4 9 16 25) diff --git a/tests/run/test04-Q.args b/tests/run/test04-Q.args new file mode 100644 index 00000000..7c986fb1 --- /dev/null +++ b/tests/run/test04-Q.args @@ -0,0 +1,2 @@ +-Q +-p(+ 2 2) diff --git a/tests/run/test04-Q.res b/tests/run/test04-Q.res new file mode 100644 index 00000000..bf0d87ab --- /dev/null +++ b/tests/run/test04-Q.res @@ -0,0 +1 @@ +4 \ No newline at end of file diff --git a/tests/run/test05-xscheme-r5rs.args b/tests/run/test05-xscheme-r5rs.args new file mode 100644 index 00000000..0c73ca7a --- /dev/null +++ b/tests/run/test05-xscheme-r5rs.args @@ -0,0 +1,2 @@ +-x(scheme r5rs) +-p(map (lambda (x) (* x x)) '(0 1 2 3 4 5)) diff --git a/tests/run/test05-xscheme-r5rs.res b/tests/run/test05-xscheme-r5rs.res new file mode 100644 index 00000000..f7fded9b --- /dev/null +++ b/tests/run/test05-xscheme-r5rs.res @@ -0,0 +1 @@ +(0 1 4 9 16 25) \ No newline at end of file diff --git a/tests/run/test06-xscheme-base.args b/tests/run/test06-xscheme-base.args new file mode 100644 index 00000000..d9917f8d --- /dev/null +++ b/tests/run/test06-xscheme-base.args @@ -0,0 +1,2 @@ +-xscheme.base +-p(map (lambda (x) (* x x)) '(0 1 2 3 4 5)) diff --git a/tests/run/test06-xscheme-base.res b/tests/run/test06-xscheme-base.res new file mode 100644 index 00000000..f7fded9b --- /dev/null +++ b/tests/run/test06-xscheme-base.res @@ -0,0 +1 @@ +(0 1 4 9 16 25) \ No newline at end of file diff --git a/tests/run/test07-xchibi.args b/tests/run/test07-xchibi.args new file mode 100644 index 00000000..4d04a5c0 --- /dev/null +++ b/tests/run/test07-xchibi.args @@ -0,0 +1,2 @@ +-x(chibi) +-p(map (lambda (x) (* x x)) '(0 1 2 3 4 5)) diff --git a/tests/run/test07-xchibi.res b/tests/run/test07-xchibi.res new file mode 100644 index 00000000..f7fded9b --- /dev/null +++ b/tests/run/test07-xchibi.res @@ -0,0 +1 @@ +(0 1 4 9 16 25) \ No newline at end of file diff --git a/tests/run/test08-xchibi-primitive.args b/tests/run/test08-xchibi-primitive.args new file mode 100644 index 00000000..7f9e955a --- /dev/null +++ b/tests/run/test08-xchibi-primitive.args @@ -0,0 +1,2 @@ +-x(chibi primitive) +-p(+ 2 2) diff --git a/tests/run/test08-xchibi-primitive.res b/tests/run/test08-xchibi-primitive.res new file mode 100644 index 00000000..bf0d87ab --- /dev/null +++ b/tests/run/test08-xchibi-primitive.res @@ -0,0 +1 @@ +4 \ No newline at end of file diff --git a/tests/run/test09-m.args b/tests/run/test09-m.args new file mode 100644 index 00000000..31ca4a00 --- /dev/null +++ b/tests/run/test09-m.args @@ -0,0 +1,4 @@ +-m +srfi.1 +-p +(iota 5) diff --git a/tests/run/test09-m.res b/tests/run/test09-m.res new file mode 100644 index 00000000..89bcd7e5 --- /dev/null +++ b/tests/run/test09-m.res @@ -0,0 +1 @@ +(0 1 2 3 4) \ No newline at end of file diff --git a/tests/run/test10-xscheme-base-m.args b/tests/run/test10-xscheme-base-m.args new file mode 100644 index 00000000..9f503c6b --- /dev/null +++ b/tests/run/test10-xscheme-base-m.args @@ -0,0 +1,3 @@ +-x(scheme base) +-m(srfi 1) +-p(iota 5) diff --git a/tests/run/test10-xscheme-base-m.res b/tests/run/test10-xscheme-base-m.res new file mode 100644 index 00000000..89bcd7e5 --- /dev/null +++ b/tests/run/test10-xscheme-base-m.res @@ -0,0 +1 @@ +(0 1 2 3 4) \ No newline at end of file diff --git a/tests/run/test11-xscheme-r5rs-m.args b/tests/run/test11-xscheme-r5rs-m.args new file mode 100644 index 00000000..452648a9 --- /dev/null +++ b/tests/run/test11-xscheme-r5rs-m.args @@ -0,0 +1,3 @@ +-xscheme.r5rs +-m(srfi 1) +-p(iota 5) diff --git a/tests/run/test11-xscheme-r5rs-m.res b/tests/run/test11-xscheme-r5rs-m.res new file mode 100644 index 00000000..89bcd7e5 --- /dev/null +++ b/tests/run/test11-xscheme-r5rs-m.res @@ -0,0 +1 @@ +(0 1 2 3 4) \ No newline at end of file diff --git a/tests/run/test12-xchibi-m.args b/tests/run/test12-xchibi-m.args new file mode 100644 index 00000000..10a33e3e --- /dev/null +++ b/tests/run/test12-xchibi-m.args @@ -0,0 +1,3 @@ +-xchibi +-m(srfi 1) +-p(iota 5) diff --git a/tests/run/test12-xchibi-m.res b/tests/run/test12-xchibi-m.res new file mode 100644 index 00000000..89bcd7e5 --- /dev/null +++ b/tests/run/test12-xchibi-m.res @@ -0,0 +1 @@ +(0 1 2 3 4) \ No newline at end of file diff --git a/tests/run/test13-A-m.args b/tests/run/test13-A-m.args new file mode 100644 index 00000000..b0dab3ce --- /dev/null +++ b/tests/run/test13-A-m.args @@ -0,0 +1,3 @@ +-Atests/run/lib +-mfact +-p(fact 5) \ No newline at end of file diff --git a/tests/run/test13-A-m.res b/tests/run/test13-A-m.res new file mode 100644 index 00000000..8bc65837 --- /dev/null +++ b/tests/run/test13-A-m.res @@ -0,0 +1 @@ +120 \ No newline at end of file diff --git a/tests/run/test14-R.args b/tests/run/test14-R.args new file mode 100644 index 00000000..52da06b6 --- /dev/null +++ b/tests/run/test14-R.args @@ -0,0 +1,2 @@ +-Atests/run/lib +-Rhello diff --git a/tests/run/test14-R.res b/tests/run/test14-R.res new file mode 100644 index 00000000..5dd01c17 --- /dev/null +++ b/tests/run/test14-R.res @@ -0,0 +1 @@ +Hello, world! \ No newline at end of file diff --git a/tests/run/test15-R-args.args b/tests/run/test15-R-args.args new file mode 100644 index 00000000..208c8c17 --- /dev/null +++ b/tests/run/test15-R-args.args @@ -0,0 +1,4 @@ +-Atests/run/lib +-Rhello +-- +Schemer! \ No newline at end of file diff --git a/tests/run/test15-R-args.res b/tests/run/test15-R-args.res new file mode 100644 index 00000000..880ddf25 --- /dev/null +++ b/tests/run/test15-R-args.res @@ -0,0 +1 @@ +Hello, Schemer! \ No newline at end of file diff --git a/tests/run/test16-R-r.args b/tests/run/test16-R-r.args new file mode 100644 index 00000000..9fcd4e9b --- /dev/null +++ b/tests/run/test16-R-r.args @@ -0,0 +1,3 @@ +-Atests/run/lib +-Rhello +-rbye diff --git a/tests/run/test16-R-r.res b/tests/run/test16-R-r.res new file mode 100644 index 00000000..6b49ab70 --- /dev/null +++ b/tests/run/test16-R-r.res @@ -0,0 +1 @@ +Goodbye, world! \ No newline at end of file diff --git a/tests/run/test17-R-r-args.args b/tests/run/test17-R-r-args.args new file mode 100644 index 00000000..8596a81d --- /dev/null +++ b/tests/run/test17-R-r-args.args @@ -0,0 +1,5 @@ +-Atests/run/lib +-Rhello +-rbye +-- +Schemer! \ No newline at end of file diff --git a/tests/run/test17-R-r-args.res b/tests/run/test17-R-r-args.res new file mode 100644 index 00000000..2256fe2b --- /dev/null +++ b/tests/run/test17-R-r-args.res @@ -0,0 +1 @@ +Goodbye, Schemer! \ No newline at end of file diff --git a/tests/run/test18-t.args b/tests/run/test18-t.args new file mode 100644 index 00000000..b009fcaa --- /dev/null +++ b/tests/run/test18-t.args @@ -0,0 +1,3 @@ +-msrfi.1 +-tsrfi.1.append-reverse +-p(append-reverse (quote(3 2 1)) (quote(4 5))) diff --git a/tests/run/test18-t.err-res b/tests/run/test18-t.err-res new file mode 100644 index 00000000..33a876e3 --- /dev/null +++ b/tests/run/test18-t.err-res @@ -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) diff --git a/tests/run/test18-t.res b/tests/run/test18-t.res new file mode 100644 index 00000000..695e389e --- /dev/null +++ b/tests/run/test18-t.res @@ -0,0 +1 @@ +(1 2 3 4 5) diff --git a/tests/run/test19-l.args b/tests/run/test19-l.args new file mode 100644 index 00000000..752d4ca9 --- /dev/null +++ b/tests/run/test19-l.args @@ -0,0 +1,3 @@ +-Atests/run/lib +-lfib.scm +-p(fib 5) \ No newline at end of file diff --git a/tests/run/test19-l.res b/tests/run/test19-l.res new file mode 100644 index 00000000..301160a9 --- /dev/null +++ b/tests/run/test19-l.res @@ -0,0 +1 @@ +8 \ No newline at end of file