aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDima Kogan2017-01-30 23:40:54 -0800
committerDima Kogan2017-01-31 07:50:28 -0800
commit3506ec2b110b7de75e9e41657d97d04b04b9e6ff (patch)
tree1dfbd6d0d04a371659c4747c959a4287085f299e /test
parent189df8262e54c486658784801da3e90b29a548df (diff)
downloademacs-3506ec2b110b7de75e9e41657d97d04b04b9e6ff.tar.gz
emacs-3506ec2b110b7de75e9e41657d97d04b04b9e6ff.zip
New test for diff-mode handling trailing --
test/lisp/vc/diff-mode-tests.el: New test file
Diffstat (limited to 'test')
-rw-r--r--test/lisp/vc/diff-mode-tests.el199
1 files changed, 199 insertions, 0 deletions
diff --git a/test/lisp/vc/diff-mode-tests.el b/test/lisp/vc/diff-mode-tests.el
new file mode 100644
index 00000000000..3887afb59b9
--- /dev/null
+++ b/test/lisp/vc/diff-mode-tests.el
@@ -0,0 +1,199 @@
1;; Copyright (C) 2017 Free Software Foundation, Inc
2
3;; Author: Dima Kogan <dima@secretsauce.net>
4;; Maintainer: emacs-devel@gnu.org
5
6;; This file is part of GNU Emacs.
7
8;; GNU Emacs is free software: you can redistribute it and/or modify
9;; it under the terms of the GNU General Public License as published by
10;; the Free Software Foundation, either version 3 of the License, or
11;; (at your option) any later version.
12
13;; GNU Emacs is distributed in the hope that it will be useful,
14;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;; GNU General Public License for more details.
17
18;; You should have received a copy of the GNU General Public License
19;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
20
21
22(ert-deftest diff-mode-test-ignore-trailing-dashes ()
23 "Check to make sure we successfully ignore trailing -- made by
24'git format-patch'. This is bug #9597"
25
26 ;; I made a test repo, put some files in it, made arbitrary changes
27 ;; and invoked 'git format-patch' to get a patch out of it. The
28 ;; patch and the before and after versions of the files appear here.
29 ;; The test simply tries to apply the patch. The patch contains
30 ;; trailing --, which confused diff-mode previously
31 (let ((patch "From 18ed35640be496647e0a02fc155b4ee4a0490eca Mon Sep 17 00:00:00 2001
32From: Dima Kogan <dima@secretsauce.net>
33Date: Mon, 30 Jan 2017 22:24:13 -0800
34Subject: [PATCH] test commit
35
36---
37 fil | 3 ---
38 fil2 | 4 ----
39 2 files changed, 7 deletions(-)
40
41diff --git a/fil b/fil
42index 10344f1..2a56245 100644
43--- a/fil
44+++ b/fil
45@@ -2,10 +2,8 @@ Afrocentrism
46 Americanisms
47 Americanization
48 Americanizations
49-Americanized
50 Americanizes
51 Americanizing
52-Andrianampoinimerina
53 Anglicanisms
54 Antananarivo
55 Apalachicola
56@@ -15,6 +13,5 @@ Aristophanes
57 Aristotelian
58 Ashurbanipal
59 Australopithecus
60-Austronesian
61 Bangladeshis
62 Barquisimeto
63diff --git a/fil2 b/fil2
64index 8858f0d..86e8ea5 100644
65--- a/fil2
66+++ b/fil2
67@@ -1,20 +1,16 @@
68 whippoorwills
69 whitewashing
70 wholehearted
71-wholeheartedly
72 wholesomeness
73 wildernesses
74 windbreakers
75 wisecracking
76 withstanding
77-woodcarvings
78 woolgathering
79 workstations
80 worthlessness
81 wretchedness
82 wristwatches
83-wrongfulness
84 wrongheadedly
85 wrongheadedness
86-xylophonists
87 youthfulness
88--
892.11.0
90
91")
92 (fil_before "Afrocentrism
93Americanisms
94Americanization
95Americanizations
96Americanized
97Americanizes
98Americanizing
99Andrianampoinimerina
100Anglicanisms
101Antananarivo
102Apalachicola
103Appalachians
104Argentinians
105Aristophanes
106Aristotelian
107Ashurbanipal
108Australopithecus
109Austronesian
110Bangladeshis
111Barquisimeto
112")
113 (fil_after "Afrocentrism
114Americanisms
115Americanization
116Americanizations
117Americanizes
118Americanizing
119Anglicanisms
120Antananarivo
121Apalachicola
122Appalachians
123Argentinians
124Aristophanes
125Aristotelian
126Ashurbanipal
127Australopithecus
128Bangladeshis
129Barquisimeto
130")
131 (fil2_before "whippoorwills
132whitewashing
133wholehearted
134wholeheartedly
135wholesomeness
136wildernesses
137windbreakers
138wisecracking
139withstanding
140woodcarvings
141woolgathering
142workstations
143worthlessness
144wretchedness
145wristwatches
146wrongfulness
147wrongheadedly
148wrongheadedness
149xylophonists
150youthfulness
151")
152 (fil2_after "whippoorwills
153whitewashing
154wholehearted
155wholesomeness
156wildernesses
157windbreakers
158wisecracking
159withstanding
160woolgathering
161workstations
162worthlessness
163wretchedness
164wristwatches
165wrongheadedly
166wrongheadedness
167youthfulness
168")
169 (temp-dir (make-temp-file "diff-mode-test" 'dir)))
170
171 (let ((buf (find-file-noselect (format "%s/%s" temp-dir "fil" )))
172 (buf2 (find-file-noselect (format "%s/%s" temp-dir "fil2"))))
173 (unwind-protect
174 (progn
175 (with-current-buffer buf (insert fil_before) (save-buffer))
176 (with-current-buffer buf2 (insert fil2_before) (save-buffer))
177
178 (with-temp-buffer
179 (cd temp-dir)
180 (insert patch)
181 (beginning-of-buffer)
182 (diff-apply-hunk)
183 (diff-apply-hunk)
184 (diff-apply-hunk))
185
186 (should (equal (with-current-buffer buf (buffer-string))
187 fil_after))
188 (should (equal (with-current-buffer buf2 (buffer-string))
189 fil2_after)))
190
191 (ignore-errors
192 (with-current-buffer buf (set-buffer-modified-p nil))
193 (kill-buffer buf)
194 (with-current-buffer buf2 (set-buffer-modified-p nil))
195 (kill-buffer buf2)
196 (delete-directory temp-dir 'recursive))))))
197
198
199(provide 'diff-mode-tests)