Using ppx_expect with ocamlbuild

You can use the -pp flag of ocamlbuild to process files through ppx-jane. This will compile your code normally and drop the tests: ocamlbuild -use-ocamlfind -tag thread -pp 'ppx-jane -inline-test-lib testname' -pkg core_kernel …

In order to run the tests, copy the test runner script and link it with your library using the mod flag to ocamlbuild: ocamlbuild -use-ocamlfind -tag thread -pkg core_kernel -pkg ppx_expect.evaluator -pkg ppx_inline_test.runner.lib -mod test test_runner.native. You can then invoke the tests as follows: ./test_runner.native inline-test-runner testname.

Note that ppx-jane applies all of Jane Streets ppxs. You might be able to build a preprocessor that only includes ppx_expect using the instructions here, but I haven’t tried that.