Expect_test_collector.set being re-run and causing error...
I get this error initialisation error:
Expect_test_collector.set: already set
after dynlinking this code:
let ()=
let module M = (val Major_mode.define_derived_mode ~parent:Major_mode.Fundamental.major_mode
mode_name
[%here]
~docstring:"Major mode for interacting with my thingy"
~mode_line:"MYMODE"
())
in
let keymap=Major_mode.keymap M.major_mode in
Keymap.define_key keymap (Key_sequence.create_exn "<f5>")
(Command (Command.of_value_exn(Value.intern "grabbit")))
As I'm compiling a cma to be dynlinked against the ecaml library and so not re-initialising any ecaml modules, there must be something about the code above that causes Expect_test_collector.set to be called again. But why should this module be linked in at all? I have no expect tests. If it's linking is unavoidable, is there something that can be done to prevent the above call being made? Thanks.
The call to Expect_test_collector.set is inserted systematically when you use ppx_expect. If you don't have expect test in your file and don't want this code to be inserted, you can remove ppx_expect from the set of preprocessors for this file.
If you use something such as ppx_jane, you can explicitly tell it to not apply ppx_expect by passing the argument -dont-apply expect_test