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

Hi,

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:

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

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

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

2 Likes

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

Thanks!

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.

@rgrinberg, any progress on this front, or issue to subscribe to in dune’s VCS?

I can’t think of one. Feel free to make one and we’ll discuss in the dune meeting if it needs to be prioritized.