Dune runtest does not seem to work


I want to install and test this code: https://github.com/astahfrom/prettiest.

After downloading the source code, I did 1) dune upgrade, 2) replaced ~cmp by ~compare in one place, 3) removed quick from test/dune because of deprecated: Gen.recursive.

Then, dune runtest did not generate any files or errors. I modified values inside “[%expect {| … |}]”, it did not raise any error either. Here is test/dune:

 (name prettiest_tests)
 (modules sexpr pretty_type)
 (library_flags -linkall)
 (libraries core prettiest)
  (pps ppx_jane)))

 (name runner)
 (modules runner)
 (libraries prettiest_tests ppx_expect.evaluator ppx_inline_test.runner.lib))

 (name runtest)
  (:< runner.exe))
   (run %{<} inline-test-runner prettiest_tests))))

Does anyone know how to make the tests run?

This is a rather old way to make dune run expect tests. I would delete the executable and alias stanzas, and add the following line to the library stanza:


Perhaps (library_flags -linkall) is also no longer necessary, but I’m not sure.

Do you mean changing test/dune to the follows?

 (name prettiest_tests)
 (modules sexpr pretty_type)
 (library_flags -linkall)
 (libraries core prettiest)
  (pps ppx_jane))

Modifying values inside “[%expect {| … |}]” still did not raise any error.

Wow, that’s bizarre. I tried to reproduce and was able to do so. Using dune runtest --display=verbose, I even got proof that the tests were running but they passed for some reason:

Running[2]: (cd _build/default/test && .prettiest_tests.inline-tests/run.exe inline-test-runner prettiest_tests -source-tree-root .. -diff-cmd -)

I’m stumped…

Ah, no, I found it. sexpr.ml calls let () = Ppx_inline_test_lib.Runtime.exit () at the end, which I think it should not do. It was causing the test runner to exit prematurely. Remove that line and the expect tests work fine for me.

Indeed, the shorter version of test/dune combined with removing that runtime.exit line worked.

Thank you.