Skip to content

feat(runtest): allow running (tests) and (inline_tests) - #11980

Closed
Alizter wants to merge 4 commits into
ocaml:mainfrom
Alizter:dune-test-inline
Closed

Alizter wants to merge 4 commits into
ocaml:mainfrom
Alizter:dune-test-inline

Conversation

@Alizter

@Alizter Alizter commented Jul 6, 2025 •

Copy link
Copy Markdown
Collaborator

In this PR we add support for running individual libraries with (inline_tests) and individual (tests) executables.

  • update doc
  • add changelog
  • use lib db to look up inline tests rather than stanzas

If you have a library or test stanza in src/:

(library
 (name foo)
 (modules foo)
 (inline_tests)) ; up to some backend like ppx_expect

(test
 (name bar)
 (modules bar))

you can do:

dune runtest src/foo src/bar

to run them.

Fix #870

@Alizter
Alizter force-pushed the dune-test-inline branch 3 times, most recently from 428ebbb to 98da0e5 Compare July 7, 2025 16:13
@Alizter
Alizter marked this pull request as ready for review July 7, 2025 16:20
Alizter added 4 commits July 7, 2025 18:21
We modify dune runtest to allow for inline tests to be run. Users may
now run

```
dune runtest src/my_lib_with_tests
```

to run tests associated with a library that has `(inline_tests)`.

Signed-off-by: Ali Caglayan <[email protected]>
Signed-off-by: Ali Caglayan <[email protected]>
@Alizter
Alizter force-pushed the dune-test-inline branch from de1d4cd to a59c89a Compare July 7, 2025 16:21
@Alizter
Alizter requested a review from rgrinberg July 7, 2025 16:21
@Alizter
Alizter marked this pull request as draft July 14, 2025 19:57
Comment thread bin/runtest.ml
Dune_file.find_stanzas dune_file Dune_rules.Library.key
>>| List.filter_map ~f:(fun { Library.sub_systems; name = _loc, name; _ } ->
Option.some_if
(Dune_rules.Sub_system_name.Map.mem

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the sub system is a bit too level for functionality like this. I think you should expose what you need from the Dune_rules.Inline_tests module.

@Alizter

Alizter commented Nov 6, 2025

Copy link
Copy Markdown
Collaborator Author

Subsumed by #12689

@Alizter Alizter closed this Nov 6, 2025
@Alizter
Alizter deleted the dune-test-inline branch April 2, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

It should be possible to run tests from a specific module with runtest

2 participants