Skip to content

Commit

Permalink
Keep rules marked promote until-clean with -p
Browse files Browse the repository at this point in the history
Closes #4401

Signed-off-by: Etienne Millon <me@emillon.org>
  • Loading branch information
emillon committed Jul 19, 2022
1 parent b554df8 commit eb55983
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
particular, messages where the excerpt line number started with a blank
character were skipped. (#5981, @rgrinberg)

- Do not ignore rules marked `(promote (until-clean))` when
`--ignore-promoted-rules` (or `-p`) is passed. (#...., #...., fixes #4401,
@emillon)

3.3.1 (19-06-2022)
------------------

Expand Down
20 changes: 16 additions & 4 deletions src/dune_rules/dune_file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2332,15 +2332,27 @@ type t =
; stanzas : Stanzas.t
}

let is_promoted_rule version rule =
let is_promoted_mode = function
| Rule.Mode.Promote { only = None; lifetime; _ } ->
if version >= (3, 4) then
match lifetime with
| Unlimited -> true
| Until_clean -> false
else true
| _ -> false
in
match rule with
| Rule { mode; _ } | Menhir.T { mode; _ } -> is_promoted_mode mode
| _ -> false

let parse sexps ~dir ~file ~project =
let open Memo.O in
let+ stanzas = Stanzas.parse ~file project sexps in
let stanzas =
if !Clflags.ignore_promoted_rules then
List.filter stanzas ~f:(function
| Rule { mode = Rule.Mode.Promote { only = None; _ }; _ }
| Menhir.T { mode = Rule.Mode.Promote { only = None; _ }; _ } -> false
| _ -> true)
let version = Dune_project.dune_version project in
List.filter stanzas ~f:(fun s -> not (is_promoted_rule version s))
else stanzas
in
{ dir; project; stanzas }
Expand Down
9 changes: 9 additions & 0 deletions test/blackbox-tests/test-cases/github4401.t
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,12 @@ are ignored. See #4401.
Error: No rule found for test
-> required by alias runtest in dune:5
[1]

This is correctly ignored if dune-lang is bumped to 3.4.

$ cat > dune-project << EOF
> (lang dune 3.4)
> EOF

$ dune clean
$ dune runtest --ignore-promoted-rules

0 comments on commit eb55983

Please sign in to comment.