Dune: tests and library in same folder (or: specify modules using glob)


I like keeping modules and their tests in separate files, but in the same folder. For example, the module foo.ml would have a corresponding test file test_foo.ml in the same folder.

Is this pattern supported by Dune? Here is what I imagine my dune file would look like:

  (name foo)
  (modules (:standard \ (glob_files "test*.ml"))

  (name test_foo)
  (modules (glob_files "test*.ml))

Unfortunately, glob_files does not seem to be supported in the modules stanza currently.

1 Like

This is not supported but we do plan to add support for this (perhaps for 2.0?). The syntax would look like: (modules (:standard \ test*) however. Note that modules accepts lowercased module names rather than filenames.

1 Like


Does that mean there would be no way to make this work even once globbing is supported?

I think it should still work. You would be able to exclude module names according to a glob pattern. That seems like it should be enough for your use case.

Ok, awesome! :ok_hand: Looking forward to 2.0.