unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#60259: [PATCH] Add some diff-fixup-modifs tests
       [not found] <m1ili3qp74.fsf.ref@yahoo.es>
@ 2022-12-22 18:16 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-12-24  7:27   ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-12-22 18:16 UTC (permalink / raw)
  To: 60259

[-- Attachment #1: Type: text/plain, Size: 124 bytes --]

Tags: patch


I've added some tests for diff-fixup-modifs, the Emacs command that
tries to fix edited Unix diffs.  Thanks.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-some-diff-fixup-modifs-tests.patch --]
[-- Type: text/patch, Size: 2392 bytes --]

From 91dfdcfe5c944d840e05325b38bcf2a3c7f6101c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= <mardani29@yahoo.es>
Date: Thu, 22 Dec 2022 19:10:24 +0100
Subject: [PATCH] Add some diff-fixup-modifs tests

* test/lisp/vc/diff-mode-tests.el (diff-mode-test-fixups-added-lines):
Test that diff-mode fixes patches with added lines correctly.
* test/lisp/vc/diff-mode-tests.el (diff-mode-test-fixups-empty-hunks):
Ditto for patches with empty hunks.
---
 test/lisp/vc/diff-mode-tests.el | 79 +++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)

diff --git a/test/lisp/vc/diff-mode-tests.el b/test/lisp/vc/diff-mode-tests.el
index 19e3dbb42a..b67ccd4fe0 100644
--- a/test/lisp/vc/diff-mode-tests.el
+++ b/test/lisp/vc/diff-mode-tests.el
@@ -478,5 +478,84 @@ test-hunk-file-names
     (should (equal (diff-hunk-file-names)
                    '("/tmp/ange-ftp1351895K.el" "/tmp/ange-ftp13518wvE.el")))))
 
+(ert-deftest diff-mode-test-fixups-added-lines ()
+  "Check that `diff-fixup-modifs' works well with hunks with added lines."
+  (let ((patch "--- file
++++ file
+@@ -0,0 +1,15 @@
++1
++2
++3
++4
+"))
+    (with-temp-buffer
+      (insert patch)
+      (diff-fixup-modifs (point-min) (point-max))
+      (should (equal (buffer-string) "--- file
++++ file
+@@ -0,0 +1,4 @@
++1
++2
++3
++4
+"))))
+  (let ((patch "--- file
++++ file
+@@ -389,5 +398,6 @@
+        while (1)
+                ;
++       # not needed
+        # at all
+        # stop
+"))
+    (with-temp-buffer
+      (insert patch)
+      (diff-fixup-modifs (point-min) (point-max))
+      (should (equal (buffer-string) "--- file
++++ file
+@@ -389,4 +398,5 @@
+        while (1)
+                ;
++       # not needed
+        # at all
+        # stop
+")))))
+
+(ert-deftest diff-mode-test-fixups-empty-hunks ()
+  "Check that `diff-fixup-modifs' works well with empty hunks."
+  (let ((patch "--- file
++++ file
+@@ -1 +1 @@
+-1
+@@ -10 +10 @@
+-1
++1
+--- otherfile
++++ otherfile
+@@ -1 +1 @@
++2
+@@ -10 +10 @@
+-1
++1
+"))
+    (with-temp-buffer
+      (insert patch)
+      (diff-fixup-modifs (point-min) (point-max))
+      (should (equal (buffer-string) "--- file
++++ file
+@@ -1,1 +1,0 @@
+-1
+@@ -10,1 +10,1 @@
+-1
++1
+--- otherfile
++++ otherfile
+@@ -1,0 +1,1 @@
++2
+@@ -10,1 +10,1 @@
+-1
++1
+")))))
+
 (provide 'diff-mode-tests)
 ;;; diff-mode-tests.el ends here
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#60259: [PATCH] Add some diff-fixup-modifs tests
  2022-12-22 18:16 ` bug#60259: [PATCH] Add some diff-fixup-modifs tests Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-12-24  7:27   ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2022-12-24  7:27 UTC (permalink / raw)
  To: Daniel Martín; +Cc: 60259-done

> Date: Thu, 22 Dec 2022 19:16:15 +0100
> From:  Daniel Martín via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> I've added some tests for diff-fixup-modifs, the Emacs command that
> tries to fix edited Unix diffs.  Thanks.

Thanks, installed on the emacs-29 branch, and closing.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-24  7:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <m1ili3qp74.fsf.ref@yahoo.es>
2022-12-22 18:16 ` bug#60259: [PATCH] Add some diff-fixup-modifs tests Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-24  7:27   ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).