janestreet / janestreet/ecaml

Expect_test_collector.set being re-run and causing error...

Open
#12 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

forwarded-to-js-devs
Dominant language
OCaml
Stars
286
Forks
13
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the dynlink initialization error with the shown major-mode code and inspect why Expect_test_collector.set is included or called again. Trace the linked modules and initialization path; done means the CMA dynlinks against ecaml without the duplicate initialization error.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.