Skip to content

Commit

Permalink
test: Repro case for when the patch prefix is not a//b/ (ocaml#10895
Browse files Browse the repository at this point in the history
)

Signed-off-by: Marek Kubica <marek@tarides.com>
  • Loading branch information
Leonidas-from-XIV authored Sep 9, 2024
1 parent b3bd89f commit 83f6e1c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/expect-tests/dune_patch/dune_patch_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ let no_prefix =
|}
;;

let random_prefix =
{|
diff -u bar/foo.ml baz/foo.ml
--- bar/foo.ml 2024-08-29 17:37:53.114980665 +0200
+++ baz/foo.ml 2024-08-29 17:38:00.243088256 +0200
@@ -1 +1 @@
-This is wrong
+This is right
|}
;;

(* The file is called "foo bar" *)
let spaces =
{|
Expand Down Expand Up @@ -227,6 +238,17 @@ let%expect_test "patching a file without prefix" =
[%expect {| This is right |}]
;;

let%expect_test "patching files with freestyle prefix" =
try
test [ "foo.ml", "This is wrong\n" ] ("foo.patch", random_prefix);
check "foo.ml";
[%expect.unreachable]
with
| Dune_util.Report_error.Already_reported ->
print_endline @@ normalize_error_path [%expect.output];
[%expect {| Error: foo.ml: No such file or directory |}]
;;

let%expect_test "patching files with spaces" =
try
test [ "foo bar", "This is wrong\n" ] ("foo.patch", spaces);
Expand Down

0 comments on commit 83f6e1c

Please sign in to comment.