Arguments for ppx rewriters ("the build system didn't pass -inline-test-lib")
I'm trying to use ppx_inline_test in a project that is being built with solvuu-build. ppx_inline_test has some specific requirements to the build system, which I believe can't be configured in solvuu-build right now, see https://github.com/janestreet/ppx_inline_test#building-and-running-the-tests-outside-of-jane-street
When building with the extension naively, the following error is thrown:
% make _build/test.native :(
ocamlbuild -verbose 0 -use-ocamlfind -plugin-tag "package(solvuu-build)" test.native
ocamlfind ocamlopt -package unix -package ocamlbuild -linkpkg -package solvuu-build myocamlbuild.ml /home/fabian/.opam/4.04.0+flambda/lib/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
.merlin: registering rule to build file
.ocamlinit: registering rule to build file
project.mk: registering rule to build file
rank.install: registering rule to build file
File "lib/mylib.ml", line 1, characters 0-18:
Error: ppx_inline_test: extension is disabled because the tests would be ignored (the build system didn't pass -inline-test-lib)
Failure:
Error while running: ocamlfind ocamldep -package ppx_inline_test -sort lib/mylib.ml.
make: *** [_build/project.mk:4: _build/test.native] Error 2
The README for ppx_inline_test says:
The
ppx_inline_testsyntax extension will reject any test if it wasn't passed a-inline-test-lib libnameflag.
Do you understand this sentence? Where do you pass the mentioned flag?
The argument is passed here: https://github.com/janestreet/jane-street-tests/blob/master/test-inline-tests/with-oasis-method1/_tags
I'm not sure how ocamlbuild translates its tags to command line invocations, but I kind of get what is needed. I think the possible solutions are:
-
Support ocaml's
-ppxoption. This would allow specifying the pre-processor with additional options. We don't use this right now. We instead pass ppx packages the same way as other dependencies to ocamlfind's-packageflag. This is bad and we should actually distinguish between ppx and normal dependencies. This would enable other performance optimizations. -
Support ocamlfind's
-ppxoptflag. This let's you specify options to ppx packages. This would be the quick and dirty solution, but I'm not certain it will work.@copy Can you
cd _buildand then runocamlfind ocamldep -package ppx_inline_test -ppxopt ppx_inline_test,"-inline-test-lib libname" -sort lib/mylib.ml. I'm really not sure about the quotes there.
It works with ppx_inline_test.deprecated-ppx-method:
% ocamlfind ocamldep -verbose -package ppx_inline_test.deprecated-ppx-method -ppxopt 'ppx_inline_test.deprecated-ppx-method,-inline-test-lib mylib' -sort lib/mylib.ml
+ ocamldep.opt -sort -ppx "~/.opam/4.04.0+flambda/lib/ppx_inline_test/./ppx.exe --as-ppx -inline-test-lib mylib" lib/mylib.ml
lib/mylib.ml
This is bad and we should actually distinguish between ppx and normal dependencies. This would enable other performance optimizations.
That sounds like a good idea, indeed.