add a minimal test framework

This commit is contained in:
Gabriel Scherer 2019-08-19 08:59:19 +02:00 committed by Nathanaël Courant
parent b3e3858553
commit 8670dcae7a
4 changed files with 55 additions and 0 deletions

View File

@ -124,3 +124,6 @@ run: interpopt
OCAMLINTERP_SRC_PATH=$(OCAMLINTERP_SRC_PATH) \
OCAMLINTERP_STDLIB_PATH=$(OCAMLINTERP_STDLIB_PATH) \
./interpopt $(RUNARGS)
test: interpopt
cd tests && sh runtests.sh

15
tests/README Normal file
View File

@ -0,0 +1,15 @@
Test cases are written by creating a new directory, containing a list
of files to be interpreted, and a file called `files` that lists those
file, in the order in which they should be interpreted/linked.
runtests.sh runs the tests -- if passed a directory name as argument,
it runs only that test, otherwise it tests everything.
checktests.sh checks that the tests are correct by running them using
the official OCaml implementation rather than the interpreted. If your
test fails this check, the test is quite probably wrong.
There is no explicit support for reporting success/failure of a test;
you should write your tests so that success is doing nothing, and
failure fails visibly -- for example, using `assert` to check for the
expected result or fail loudly.

18
tests/checktests.sh Normal file
View File

@ -0,0 +1,18 @@
function test() {
echo "Checking $1"
cd $1
ocamlc $(cat files) -o check.byte
./check.byte
rm *.cm* check.byte
echo "done with $1."
}
if [ ! -z $1 ]
then
test $1
else
for f in */
do
test $f
done
fi

19
tests/runtests.sh Normal file
View File

@ -0,0 +1,19 @@
function test() {
echo "Testing $1"
cd $1
OCAMLINTERP_DEBUG=0 OCAMLRUNPARAM=b \
OCAMLINTERP_SRC_PATH=../../ocaml-src \
OCAMLINTERP_STDLIB_PATH=$OCAMLINTERP_SRC_PATH/stdlib \
OCAMLINTERP_COMMAND=files ../../interpopt $(cat files)
echo "done with $1."
}
if [ ! -z $1 ]
then
test $1
else
for f in */
do
test $f
done
fi