ocaml / ocaml/dune

separate running tests with outputs from `dune build @all`

Open
#6,822 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

test
Dominant language
OCaml
Stars
1.9k
Forks
500
Avg merge
15h 21m
Merged PRs (30d)
277

Description

Desired Behavior

Currently when running dune build in a project where there are rules for tests that have an output file:

...
(rule                                                                                                                                                                                        
 (action                                                                                                                                                                                     
  (with-stdout-to                                                                                                                                                                            
   payloads.out                                                                                                                                                                    
   (run ./test.exe))))                                                                                                                                                            
                                                                                                                                                                                             
(rule                                                                                                                                                                                        
 (alias runtest)                                                                                                                                                                             
 (action                                                                                                                                                                                     
  (diff payloads.expected payloads.out)))
...

The first rule is built even when alias runtest is added. It would be good to be able to separate building this rule to only build during dune build @runtest because sometimes these tests are very time-consuming.

Ideally, dune build @all build test executables but do not run the executables.

For the above example, I specified the target in dune build <target.exe> which only builds the executables I want to get the desired behavior.

Example

test/test.ml:

let log = Devkit.Log.from "test" 
log#info "test is running"
Printf.print_endline "..."

test/dune

(executables      
 (libraries devkit)                                                                                                                                                                 
 (names test))

(rule                                                                                                                                                                                        
 (action                                                                                                                                                                                     
  (with-stdout-to                                                                                                                                                                            
   payloads.out                                                                                                                                                                    
   (run ./test.exe))))                                                                                                                                                            
                                                                                                                                                                                             
(rule                                                                                                                                                                                        
 (alias runtest)                                                                                                                                                                             
 (action                                                                                                                                                                                     
  (diff payloads.expected payloads.out)))

current behaviour:

$ dune build @all
[2023-01-04T01:37:01.9572] 001: [test:info] test is running

desired behaviour:

$ dune build @all

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproduction in test/test.ml and test/dune, then run dune build @all and dune build @runtest to confirm the current separation of behavior. Done means @all builds test executables without running output-producing test rules, while @runtest still runs and checks them.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.