From 07e4354f8a9875ea956a9f643f9e3f362d049c36 Mon Sep 17 00:00:00 2001 From: Marek Kubica Date: Wed, 4 Sep 2024 09:52:13 +0200 Subject: [PATCH] Repro case for when a unified patch has no prefix (#10877) 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 ede3cd63150..494004248ac 100644 --- a/test/expect-tests/dune_patch/dune_patch_tests.ml +++ b/test/expect-tests/dune_patch/dune_patch_tests.ml @@ -70,6 +70,16 @@ diff -u a/foo.ml b/foo.ml |} ;; +let no_prefix = + {| +--- foo.ml 2024-08-29 17:37:53.114980665 +0200 ++++ foo.ml 2024-08-29 17:38:00.243088256 +0200 +@@ -1 +1 @@ +-This is wrong ++This is right +|} +;; + (* Testing the patch action *) include struct @@ -171,3 +181,15 @@ let%expect_test "Using a patch from 'diff' with a timestamp" = then [%expect ""] else [%expect.unreachable] ;; + +let%expect_test "patching a file without prefix" = + test [ "foo.ml", "This is wrong\n" ] ("foo.patch", no_prefix); + check "foo.ml"; + [%expect.unreachable] +[@@expect.uncaught_exn + {| + (Dune_util__Report_error.Already_reported) + Trailing output + --------------- + Command exited with code 1. |}] +;;