See issue 7454

  $ cat >parser_raw.mly <<EOF
  > %token EOL
  > %start <unit> prog
  > %%
  > prog:
  >   | EOL { () }
  >   | EOL; prog { () }
  > EOF

  $ cat >dune <<EOF
  > (library
  >  (name foo)
  >  (modules parser_raw other_gen))
  > 
  > (menhir
  >  (modules parser_raw)
  >  (mode promote))
  > 
  > (rule
  >  (targets other_gen.ml)
  >  (mode promote)
  >  (action (with-stdout-to %{targets}
  >          (echo "print_int 42"))))
  > EOF

  $ cat >dune-project <<EOF
  > (lang dune 2.9)
  > (using menhir 2.0)
  > (formatting (enabled_for ocaml))
  > EOF

  $ touch .ocamlformat 

In the above project, two modules have their implementation generated:
- [Other_gen]'s implementation is generated by a rule stanza
- [Parser_raw]'s implementation is generated by menhir stanza

Formatting the codebase should not trigger the generation of missing modules
  $ dune build @fmt

As expected, Dune did not try to generate the missing implem for [Parser_raw]
  $ dune_cmd exists _build/default/parser_raw.ml
  false

As expected, Dune did not try to generate the missing implem for [Other_gen]
  $ dune_cmd exists _build/default/other_gen.ml
  false

  $ dune clean

Now we add [mli] files for the two modules whose implementation is generated:

  $ touch other_gen.mli
  $ touch parser_raw.mli 

We format again. Filter menhir warnings (which vary by version) to keep output stable.
  $ dune build @fmt 2>&1 | grep -v "end-of-stream" | grep -v "never reduced" | grep -v 'File "parser_raw.mly"' | grep -v "in total"
  fake ocamlformat is running: "--intf" "other_gen.mli"
  fake ocamlformat is running: "--intf" "parser_raw.mli"
  File "other_gen.mli", line 1, characters 0-0:
  --- other_gen.mli
  +++ .formatted/other_gen.mli
  @@ -0,0 +1 @@
  +(* fake ocamlformat output *)
  \ No newline at end of file
  File "parser_raw.mli", line 1, characters 0-0:
  --- parser_raw.mli
  +++ .formatted/parser_raw.mli
  @@ -1,13 +1 @@
  -
  -(* The type of tokens. *)
  -
  -type token = 
  -  | EOL
  -
  -(* This exception is raised by the monolithic API functions. *)
  -
  -exception Error
  -
  -(* The monolithic API. *)
  -
  -val prog: (Lexing.lexbuf -> token) -> Lexing.lexbuf -> (unit)
  +(* fake ocamlformat output *)
  \ No newline at end of file
  [1]

FIXME: unexpectedly, Dune generated the missing parser
  $ dune_cmd exists _build/default/parser_raw.ml
  true

As expected, Dune did not try to generate the missing implem for [Other_gen]
  $ dune_cmd exists _build/default/other_gen.ml
  false
