Skip to content

Commit

Permalink
pkg: sandbox format action when using devtool
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Sherratt <[email protected]>
  • Loading branch information
gridbugs committed Oct 14, 2024
1 parent 1becc6e commit 154739e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/dune_rules/format_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ module Ocamlformat = struct
let open Action_builder.With_targets.O in
(* Depend on [extra_deps] so if the ocamlformat config file
changes then ocamlformat will run again. *)
extra_deps dir >>> action
extra_deps dir
>>> action
|> With_targets.map ~f:(Action.Full.add_sandbox Sandbox_config.needs_sandboxing)
;;

let action_when_ocamlformat_isn't_locked ~input kind =
Expand Down
8 changes: 4 additions & 4 deletions test/blackbox-tests/test-cases/pkg/ocamlformat/gh10991.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@ Initial file:
$ cat foo.ml
let () = print_endline "Hello, world"

Formatting failed because the input file was not copied into the sandbox.
$ DUNE_CONFIG__LOCK_DEV_TOOL=enabled dune fmt
Solution for dev-tools.locks/ocamlformat:
- ocamlformat.0.0.1
cat: foo.ml: No such file or directory
File "foo.ml", line 1, characters 0-0:
Error: Files _build/default/foo.ml and _build/default/.formatted/foo.ml
differ.
Promoting _build/default/.formatted/foo.ml to foo.ml.
[1]

After formatting the fake ocamlformat has added a suffix:
No formatting occured because input file wasn't copied to the sandbox.
$ cat foo.ml
let () = print_endline "Hello, world"
(* formatted with fake ocamlformat *)

Update the file:
Expand All @@ -44,7 +45,6 @@ Update the file:
Promoting _build/default/.formatted/foo.ml to foo.ml.
[1]

After formatting a second time, the recent change to the file was ignored:
No formatting occured because input file wasn't copied to the sandbox.
$ cat foo.ml
let () = print_endline "Hello, world"
(* formatted with fake ocamlformat *)

0 comments on commit 154739e

Please sign in to comment.