From: Stefan Kangas Date: Sat, 19 Apr 2025 08:35:59 +0000 (+0200) Subject: ; Fix failing diff-mode tests X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=58f4c47ccf11d4b9cf02692b44ceca21a2e6a357;p=emacs.git ; Fix failing diff-mode tests * test/lisp/vc/diff-mode-resources/git.patch: Delete file, moving its contents to... * test/lisp/vc/diff-mode-tests.el (diff-mode-tests--git-patch): ...this new variable. Git merges kept deleting a trailing whitespace in the patch signature, so let's do this instead. (diff-mode-test-git-patch) (diff-mode-test-git-patch/before-first-hunk) (diff-mode-test-git-patch/signature): Use above new variable. (cherry picked from commit 87d615e26cc565cd49be79d08116354341d1af93) --- diff --git a/test/lisp/vc/diff-mode-resources/git.patch b/test/lisp/vc/diff-mode-resources/git.patch deleted file mode 100644 index 05ec90d105c..00000000000 --- a/test/lisp/vc/diff-mode-resources/git.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 1234567890abcdef1234567890abcdef12345678 Mon Sep 17 00:00:00 2001 -From: Alyssa P. Hacker -Date: Sun, 3 Mar 2025 10:30:00 -0400 -Subject: [PATCH] Subtle bug fixes and slight improvements - -- This is not a removed line -+ This is not an added line - ---- - src/main.py | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -diff --git a/src/main.py b/src/main.py -index 9f6c5fe43e47eab441232e54456c5c2b06297b65..7b3f91a8b4ed923c8f43183276e3ab36fe04f6c9 100644 ---- a/src/main.py -+++ b/src/main.py -@@ -2,25 +2,24 @@ - - def main(): - # Initialize the magic number generator -- magic_number = 42 -- print("Magic number: ", magic_number) - -- # TODO: Fix the infinite loop -- while True: -- print("This loop will never end") -+ magic_number = 73 # After reconsidering, 73 seems more appropriate -+ print("Updated magic number: ", magic_number) - -+ # The infinite loop was probably not the best approach -+ # while True: -+ # print("This loop will never end.") - - # This part of the code handles other important tasks - print("Processing other tasks...") - - # Error handling has been updated for clarity -- if not fixed_it_yet: -- print("ERROR: Still broken!") -+ if not fixed_it_yet: # This should be fine now -+ print("ERROR: No longer an issue.") - - # Exiting the function on a positive note -- print("Goodbye, cruel world!") -+ print("Goodbye, world!") - - if __name__ == "__main__": - main() - --- -2.40.0 diff --git a/test/lisp/vc/diff-mode-tests.el b/test/lisp/vc/diff-mode-tests.el index 5611e9abc79..b82fb3effbe 100644 --- a/test/lisp/vc/diff-mode-tests.el +++ b/test/lisp/vc/diff-mode-tests.el @@ -557,45 +557,96 @@ baz")))) +1 "))))) +(defvar diff-mode-tests--git-patch + "From 1234567890abcdef1234567890abcdef12345678 Mon Sep 17 00:00:00 2001 +From: Alyssa P. Hacker +Date: Sun, 3 Mar 2025 10:30:00 -0400 +Subject: [PATCH] Subtle bug fixes and slight improvements + +- This is not a removed line ++ This is not an added line + +--- + src/main.py | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/src/main.py b/src/main.py +index 9f6c5fe43e47eab441232e54456c5c2b06297b65..7b3f91a8b4ed923c8f43183276e3ab36fe04f6c9 100644 +--- a/src/main.py ++++ b/src/main.py +@@ -2,25 +2,24 @@ + + def main(): + # Initialize the magic number generator +- magic_number = 42 +- print(\"Magic number: \", magic_number) + +- # TODO: Fix the infinite loop +- while True: +- print(\"This loop will never end\") ++ magic_number = 73 # After reconsidering, 73 seems more appropriate ++ print(\"Updated magic number: \", magic_number) + ++ # The infinite loop was probably not the best approach ++ # while True: ++ # print(\"This loop will never end.\") + + # This part of the code handles other important tasks + print(\"Processing other tasks...\") + + # Error handling has been updated for clarity +- if not fixed_it_yet: +- print(\"ERROR: Still broken!\") ++ if not fixed_it_yet: # This should be fine now ++ print(\"ERROR: No longer an issue.\") + + # Exiting the function on a positive note +- print(\"Goodbye, cruel world!\") ++ print(\"Goodbye, world!\") + + if __name__ == \"__main__\": + main() + +--\s +2.40.0 +") + (ert-deftest diff-mode-test-git-patch () - (let ((file (ert-resource-file "git.patch"))) - (with-temp-buffer - (insert-file-contents file) - (diff-mode) - (font-lock-ensure) - (goto-char (point-min)) - (re-search-forward "magic_number = 42") - (should (eq (get-text-property (match-beginning 0) 'face) - 'diff-removed)) - (re-search-forward "magic_number = 73") - (should (eq (get-text-property (match-beginning 0) 'face) - 'diff-added))))) + (with-temp-buffer + (insert diff-mode-tests--git-patch) + (diff-mode) + (font-lock-ensure) + (goto-char (point-min)) + (re-search-forward "magic_number = 42") + (should (eq (get-text-property (match-beginning 0) 'face) + 'diff-removed)) + (re-search-forward "magic_number = 73") + (should (eq (get-text-property (match-beginning 0) 'face) + 'diff-added)))) (ert-deftest diff-mode-test-git-patch/before-first-hunk () - (let ((file (ert-resource-file "git.patch"))) - (with-temp-buffer - (insert-file-contents file) - (diff-mode) - (font-lock-ensure) - (goto-char (point-min)) - (re-search-forward "This is not a removed line") - (should (eq (get-text-property (match-beginning 0) 'face) - 'diff-context)) - (re-search-forward "This is not an added line") - (font-lock-ensure) - (should (eq (get-text-property (match-beginning 0) 'face) - 'diff-context))))) + (with-temp-buffer + (insert diff-mode-tests--git-patch) + (diff-mode) + (font-lock-ensure) + (goto-char (point-min)) + (re-search-forward "This is not a removed line") + (should (eq (get-text-property (match-beginning 0) 'face) + 'diff-context)) + (re-search-forward "This is not an added line") + (font-lock-ensure) + (should (eq (get-text-property (match-beginning 0) 'face) + 'diff-context)))) (ert-deftest diff-mode-test-git-patch/signature () - (let ((file (ert-resource-file "git.patch"))) - (with-temp-buffer - (insert-file-contents file) - (diff-mode) - (font-lock-ensure) - (goto-char (point-max)) - (re-search-backward "^-- $") - (should (eq (get-text-property (match-beginning 0) 'face) - 'diff-context))))) + (with-temp-buffer + (insert diff-mode-tests--git-patch) + (diff-mode) + (font-lock-ensure) + (goto-char (point-max)) + (re-search-backward "^-- $") + (should (eq (get-text-property (match-beginning 0) 'face) + 'diff-context)))) (ert-deftest diff-mode-test-topmost-addition-undo () (let ((patch "diff --git a/fruits b/fruits