forked from ocaml/dune
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg: add repro for gh10991 (ocaml#10993)
Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
- Loading branch information
1 parent
9c42f51
commit 4e1ddc6
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
Test that ocamlformat is re-run when a source file changes. | ||
|
||
$ . ./helpers.sh | ||
$ mkrepo | ||
$ make_project_with_dev_tool_lockdir | ||
|
||
Make a fake ocamlformat package that appends a comment to the end of its input. | ||
$ mkpkg ocamlformat <<EOF | ||
> install: [ | ||
> [ "sh" "-c" "echo '#!/bin/sh' > %{bin}%/ocamlformat" ] | ||
> [ "sh" "-c" "echo 'cat \$2' >> %{bin}%/ocamlformat" ] | ||
> [ "sh" "-c" "echo 'echo \$2 | grep .*.ml >/dev/null && echo \"(* formatted with fake ocamlformat *)\"' >> %{bin}%/ocamlformat" ] | ||
> [ "sh" "-c" "chmod a+x %{bin}%/ocamlformat" ] | ||
> ] | ||
> EOF | ||
|
||
Initial file: | ||
$ cat foo.ml | ||
let () = print_endline "Hello, world" | ||
|
||
$ DUNE_CONFIG__LOCK_DEV_TOOL=enabled dune fmt | ||
Solution for dev-tools.locks/ocamlformat: | ||
- ocamlformat.0.0.1 | ||
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: | ||
$ cat foo.ml | ||
let () = print_endline "Hello, world" | ||
(* formatted with fake ocamlformat *) | ||
|
||
Update the file: | ||
$ cat > foo.ml <<EOF | ||
> let () = print_endline "Hello, ocaml!" | ||
> EOF | ||
|
||
$ DUNE_CONFIG__LOCK_DEV_TOOL=enabled dune fmt | ||
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 a second time, the recent change to the file was ignored: | ||
$ cat foo.ml | ||
let () = print_endline "Hello, world" | ||
(* formatted with fake ocamlformat *) |