Jbuilder support for multiple test executables

In porting a project across from oasis based build to jbuilder and I’ve run into an issue with running the tests. Basically I’ve got 2 sets of tests test_dispatch and test_logic both with their own main runners. The jbuilder file below compiles both files but only seems to run the first test executable but not the second one. Is there a way to have both run? I assumed the deps section was the correct place to list them.

(jbuild_version 1)

(executables
 ((libraries (calendar cohttp webmachine re re.str))
  (modules (test_dispatch))
  (names (test_dispatch))))

(executables
 ((libraries (calendar cohttp webmachine re re.str))
  (modules (test_logic))
  (names (test_logic))))

(alias
 ((name   runtest)
  (package webmachine)
  (deps   (test_logic.exe test_dispatch.exe))
  (action (run ${<}))))

I could combine the tests into a single main runner but I’d prefer to keep them separate if possible.

1 Like

Simply add a runtest alias for every runner that you have rather than trying to make them work with 1 alias.

Thanks if I add a second sexp it works

(alias
 ((name runtest)
  (package webmachine)
  (deps (test_logic.exe))
  (action (run ${<}))))

(alias
 ((name runtest)
  (package webmachine)
  (deps (test_dispatch.exe))
  (action (run ${<}))))

It’s perhaps not that clear from the test sections in the jbuilder manual that this configuration is what is required to run multiple tests. Jbuilder doesn’t fail or complain if I have the first configuration when it’s clearly incorrect.

1 Like

${<} expands to only the first listed dependency [0]. You can use ${^} to refer to all dependencies.

[0] https://jbuilder.readthedocs.io/en/latest/jbuild.html#variables-expansion

1 Like