Using ppx_expect with ocamlbuild

Hi, can anyone explain (or point to an example repo) how to use ppx_expect with plain ocamlbuild? The README only contains pointers to other ppx’es, no simple self-explainatory documentation.

Have you tried using the ppx(ppx_expect) tag ? I’m not sure but it seems to be the way to go when using ppxs with ocamlbuild.

Hi, thanks for your answer. Unfortunately, these ppx’es work in a more complex way than (perhaps more) classical ones. The documentation on Github is alas a bit sparse.

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.

Thanks for your help, your suggestions improved the building of tests for my program but not to the extent of ending up with a fully working solution. Every step brings new problems (e.g. conflicts with ppx_deriving) :slight_smile:

But that’s OK, I have other topics to address at the moment and this is not crucial. Once I have a public release of my program, I will perhaps go back to this question. Thanks again.