8000 change: never ignore promote until-clean under -p by emillon · Pull Request #8721 · ocaml/dune · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

change: never ignore promote until-clean under -p #8721

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

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

Filter by extension

Filter by extension 8000

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/changes/promote-fallback-always.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- If `--ignore-promoted-rules` is set, do not change `(promote (until-clean))`
rules and make affected rules fallback instead of removing them. This was
previously done depending on `(lang dune)`. (#8721, @emillon)
23 changes: 10 additions & 13 deletions src/dune_rules/dune_file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2472,24 +2472,21 @@ type t =
; stanzas : Stanzas.t
}

let is_promoted_rule version rule =
match rule with
| Rule { mode; _ } | Menhir_stanza.T { mode; _ } ->
let until_clean = if version >= (3, 5) then `Keep else `Ignore in
Rule_mode_decoder.is_ignored mode ~until_clean
| _ -> false
let map_stanza_mode ~f = function
| Rule r -> Rule { r with mode = f r.mode }
| Menhir_stanza.T m -> Menhir_stanza.T { m with mode = f m.mode }
| s -> s
;;

let change_stanza =
map_stanza_mode ~f:(fun mode ->
if Rule_mode_decoder.is_ignored mode then Fallback else mode)
;;

let parse sexps ~dir ~file ~project =
let open Memo.O in
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)))
else stanzas
in
let stanzas = List.map stanzas ~f:change_stanza in
{ dir; project; stanzas }
;;

Expand Down
6 changes: 1 addition & 5 deletions src/dune_rules/rule_mode_decoder.ml
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,10 @@ end
let decode = sum mode_decoders
let field = field "mode" decode ~default:Rule.Mode.Standard

let is_ignored (mode : Rule.Mode.t) ~until_clean =
let is_ignored (mode : Rule.Mode.t) =
!Clflags.ignore_promoted_rules
&&
match mode with
| Promote { lifetime = Unlimited; _ } -> true
| Promote { lifetime = Until_clean; _ } ->
(match until_clean with
| `Ignore -> true
| `Keep -> false)
| _ -> false
;;
10 changes: 3 additions & 7 deletions src/dune_rules/rule_mode_decoder.mli
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ end
val decode : Rule.Mode.t Dune_lang.Decoder.t
val field : Rule.Mode.t Dune_lang.Decoder.fields_parser

(** [is_ignored mode ~until_clean] will return if a rule with [mode] should be
ignored whenever [--ignored-promoted-rules] is set.

[until_clean] is used to set if [(promote (until-clean))] is ignored as
considered by this function. Old versions of dune would incorrectly ignore
this, so we need to maintain the old behavior for now. *)
val is_ignored : Rule.Mode.t -> until_clean:[ `Ignore | `Keep ] -> bool
(** [is_ignored mode] will return if a rule with [mode] should be
ignored, considering whether [--ignored-promoted-rules] is set. *)
val is_ignored : Rule.Mode.t -> bool
2 changes: 1 addition & 1 deletion src/dune_rules/super_context.ml
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ let extend_action t ~dir action =

let make_rule t ?mode ?loc ~dir { Action_builder.With_targets.build; targets } =
match mode with
| Some mode when Rule_mode_decoder.is_ignored mode ~until_clean:`Keep -> None
| Some mode when Rule_mode_decoder.is_ignored mode -> None
| _ ->
let build = extend_action t build ~dir in
Some
Expand Down
14 changes: 1 addition & 13 deletions test/blackbox-tests/test-cases/github4401.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
When --ignore-promoted-rules is passed, rules marked `(promote (until-clean))`
are ignored. See #4401.
are not ignored, independently of dune-lang. See #4401.

$ cat > dune-project << EOF
> (lang dune 3.4)
Expand All @@ -18,15 +18,3 @@ 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.

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

$ dune clean
$ dune runtest --ignore-promoted-rules
7 changes: 6 additions & 1 deletion test/blackbox-tests/test-cases/promote/old-tests.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,13 @@ Test for (promote (into ...)) + (enabled_if %{ignoring_promoted_rules}

$ dune clean
$ dune build into+ignoring --ignore-promoted-rules
Error: Multiple rules generated for _build/default/into+ignoring:
- dune:30
- dune:35
[1]
$ ls -1 _build/default/into*
_build/default/into+ignoring
ls: cannot access '_build/default/into*': No such file or directory
[2]

Reproduction case for #3069
---------------------------
Expand Down
0