* test/lisp/vc/diff-mode-tests.el: Require diff-mode.
[emacs.git] / test / lisp / vc / diff-mode-tests.el
blob807a411fa5d056259e6cabd5dbadc19d1ad74efd
1 ;; Copyright (C) 2017 Free Software Foundation, Inc
3 ;; Author: Dima Kogan <dima@secretsauce.net>
4 ;; Maintainer: emacs-devel@gnu.org
6 ;; This file is part of GNU Emacs.
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.
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.
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/>.
21 ;;; Code:
23 (require 'diff-mode)
26 (ert-deftest diff-mode-test-ignore-trailing-dashes ()
27 "Check to make sure we successfully ignore trailing -- made by
28 'git format-patch'. This is bug #9597"
30 ;; I made a test repo, put some files in it, made arbitrary changes
31 ;; and invoked 'git format-patch' to get a patch out of it. The
32 ;; patch and the before and after versions of the files appear here.
33 ;; The test simply tries to apply the patch. The patch contains
34 ;; trailing --, which confused diff-mode previously
35 (let ((patch "From 18ed35640be496647e0a02fc155b4ee4a0490eca Mon Sep 17 00:00:00 2001
36 From: Dima Kogan <dima@secretsauce.net>
37 Date: Mon, 30 Jan 2017 22:24:13 -0800
38 Subject: [PATCH] test commit
40 ---
41 fil | 3 ---
42 fil2 | 4 ----
43 2 files changed, 7 deletions(-)
45 diff --git a/fil b/fil
46 index 10344f1..2a56245 100644
47 --- a/fil
48 +++ b/fil
49 @@ -2,10 +2,8 @@ Afrocentrism
50 Americanisms
51 Americanization
52 Americanizations
53 -Americanized
54 Americanizes
55 Americanizing
56 -Andrianampoinimerina
57 Anglicanisms
58 Antananarivo
59 Apalachicola
60 @@ -15,6 +13,5 @@ Aristophanes
61 Aristotelian
62 Ashurbanipal
63 Australopithecus
64 -Austronesian
65 Bangladeshis
66 Barquisimeto
67 diff --git a/fil2 b/fil2
68 index 8858f0d..86e8ea5 100644
69 --- a/fil2
70 +++ b/fil2
71 @@ -1,20 +1,16 @@
72 whippoorwills
73 whitewashing
74 wholehearted
75 -wholeheartedly
76 wholesomeness
77 wildernesses
78 windbreakers
79 wisecracking
80 withstanding
81 -woodcarvings
82 woolgathering
83 workstations
84 worthlessness
85 wretchedness
86 wristwatches
87 -wrongfulness
88 wrongheadedly
89 wrongheadedness
90 -xylophonists
91 youthfulness
92 --
93 2.11.0
96 (fil_before "Afrocentrism
97 Americanisms
98 Americanization
99 Americanizations
100 Americanized
101 Americanizes
102 Americanizing
103 Andrianampoinimerina
104 Anglicanisms
105 Antananarivo
106 Apalachicola
107 Appalachians
108 Argentinians
109 Aristophanes
110 Aristotelian
111 Ashurbanipal
112 Australopithecus
113 Austronesian
114 Bangladeshis
115 Barquisimeto
117 (fil_after "Afrocentrism
118 Americanisms
119 Americanization
120 Americanizations
121 Americanizes
122 Americanizing
123 Anglicanisms
124 Antananarivo
125 Apalachicola
126 Appalachians
127 Argentinians
128 Aristophanes
129 Aristotelian
130 Ashurbanipal
131 Australopithecus
132 Bangladeshis
133 Barquisimeto
135 (fil2_before "whippoorwills
136 whitewashing
137 wholehearted
138 wholeheartedly
139 wholesomeness
140 wildernesses
141 windbreakers
142 wisecracking
143 withstanding
144 woodcarvings
145 woolgathering
146 workstations
147 worthlessness
148 wretchedness
149 wristwatches
150 wrongfulness
151 wrongheadedly
152 wrongheadedness
153 xylophonists
154 youthfulness
156 (fil2_after "whippoorwills
157 whitewashing
158 wholehearted
159 wholesomeness
160 wildernesses
161 windbreakers
162 wisecracking
163 withstanding
164 woolgathering
165 workstations
166 worthlessness
167 wretchedness
168 wristwatches
169 wrongheadedly
170 wrongheadedness
171 youthfulness
173 (temp-dir (make-temp-file "diff-mode-test" 'dir)))
175 (let ((buf (find-file-noselect (format "%s/%s" temp-dir "fil" )))
176 (buf2 (find-file-noselect (format "%s/%s" temp-dir "fil2"))))
177 (unwind-protect
178 (progn
179 (with-current-buffer buf (insert fil_before) (save-buffer))
180 (with-current-buffer buf2 (insert fil2_before) (save-buffer))
182 (with-temp-buffer
183 (cd temp-dir)
184 (insert patch)
185 (beginning-of-buffer)
186 (diff-apply-hunk)
187 (diff-apply-hunk)
188 (diff-apply-hunk))
190 (should (equal (with-current-buffer buf (buffer-string))
191 fil_after))
192 (should (equal (with-current-buffer buf2 (buffer-string))
193 fil2_after)))
195 (ignore-errors
196 (with-current-buffer buf (set-buffer-modified-p nil))
197 (kill-buffer buf)
198 (with-current-buffer buf2 (set-buffer-modified-p nil))
199 (kill-buffer buf2)
200 (delete-directory temp-dir 'recursive))))))
203 (provide 'diff-mode-tests)