ExtLib Testing Suite

Getting the source

Checkout both extlib-dev and extlib-test modules from CVS. Currently the directory layout is fixed, so you need the following organization in order to get the tester to compile:

      $root/extlib-dev    (ExtLib source code)
      $root/extlib-test   (Testing suite source code)
    

Building and running

The simple way

Go to extlib-test directory and run make. This will make the tester. You can execute the test by running make run.

If you want to build native code version of the tester, run make opt. You can run it with make run.

More advanced

Since you don't always want to build ExtLib when you're building the test suite, you can build just the tester and link against prebuilt ExtLib. You can do this by using test.mak instead of Makefile. E.g., to build the tester, run make -f test.mak. This assumes that ExtLib has already been built.

Make plays a very small role in all of this. The test executable is actually buit by a small program called mktest.

Adding tests

Tests need to be named according to a specific syntax. Files that match this syntax are scanned from the extlib-test directory and automatically included into the test.

Creating a test

  1. Create a test file. The syntax for the filename is: Test_<xy>_<module_name>_<test_name>.ml. where <xy> is author's initials (e.g., jh); <module_name> is the module that is tested (e.g., ExtString); and <test> is the name for the test (e.g., 001).
  2. Add test functions into your source file. Check correctness using assert. Existing tests serve as good example code.
  3. Add a test entrypoint into your test module. This entrypoint should call all your tests with Util.run_test function. Example: let test () = Util.run_test ~test_name:"jh_BitSet.create" test_create. The entrypoint must be named test and its type must be unit->unit.

Running your test

  1. Drop your .ml file into extlib-test directory.
  2. Run make -f test.mak && make -f test.mak run

Inclusion in the official test suite

  1. Make sure your test makes at least some sense by discussing it first on ExtLib mailing list.
  2. Post to ExtLib mailing list requesting for inclusion or add to CVS if you have write access.

Mktest

The test suite is compiled using a program called mktest. It scans the test directory for tests and builds them. Author and module masks can be given on the command line to control which tests are built into the test executable. Try running ./mktest --help for more info.