Feature request: flush buffers on interrupt to `dune runtest`
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 1.9k
- Forks
- 500
- Avg merge
- 15h 21m
- Merged PRs (30d)
- 277
Description
Desired Behavior
By default (without the --no-buffer option), dune runtest buffers the output of test processes on disk. When one of the tests completes, its buffered output is written to standard error. If an ongoing test is interrupted (via SIGINT / SIGTERM), its buffered output is not written in this way.
This has been causing us some difficulty in Irmin's CI, where we occasionally get deadlocked jobs that are terminated by the CI. When this happens, it's not clear which of the test-cases got stuck (or even which test binaries are responsible). In these cases, it'd be nice if Dune would flush the output buffers when it's signalled.
For our particular usage, we'd also like Alcotest to dump its own log buffer too (so that we can see not only which test case stalled, but also the logs leading up to the stall). I suspect this just means that Alcotest needs to register its own SIGINT handler (and hopefully the necessary child/parent flush ordering happens for free).
Example
For example, the existing behaviour is:
$ echo ';; print_endline "some output"; Unix.sleep 3' > main.ml
$ echo '(test (name main) (libraries unix))' > dune
$ dune runtest
Done: 6/8 (jobs: 1)^C
$
Ideally, this example would show some output (perhaps followed by a "Dune was interrupted"-esque line to make it 100% clear in any CI logs that the test didn't complete).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the dune runtest entry point and reproduce the issue using the shown main.ml and dune files, interrupting the sleeping test with SIGINT or SIGTERM. Trace how test-process output is buffered and determine how interrupted processes should flush it; done means the example shows some output and clearly indicates that the run was interrupted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- build-system, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100