From 83f6e1cc5c79f5c5caac26e2c6f5618b0dc85a44 Mon Sep 17 00:00:00 2001 From: Marek Kubica Date: Mon, 9 Sep 2024 16:34:33 +0200 Subject: [PATCH] test: Repro case for when the patch prefix is not `a/`/`b/` (#10895) Signed-off-by: Marek Kubica --- .../dune_patch/dune_patch_tests.ml | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/expect-tests/dune_patch/dune_patch_tests.ml b/test/expect-tests/dune_patch/dune_patch_tests.ml index fa0c8678c1a..899494585c4 100644 --- a/test/expect-tests/dune_patch/dune_patch_tests.ml +++ b/test/expect-tests/dune_patch/dune_patch_tests.ml @@ -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 = {| @@ -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);