add a minimal test framework
This commit is contained in:
parent
b3e3858553
commit
8670dcae7a
3
Makefile
3
Makefile
@ -124,3 +124,6 @@ run: interpopt
|
|||||||
OCAMLINTERP_SRC_PATH=$(OCAMLINTERP_SRC_PATH) \
|
OCAMLINTERP_SRC_PATH=$(OCAMLINTERP_SRC_PATH) \
|
||||||
OCAMLINTERP_STDLIB_PATH=$(OCAMLINTERP_STDLIB_PATH) \
|
OCAMLINTERP_STDLIB_PATH=$(OCAMLINTERP_STDLIB_PATH) \
|
||||||
./interpopt $(RUNARGS)
|
./interpopt $(RUNARGS)
|
||||||
|
|
||||||
|
test: interpopt
|
||||||
|
cd tests && sh runtests.sh
|
||||||
|
15
tests/README
Normal file
15
tests/README
Normal 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
18
tests/checktests.sh
Normal 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
19
tests/runtests.sh
Normal 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
|
Loading…
x
Reference in New Issue
Block a user