From e63a51723e2cea4760f2b67409653ce246d2f7c2 Mon Sep 17 00:00:00 2001 From: Ambre Austen Suhamy Date: Tue, 3 Sep 2024 12:18:53 +0200 Subject: [PATCH] Repro: patch doesn't like timestamps (#10859) * Repro: patch doesn't like timestamps Signed-off-by: Ambre Austen Suhamy --- .../dune_patch/dune_patch_tests.ml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/expect-tests/dune_patch/dune_patch_tests.ml b/test/expect-tests/dune_patch/dune_patch_tests.ml index 7a3c2633373..ede3cd63150 100644 --- a/test/expect-tests/dune_patch/dune_patch_tests.ml +++ b/test/expect-tests/dune_patch/dune_patch_tests.ml @@ -58,6 +58,18 @@ index ea988f6bd..000000000 |} ;; +(* Use GNU diff 'unified' format instead of 'git diff' *) +let unified = + {| +diff -u a/foo.ml b/foo.ml +--- a/foo.ml 2024-08-29 17:37:53.114980665 +0200 ++++ b/foo.ml 2024-08-29 17:38:00.243088256 +0200 +@@ -1 +1 @@ +-This is wrong ++This is right +|} +;; + (* Testing the patch action *) include struct @@ -147,3 +159,15 @@ let%expect_test "patching a deleted file" = [%expect {| File foo.ml not found |}] ;; + +let%expect_test "Using a patch from 'diff' with a timestamp" = + try + test [ "foo.ml", "This is wrong\n" ] ("foo.patch", unified); + check "foo.ml"; + [%expect.unreachable] + with + | Dune_util.Report_error.Already_reported -> + if String.ends_with ~suffix:"No such file or directory\n" [%expect.output] + then [%expect ""] + else [%expect.unreachable] +;;