ocaml / dune

A composable build system for OCaml.
https://dune.build/
MIT License
1.6k stars 395 forks source link

Silently ignores tests, when inline_tests is not specified (ppx_custom_printf) #2168

Open ksromanov opened 5 years ago

ksromanov commented 5 years ago

I am not sure if it is really possible to fix, or it is one of the design constrains. Please fill free to close with Will-Not-Fix.

While exploring ppx_custom_printf rewriter, I found that dune build @runtest command does almost nothing for this package (checked with strace). However, tests are written. Quite soon, it revealed that test/dune file missed mandatory inline_tests stanza. See https://github.com/janestreet/ppx_custom_printf/issues/5

The problem is that tests were silently ignored. So, the developer would think mistakenly that they have passed (after fix they passed indeed).

I don't think that there is a good solution for this problem. But, as a semi-solution dune can warn, if absolutely no tests were executed for runtest target. This definitely will not hurt.

Or, may be, dune can dump the list of executed tests? Painted in emerald green, of course.

ghost commented 5 years ago

There is actually a plan for this :)

ppxlib has an infrastructure for ppx rewriters to output additional information that could be useful to the build system. For instance, if you run ppx-jane -output-metadata /tmp/meta file_with_tests.ml (after installing ppx_jane), you will see that /file/meta contains a field saying that file_with_tests has tests.

Dune could then use this information to warn the user if ml files have tests but they forgot to put the inline_tests field. It could also use it for optimisation purposes.

I have been meaning to wire things up, but never really found the time to do it.