test(lua): add test driver for Lua binding tests

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2013-11-05 13:11:34 -08:00
parent 0cc475e581
commit ba3faea586
3 changed files with 35 additions and 11 deletions

View file

@ -1,14 +1,3 @@
function check_error(f)
ok, msg = pcall(function ()
f()
end)
if ok then
error("unexpected success...")
else
print("caught expected error: ", msg)
end
end
s = sexpr(1, 2, 3)
print(s)
s = sexpr(1, 2, 3, nil)

24
tests/lua/test.sh Executable file
View file

@ -0,0 +1,24 @@
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: test.sh [leanlua-executable-path]"
exit 1
fi
ulimit -s unlimited
LEANLUA=$1
NUM_ERRORS=0
for f in `ls *.lua`; do
echo "-- testing $f"
if $LEANLUA util.lua $f > $f.produced.out; then
echo "-- worked"
else
echo "ERROR executing $f, produced output is at $f.produced.out"
NUM_ERRORS=$(($NUM_ERRORS+1))
fi
done
if [ $NUM_ERRORS -gt 0 ]; then
echo "-- Number of errors: $NUM_ERRORS"
exit 1
else
echo "-- Passed"
exit 0
fi

11
tests/lua/util.lua Normal file
View file

@ -0,0 +1,11 @@
-- Execute f, and make sure is throws an error
function check_error(f)
ok, msg = pcall(function ()
f()
end)
if ok then
error("unexpected success...")
else
print("caught expected error: ", msg)
end
end