Skip to content

Commit 966c1fb

Browse files
committed
Keep rules marked promote until-clean with -p
Closes ocaml#4401 Signed-off-by: Etienne Millon <me@emillon.org>
1 parent 70962d7 commit 966c1fb

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

CHANGES.md

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
- Fix handling of the `(deps)` field in `(test)` stanzas when there is an
2222
`.expected` file. (#5952, #5951, fixes #5950, @emillon)
2323

24+
- Do not ignore rules marked `(promote (until-clean))` when
25+
`--ignore-promoted-rules` (or `-p`) is passed. (#...., #...., fixes #4401,
26+
@emillon)
27+
2428
3.3.1 (19-06-2022)
2529
------------------
2630

src/dune_rules/dune_file.ml

+16-4
Original file line numberDiff line numberDiff line change
@@ -2332,15 +2332,27 @@ type t =
23322332
; stanzas : Stanzas.t
23332333
}
23342334

2335+
let is_promoted_rule version rule =
2336+
let is_promoted_mode = function
2337+
| Rule.Mode.Promote { only = None; lifetime; _ } ->
2338+
if version >= (3, 4) then
2339+
match lifetime with
2340+
| Unlimited -> true
2341+
| Until_clean -> false
2342+
else true
2343+
| _ -> false
2344+
in
2345+
match rule with
2346+
| Rule { mode; _ } | Menhir.T { mode; _ } -> is_promoted_mode mode
2347+
| _ -> false
2348+
23352349
let parse sexps ~dir ~file ~project =
23362350
let open Memo.O in
23372351
let+ stanzas = Stanzas.parse ~file project sexps in
23382352
let stanzas =
23392353
if !Clflags.ignore_promoted_rules then
2340-
List.filter stanzas ~f:(function
2341-
| Rule { mode = Rule.Mode.Promote { only = None; _ }; _ }
2342-
| Menhir.T { mode = Rule.Mode.Promote { only = None; _ }; _ } -> false
2343-
| _ -> true)
2354+
let version = Dune_project.dune_version project in
2355+
List.filter stanzas ~f:(fun s -> not (is_promoted_rule version s))
23442356
else stanzas
23452357
in
23462358
{ dir; project; stanzas }

test/blackbox-tests/test-cases/github4401.t

+9
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,12 @@ are ignored. See #4401.
2121
Error: No rule found for test
2222
-> required by alias runtest in dune:5
2323
[1]
24+
25+
This is correctly ignored if dune-lang is bumped to 3.4.
26+
27+
$ cat > dune-project << EOF
28+
> (lang dune 3.4)
29+
> EOF
30+
31+
$ dune clean
32+
$ dune runtest --ignore-promoted-rules

0 commit comments

Comments
 (0)