Add simple test suite.

This commit is contained in:
Jeff Garzik 2016-07-29 16:24:02 -04:00
parent 4e996af1b1
commit 379dc16c5e
6 changed files with 33 additions and 1 deletions

2
.gitignore vendored
View File

@ -1,6 +1,8 @@
*.o
*.output
*.log
*.trs
Makefile
Makefile.in

View File

@ -10,7 +10,9 @@ pkgconfig_DATA = libsqlpars.pc
# TESTS = test/unitester
# noinst_PROGRAMS = $(TESTS)
EXTRA_DIST=sql.y sql.l
EXTRA_DIST = sql.y sql.l \
test-ok.sh test-fail.sh \
fail1.sql ok1.sql
sql_SOURCES = exec.c sql-parser.h
nodist_sql_SOURCES = sql.c sql.tab.c sql.tab.h sql.lex.h
@ -24,3 +26,5 @@ sql.tab.c sql.tab.h: sql.y Makefile
sql.c sql.lex.h: sql.l Makefile
${LEX} -o $@ $<
TESTS = test-ok.sh test-fail.sh

1
fail1.sql Normal file
View File

@ -0,0 +1 @@
barf

1
ok1.sql Normal file
View File

@ -0,0 +1 @@
SELECT * FROM foo;

12
test-fail.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
for testfn in $srcdir/fail*.sql
do
cat $testfn | ./sql
if [ $? -ne 1 ]
then
echo "Failed on $testfn"
exit 1
fi
done

12
test-ok.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
for testfn in $srcdir/ok*.sql
do
cat $testfn | ./sql
if [ $? -ne 0 ]
then
echo "Failed on $testfn"
exit 1
fi
done