Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use dune's include stanza for generated tests
The current implementation of test generation is quite high friction: - When adding new tests, running tests directly with dune doesn't work, because the dune files must be generated by `make gentest` beforehand. There is `make runtest`, but that always runs all the tests, and does not allow specifying only some tests to run (which, given that our test suite is quite big, is sometimes needed for quick iterations). - The generated dune files are not commited to the repository, which means that it is easy to forget to run `make gentest` when switching branches -- which either causes some tests to silently not run, or errors because some files are missing. This patch solves both issues by integrating the test generation with dune, using the `include` stanza. More precisely: - The test generation script (gentest.ml) is modified to write all the test cases on the standard output as a single file, rather than creating the dune test files by itself. The generated file makes use of the `subdir` stanza to locate the targets appropriately. - There is a new `dune.inc` file that is included by the `dune` file in `tests`, and a `diff` rule that generates the content of that `dune.inc` file using the `gentest.ml` script. This is the way rules generation must work in dune, and it means that the `dune.inc` file must be commited to the repository --- which may not be such a bad thing, see above. The rule generation is added to the `gentest`, `runtest`, `runtest-quick` and `runtest-ci` aliases. The advantage of the new approach is that since the dependency is known to dune (and not only to make), running a command such as `dune build @tests/issues/XXX/runtest-quick` will always regenerate the tests, and also that we won't have to delete `dune` files manually when switching branches, since everything is in the file that gets re-generated. It means that running tests is slightly slower, because it always requires running the `gentest` script --- but that is probably fine, until we have many more tests than currently.
- Loading branch information