Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignoring promotion rules #8512

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/changes/8512.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Respect the `--ignore-promote-rules` flag regardless of the version in the
`dune-project` file (#8512)
19 changes: 7 additions & 12 deletions src/dune_rules/dune_file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2464,19 +2464,16 @@ type t =
}

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

Expand All @@ -2485,9 +2482,7 @@ let parse sexps ~dir ~file ~project =
let+ stanzas = Stanzas.parse ~file ~dir project sexps in
let stanzas =
if !Clflags.ignore_promoted_rules
then (
let version = Dune_project.dune_version project in
List.filter stanzas ~f:(fun s -> not (is_promoted_rule version s)))
then List.filter stanzas ~f:(fun s -> not (is_promoted_rule s))
else stanzas
in
{ dir; project; stanzas }
Expand Down
3 changes: 0 additions & 3 deletions test/blackbox-tests/test-cases/github4401.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ are ignored. See #4401.
> EOF

$ dune runtest --ignore-promoted-rules
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.5.

Expand Down