diff options
| author | Dima Kogan | 2017-01-30 23:40:54 -0800 |
|---|---|---|
| committer | Dima Kogan | 2017-01-31 07:50:28 -0800 |
| commit | 3506ec2b110b7de75e9e41657d97d04b04b9e6ff (patch) | |
| tree | 1dfbd6d0d04a371659c4747c959a4287085f299e /test | |
| parent | 189df8262e54c486658784801da3e90b29a548df (diff) | |
| download | emacs-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.el | 199 |
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 | ||
| 32 | From: Dima Kogan <dima@secretsauce.net> | ||
| 33 | Date: Mon, 30 Jan 2017 22:24:13 -0800 | ||
| 34 | Subject: [PATCH] test commit | ||
| 35 | |||
| 36 | --- | ||
| 37 | fil | 3 --- | ||
| 38 | fil2 | 4 ---- | ||
| 39 | 2 files changed, 7 deletions(-) | ||
| 40 | |||
| 41 | diff --git a/fil b/fil | ||
| 42 | index 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 | ||
| 63 | diff --git a/fil2 b/fil2 | ||
| 64 | index 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 | -- | ||
| 89 | 2.11.0 | ||
| 90 | |||
| 91 | ") | ||
| 92 | (fil_before "Afrocentrism | ||
| 93 | Americanisms | ||
| 94 | Americanization | ||
| 95 | Americanizations | ||
| 96 | Americanized | ||
| 97 | Americanizes | ||
| 98 | Americanizing | ||
| 99 | Andrianampoinimerina | ||
| 100 | Anglicanisms | ||
| 101 | Antananarivo | ||
| 102 | Apalachicola | ||
| 103 | Appalachians | ||
| 104 | Argentinians | ||
| 105 | Aristophanes | ||
| 106 | Aristotelian | ||
| 107 | Ashurbanipal | ||
| 108 | Australopithecus | ||
| 109 | Austronesian | ||
| 110 | Bangladeshis | ||
| 111 | Barquisimeto | ||
| 112 | ") | ||
| 113 | (fil_after "Afrocentrism | ||
| 114 | Americanisms | ||
| 115 | Americanization | ||
| 116 | Americanizations | ||
| 117 | Americanizes | ||
| 118 | Americanizing | ||
| 119 | Anglicanisms | ||
| 120 | Antananarivo | ||
| 121 | Apalachicola | ||
| 122 | Appalachians | ||
| 123 | Argentinians | ||
| 124 | Aristophanes | ||
| 125 | Aristotelian | ||
| 126 | Ashurbanipal | ||
| 127 | Australopithecus | ||
| 128 | Bangladeshis | ||
| 129 | Barquisimeto | ||
| 130 | ") | ||
| 131 | (fil2_before "whippoorwills | ||
| 132 | whitewashing | ||
| 133 | wholehearted | ||
| 134 | wholeheartedly | ||
| 135 | wholesomeness | ||
| 136 | wildernesses | ||
| 137 | windbreakers | ||
| 138 | wisecracking | ||
| 139 | withstanding | ||
| 140 | woodcarvings | ||
| 141 | woolgathering | ||
| 142 | workstations | ||
| 143 | worthlessness | ||
| 144 | wretchedness | ||
| 145 | wristwatches | ||
| 146 | wrongfulness | ||
| 147 | wrongheadedly | ||
| 148 | wrongheadedness | ||
| 149 | xylophonists | ||
| 150 | youthfulness | ||
| 151 | ") | ||
| 152 | (fil2_after "whippoorwills | ||
| 153 | whitewashing | ||
| 154 | wholehearted | ||
| 155 | wholesomeness | ||
| 156 | wildernesses | ||
| 157 | windbreakers | ||
| 158 | wisecracking | ||
| 159 | withstanding | ||
| 160 | woolgathering | ||
| 161 | workstations | ||
| 162 | worthlessness | ||
| 163 | wretchedness | ||
| 164 | wristwatches | ||
| 165 | wrongheadedly | ||
| 166 | wrongheadedness | ||
| 167 | youthfulness | ||
| 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) | ||