dune "build @runtest ... FAILED" in CI
dune runs your tests through the @runtest alias. A failure means an expect/cram test produced output that differs from the recorded expectation, or a test raised an uncaught exception and exited non-zero.
What this error means
dune build @runtest or dune runtest fails, printing a diff between expected and actual output, or a "Fatal error: exception ..." from a failing test.
dune
File "test/test_calc.ml", line 1, characters 0-0:
Fatal error: exception Failure("expected 5, got 6")
FAILED test/test_calc.exe (exit 2)Common causes
A real test assertion failed
The code under test produced a wrong result, so an assertion raised or an expect diff appeared.
A stale recorded expectation
The expected output in a cram/expect test drifted from intended behavior and needs promoting.
How to fix it
Read the diff or exception and fix the code
- Read the printed diff or "Fatal error: exception ..." line.
- Fix the code so the actual output matches the expectation.
- Re-run
dune runtestto confirm it passes.
Terminal
dune runtest --forcePromote intended output changes
When the new output is correct, promote it so the recorded expectation matches, then commit the change.
Terminal
dune runtest
dune promoteHow to prevent it
- Run
dune runtestlocally before pushing. - Promote expect/cram changes deliberately, reviewing the diff.
- Keep tests deterministic so CI matches local output.
Related guides
dune "Error: I don't know how to build X" in CIFix dune "Error: I don't know how to build X" in CI - the target you passed to dune does not correspond to an…
dune menhir / ocamllex generation error in CIFix menhir/ocamllex generation failures under dune in CI - a grammar conflict or lexer error stops code gener…
OCaml C stubs "cannot find -lX" / missing header in CIFix OCaml C-stub link failures in CI - "cannot find -lX" or "fatal error: X.h: No such file or directory" bec…