diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/auth-source-tests.el | 2 | ||||
| -rw-r--r-- | test/lisp/dired-tests.el | 273 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/cl-generic-tests.el | 24 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/ert-tests.el | 2 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/map-tests.el | 16 | ||||
| -rw-r--r-- | test/lisp/eshell/em-ls-tests.el | 98 | ||||
| -rw-r--r-- | test/lisp/files-tests.el | 27 | ||||
| -rw-r--r-- | test/lisp/ls-lisp-tests.el | 94 | ||||
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 159 | ||||
| -rw-r--r-- | test/lisp/register-tests.el | 43 | ||||
| -rw-r--r-- | test/lisp/subr-tests.el | 25 | ||||
| -rw-r--r-- | test/lisp/vc/ediff-ptch-tests.el | 48 | ||||
| -rw-r--r-- | test/src/buffer-tests.el | 5 | ||||
| -rw-r--r-- | test/src/eval-tests.el | 20 |
14 files changed, 713 insertions, 123 deletions
diff --git a/test/lisp/auth-source-tests.el b/test/lisp/auth-source-tests.el index 2634777c7db..9753029f198 100644 --- a/test/lisp/auth-source-tests.el +++ b/test/lisp/auth-source-tests.el | |||
| @@ -215,7 +215,7 @@ | |||
| 215 | 215 | ||
| 216 | (ert-deftest auth-source-test-remembrances-of-things-past () | 216 | (ert-deftest auth-source-test-remembrances-of-things-past () |
| 217 | (let ((password-cache t) | 217 | (let ((password-cache t) |
| 218 | (password-data (make-vector 7 0))) | 218 | (password-data (copy-hash-table password-data))) |
| 219 | (auth-source-remember '(:host "wedd") '(4 5 6)) | 219 | (auth-source-remember '(:host "wedd") '(4 5 6)) |
| 220 | (should (auth-source-remembered-p '(:host "wedd"))) | 220 | (should (auth-source-remembered-p '(:host "wedd"))) |
| 221 | (should-not (auth-source-remembered-p '(:host "xedd"))) | 221 | (should-not (auth-source-remembered-p '(:host "xedd"))) |
diff --git a/test/lisp/dired-tests.el b/test/lisp/dired-tests.el index 69331457c0e..981afdd929e 100644 --- a/test/lisp/dired-tests.el +++ b/test/lisp/dired-tests.el | |||
| @@ -21,7 +21,6 @@ | |||
| 21 | (require 'ert) | 21 | (require 'ert) |
| 22 | (require 'dired) | 22 | (require 'dired) |
| 23 | (require 'nadvice) | 23 | (require 'nadvice) |
| 24 | (require 'ls-lisp) | ||
| 25 | 24 | ||
| 26 | (ert-deftest dired-autoload () | 25 | (ert-deftest dired-autoload () |
| 27 | "Tests to see whether dired-x has been autoloaded" | 26 | "Tests to see whether dired-x has been autoloaded" |
| @@ -55,10 +54,20 @@ | |||
| 55 | (when (buffer-live-p buf) (kill-buffer buf))) | 54 | (when (buffer-live-p buf) (kill-buffer buf))) |
| 56 | (delete-directory dir 'recursive)))) | 55 | (delete-directory dir 'recursive)))) |
| 57 | 56 | ||
| 57 | (defvar dired-dwim-target) | ||
| 58 | (ert-deftest dired-test-bug25609 () | 58 | (ert-deftest dired-test-bug25609 () |
| 59 | "Test for http://debbugs.gnu.org/25609 ." | 59 | "Test for http://debbugs.gnu.org/25609 ." |
| 60 | (let* ((from (make-temp-file "foo" 'dir)) | 60 | (let* ((from (make-temp-file "foo" 'dir)) |
| 61 | ;; Make sure we have long file-names in 'from' and 'to', not | ||
| 62 | ;; their 8+3 short aliases, because the latter will confuse | ||
| 63 | ;; Dired commands invoked below. | ||
| 64 | (from (if (memq system-type '(ms-dos windows-nt)) | ||
| 65 | (file-truename from) | ||
| 66 | from)) | ||
| 61 | (to (make-temp-file "bar" 'dir)) | 67 | (to (make-temp-file "bar" 'dir)) |
| 68 | (to (if (memq system-type '(ms-dos windows-nt)) | ||
| 69 | (file-truename to) | ||
| 70 | to)) | ||
| 62 | (target (expand-file-name (file-name-nondirectory from) to)) | 71 | (target (expand-file-name (file-name-nondirectory from) to)) |
| 63 | (nested (expand-file-name (file-name-nondirectory from) target)) | 72 | (nested (expand-file-name (file-name-nondirectory from) target)) |
| 64 | (dired-dwim-target t) | 73 | (dired-dwim-target t) |
| @@ -68,20 +77,30 @@ | |||
| 68 | :override | 77 | :override |
| 69 | (lambda (_sym _prompt &rest _args) (setq dired-query t)) | 78 | (lambda (_sym _prompt &rest _args) (setq dired-query t)) |
| 70 | '((name . "advice-dired-query"))) | 79 | '((name . "advice-dired-query"))) |
| 71 | (advice-add 'completing-read ; Just return init. | 80 | (advice-add 'completing-read ; Don't prompt me: just return init. |
| 72 | :override | 81 | :override |
| 73 | (lambda (_prompt _coll &optional _pred _match init _hist _def _inherit _keymap) | 82 | (lambda (_prompt _coll &optional _pred _match init _hist _def _inherit _keymap) |
| 74 | init) | 83 | init) |
| 75 | '((name . "advice-completing-read"))) | 84 | '((name . "advice-completing-read"))) |
| 85 | (delete-other-windows) ; We don't want to display any other dired buffers. | ||
| 76 | (push (dired to) buffers) | 86 | (push (dired to) buffers) |
| 77 | (push (dired-other-window temporary-file-directory) buffers) | 87 | (push (dired-other-window temporary-file-directory) buffers) |
| 78 | (dired-goto-file from) | ||
| 79 | (dired-do-copy) | ||
| 80 | (dired-do-copy); Again. | ||
| 81 | (unwind-protect | 88 | (unwind-protect |
| 82 | (progn | 89 | (let ((ok-fn |
| 83 | (should (file-exists-p target)) | 90 | (lambda () |
| 84 | (should-not (file-exists-p nested))) | 91 | (let ((win-buffers (mapcar #'window-buffer (window-list)))) |
| 92 | (and (memq (car buffers) win-buffers) | ||
| 93 | (memq (cadr buffers) win-buffers)))))) | ||
| 94 | (dired-goto-file from) | ||
| 95 | ;; Right before `dired-do-copy' call, to reproduce the bug conditions, | ||
| 96 | ;; ensure we have windows displaying the two dired buffers. | ||
| 97 | (and (funcall ok-fn) (dired-do-copy)) | ||
| 98 | ;; Call `dired-do-copy' again: this must overwrite `target'; if the bug | ||
| 99 | ;; still exists, then it creates `nested' instead. | ||
| 100 | (when (funcall ok-fn) | ||
| 101 | (dired-do-copy) | ||
| 102 | (should (file-exists-p target)) | ||
| 103 | (should-not (file-exists-p nested)))) | ||
| 85 | (dolist (buf buffers) | 104 | (dolist (buf buffers) |
| 86 | (when (buffer-live-p buf) (kill-buffer buf))) | 105 | (when (buffer-live-p buf) (kill-buffer buf))) |
| 87 | (delete-directory from 'recursive) | 106 | (delete-directory from 'recursive) |
| @@ -89,10 +108,94 @@ | |||
| 89 | (advice-remove 'dired-query "advice-dired-query") | 108 | (advice-remove 'dired-query "advice-dired-query") |
| 90 | (advice-remove 'completing-read "advice-completing-read")))) | 109 | (advice-remove 'completing-read "advice-completing-read")))) |
| 91 | 110 | ||
| 92 | (ert-deftest dired-test-bug27243 () | 111 | ;; (ert-deftest dired-test-bug27243 () |
| 93 | "Test for http://debbugs.gnu.org/27243 ." | 112 | ;; "Test for http://debbugs.gnu.org/27243 ." |
| 113 | ;; (let ((test-dir (make-temp-file "test-dir-" t)) | ||
| 114 | ;; (dired-auto-revert-buffer t) buffers) | ||
| 115 | ;; (with-current-buffer (find-file-noselect test-dir) | ||
| 116 | ;; (make-directory "test-subdir")) | ||
| 117 | ;; (push (dired test-dir) buffers) | ||
| 118 | ;; (unwind-protect | ||
| 119 | ;; (let ((buf (current-buffer)) | ||
| 120 | ;; (pt1 (point)) | ||
| 121 | ;; (test-file (concat (file-name-as-directory "test-subdir") | ||
| 122 | ;; "test-file"))) | ||
| 123 | ;; (write-region "Test" nil test-file nil 'silent nil 'excl) | ||
| 124 | ;; ;; Sanity check: point should now be on the subdirectory. | ||
| 125 | ;; (should (equal (dired-file-name-at-point) | ||
| 126 | ;; (concat (file-name-as-directory test-dir) | ||
| 127 | ;; (file-name-as-directory "test-subdir")))) | ||
| 128 | ;; (push (dired-find-file) buffers) | ||
| 129 | ;; (let ((pt2 (point))) ; Point is on test-file. | ||
| 130 | ;; (switch-to-buffer buf) | ||
| 131 | ;; ;; Sanity check: point should now be back on the subdirectory. | ||
| 132 | ;; (should (eq (point) pt1)) | ||
| 133 | ;; ;; Case 1: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27243#5 | ||
| 134 | ;; (push (dired-find-file) buffers) | ||
| 135 | ;; (should (eq (point) pt2)) | ||
| 136 | ;; ;; Case 2: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27243#28 | ||
| 137 | ;; (push (dired test-dir) buffers) | ||
| 138 | ;; (should (eq (point) pt1)))) | ||
| 139 | ;; (dolist (buf buffers) | ||
| 140 | ;; (when (buffer-live-p buf) (kill-buffer buf))) | ||
| 141 | ;; (delete-directory test-dir t)))) | ||
| 142 | |||
| 143 | (ert-deftest dired-test-bug27243-01 () | ||
| 144 | "Test for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27243#5 ." | ||
| 145 | (let* ((test-dir (file-name-as-directory (make-temp-file "test-dir-" t))) | ||
| 146 | (save-pos (lambda () | ||
| 147 | (with-current-buffer (car (dired-buffers-for-dir test-dir)) | ||
| 148 | (dired-save-positions)))) | ||
| 149 | (dired-auto-revert-buffer t) buffers) | ||
| 150 | ;; On MS-Windows, get rid of 8+3 short names in test-dir, if the | ||
| 151 | ;; corresponding long file names exist, otherwise such names trip | ||
| 152 | ;; dired-buffers-for-dir. | ||
| 153 | (if (eq system-type 'windows-nt) | ||
| 154 | (setq test-dir (file-truename test-dir))) | ||
| 155 | (should-not (dired-buffers-for-dir test-dir)) | ||
| 156 | (with-current-buffer (find-file-noselect test-dir) | ||
| 157 | (make-directory "test-subdir")) | ||
| 158 | (message "Saved pos: %S" (funcall save-pos)) | ||
| 159 | ;; Point must be at end-of-buffer. | ||
| 160 | (with-current-buffer (car (dired-buffers-for-dir test-dir)) | ||
| 161 | (should (eobp))) | ||
| 162 | (push (dired test-dir) buffers) | ||
| 163 | (message "Saved pos: %S" (funcall save-pos)) | ||
| 164 | ;; Previous dired call shouldn't create a new buffer: must visit the one | ||
| 165 | ;; created by `find-file-noselect' above. | ||
| 166 | (should (eq 1 (length (dired-buffers-for-dir test-dir)))) | ||
| 167 | (unwind-protect | ||
| 168 | (let ((buf (current-buffer)) | ||
| 169 | (pt1 (point)) | ||
| 170 | (test-file (concat (file-name-as-directory "test-subdir") | ||
| 171 | "test-file"))) | ||
| 172 | (message "Saved pos: %S" (funcall save-pos)) | ||
| 173 | (write-region "Test" nil test-file nil 'silent nil 'excl) | ||
| 174 | (message "Saved pos: %S" (funcall save-pos)) | ||
| 175 | ;; Sanity check: point should now be on the subdirectory. | ||
| 176 | (should (equal (dired-file-name-at-point) | ||
| 177 | (concat test-dir (file-name-as-directory "test-subdir")))) | ||
| 178 | (message "Saved pos: %S" (funcall save-pos)) | ||
| 179 | (push (dired-find-file) buffers) | ||
| 180 | (let ((pt2 (point))) ; Point is on test-file. | ||
| 181 | (pop-to-buffer-same-window buf) | ||
| 182 | ;; Sanity check: point should now be back on the subdirectory. | ||
| 183 | (should (eq (point) pt1)) | ||
| 184 | (push (dired-find-file) buffers) | ||
| 185 | (should (eq (point) pt2)))) | ||
| 186 | (dolist (buf buffers) | ||
| 187 | (when (buffer-live-p buf) (kill-buffer buf))) | ||
| 188 | (delete-directory test-dir t)))) | ||
| 189 | |||
| 190 | (ert-deftest dired-test-bug27243-02 () | ||
| 191 | "Test for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27243#28 ." | ||
| 94 | (let ((test-dir (make-temp-file "test-dir-" t)) | 192 | (let ((test-dir (make-temp-file "test-dir-" t)) |
| 95 | (dired-auto-revert-buffer t) buffers) | 193 | (dired-auto-revert-buffer t) buffers) |
| 194 | ;; On MS-Windows, get rid of 8+3 short names in test-dir, if the | ||
| 195 | ;; corresponding long file names exist, otherwise such names trip | ||
| 196 | ;; string comparisons below. | ||
| 197 | (if (eq system-type 'windows-nt) | ||
| 198 | (setq test-dir (file-truename test-dir))) | ||
| 96 | (with-current-buffer (find-file-noselect test-dir) | 199 | (with-current-buffer (find-file-noselect test-dir) |
| 97 | (make-directory "test-subdir")) | 200 | (make-directory "test-subdir")) |
| 98 | (push (dired test-dir) buffers) | 201 | (push (dired test-dir) buffers) |
| @@ -111,30 +214,44 @@ | |||
| 111 | (switch-to-buffer buf) | 214 | (switch-to-buffer buf) |
| 112 | ;; Sanity check: point should now be back on the subdirectory. | 215 | ;; Sanity check: point should now be back on the subdirectory. |
| 113 | (should (eq (point) pt1)) | 216 | (should (eq (point) pt1)) |
| 114 | ;; Case 1: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27243#5 | ||
| 115 | (push (dired-find-file) buffers) | ||
| 116 | (should (eq (point) pt2)) | ||
| 117 | ;; Case 2: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27243#28 | ||
| 118 | (push (dired test-dir) buffers) | 217 | (push (dired test-dir) buffers) |
| 119 | (should (eq (point) pt1)))) | 218 | (should (eq (point) pt1)))) |
| 120 | (dolist (buf buffers) | 219 | (dolist (buf buffers) |
| 121 | (when (buffer-live-p buf) (kill-buffer buf))) | 220 | (when (buffer-live-p buf) (kill-buffer buf))) |
| 122 | (delete-directory test-dir t)))) | 221 | (delete-directory test-dir t)))) |
| 123 | 222 | ||
| 124 | (ert-deftest dired-test-bug27693 () | 223 | (ert-deftest dired-test-bug27243-03 () |
| 125 | "Test for http://debbugs.gnu.org/27693 ." | 224 | "Test for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27243#61 ." |
| 126 | (let ((dir (expand-file-name "lisp" source-directory)) | 225 | (let ((test-dir (make-temp-file "test-dir-" t)) |
| 127 | (size "") | 226 | (dired-auto-revert-buffer t) |
| 128 | ls-lisp-use-insert-directory-program buf) | 227 | test-subdir1 test-subdir2 allbufs) |
| 129 | (unwind-protect | 228 | (unwind-protect |
| 130 | (progn | 229 | (progn |
| 131 | (setq buf (dired (list dir "simple.el" "subr.el")) | 230 | (with-current-buffer (find-file-noselect test-dir) |
| 132 | size (number-to-string | 231 | (push (current-buffer) allbufs) |
| 133 | (file-attribute-size | 232 | (make-directory "test-subdir1") |
| 134 | (file-attributes (dired-get-filename))))) | 233 | (make-directory "test-subdir2") |
| 135 | (search-backward-regexp size nil t) | 234 | (let ((test-file1 "test-file1") |
| 136 | (should (looking-back "[[:space:]]" (1- (point))))) | 235 | (test-file2 "test-file2")) |
| 137 | (when (buffer-live-p buf) (kill-buffer buf))))) | 236 | (with-current-buffer (find-file-noselect "test-subdir1") |
| 237 | (push (current-buffer) allbufs) | ||
| 238 | (write-region "Test1" nil test-file1 nil 'silent nil 'excl)) | ||
| 239 | (with-current-buffer (find-file-noselect "test-subdir2") | ||
| 240 | (push (current-buffer) allbufs) | ||
| 241 | (write-region "Test2" nil test-file2 nil 'silent nil 'excl)))) | ||
| 242 | ;; Call find-file with a wild card and test point in each file. | ||
| 243 | (let ((buffers (find-file (concat (file-name-as-directory test-dir) | ||
| 244 | "*") | ||
| 245 | t))) | ||
| 246 | (dolist (buf buffers) | ||
| 247 | (let ((pt (with-current-buffer buf (point)))) | ||
| 248 | (switch-to-buffer (find-file-noselect test-dir)) | ||
| 249 | (find-file (buffer-name buf)) | ||
| 250 | (should (equal (point) pt)))) | ||
| 251 | (append buffers allbufs))) | ||
| 252 | (dolist (buf allbufs) | ||
| 253 | (when (buffer-live-p buf) (kill-buffer buf))) | ||
| 254 | (delete-directory test-dir t)))) | ||
| 138 | 255 | ||
| 139 | (ert-deftest dired-test-bug7131 () | 256 | (ert-deftest dired-test-bug7131 () |
| 140 | "Test for http://debbugs.gnu.org/7131 ." | 257 | "Test for http://debbugs.gnu.org/7131 ." |
| @@ -152,28 +269,94 @@ | |||
| 152 | (should (cdr (dired-get-marked-files)))) | 269 | (should (cdr (dired-get-marked-files)))) |
| 153 | (when (buffer-live-p buf) (kill-buffer buf))))) | 270 | (when (buffer-live-p buf) (kill-buffer buf))))) |
| 154 | 271 | ||
| 155 | (ert-deftest dired-test-bug27762 () | 272 | (ert-deftest dired-test-bug27631 () |
| 156 | "Test for http://debbugs.gnu.org/27762 ." | 273 | "Test for http://debbugs.gnu.org/27631 ." |
| 157 | :expected-result :failed | 274 | ;; For dired using 'ls' emulation we test for this bug in |
| 158 | (let* ((dir source-directory) | 275 | ;; ls-lisp-tests.el and em-ls-tests.el. |
| 276 | (skip-unless (and (not (featurep 'ls-lisp)) | ||
| 277 | (not (featurep 'eshell)))) | ||
| 278 | (let* ((dir (make-temp-file "bug27631" 'dir)) | ||
| 279 | (dir1 (expand-file-name "dir1" dir)) | ||
| 280 | (dir2 (expand-file-name "dir2" dir)) | ||
| 159 | (default-directory dir) | 281 | (default-directory dir) |
| 160 | (files (mapcar (lambda (f) (concat "src/" f)) | 282 | buf) |
| 161 | (directory-files | ||
| 162 | (expand-file-name "src") nil "\\.*\\.c\\'"))) | ||
| 163 | ls-lisp-use-insert-directory-program buf) | ||
| 164 | (unwind-protect | 283 | (unwind-protect |
| 165 | (let ((file1 "src/cygw32.c") | 284 | (progn |
| 166 | (file2 "src/atimer.c")) | 285 | (make-directory dir1) |
| 167 | (setq buf (dired (nconc (list dir) files))) | 286 | (make-directory dir2) |
| 168 | (dired-goto-file (expand-file-name file2 default-directory)) | 287 | (with-temp-file (expand-file-name "a.txt" dir1)) |
| 169 | (should-not (looking-at "^ -")) ; Must be 2 spaces not 3. | 288 | (with-temp-file (expand-file-name "b.txt" dir2)) |
| 170 | (setq files (cons file1 (delete file1 files))) | 289 | (setq buf (dired (expand-file-name "dir*/*.txt" dir))) |
| 171 | (kill-buffer buf) | 290 | (dired-toggle-marks) |
| 172 | (setq buf (dired (nconc (list dir) files))) | 291 | (should (cdr (dired-get-marked-files)))) |
| 173 | (should (looking-at "src")) | 292 | (delete-directory dir 'recursive) |
| 174 | (next-line) ; File names must be aligned. | ||
| 175 | (should (looking-at "src"))) | ||
| 176 | (when (buffer-live-p buf) (kill-buffer buf))))) | 293 | (when (buffer-live-p buf) (kill-buffer buf))))) |
| 177 | 294 | ||
| 295 | (ert-deftest dired-test-bug27899 () | ||
| 296 | "Test for http://debbugs.gnu.org/27899 ." | ||
| 297 | (let* ((dir (expand-file-name "src" source-directory)) | ||
| 298 | (buf (dired (list dir "cygw32.c" "alloc.c" "w32xfns.c" "xdisp.c"))) | ||
| 299 | (orig dired-hide-details-mode)) | ||
| 300 | (dired-goto-file (expand-file-name "cygw32.c")) | ||
| 301 | (forward-line 0) | ||
| 302 | (unwind-protect | ||
| 303 | (progn | ||
| 304 | (let ((inhibit-read-only t)) | ||
| 305 | (dired-align-file (point) (point-max))) | ||
| 306 | (dired-hide-details-mode t) | ||
| 307 | (dired-move-to-filename) | ||
| 308 | (should (eq 2 (current-column)))) | ||
| 309 | (dired-hide-details-mode orig)))) | ||
| 310 | |||
| 311 | (ert-deftest dired-test-bug27968 () | ||
| 312 | "Test for http://debbugs.gnu.org/27968 ." | ||
| 313 | (let* ((top-dir (make-temp-file "top-dir" t)) | ||
| 314 | (subdir (expand-file-name "subdir" top-dir)) | ||
| 315 | (header-len-fn (lambda () | ||
| 316 | (save-excursion | ||
| 317 | (goto-char 1) | ||
| 318 | (forward-line 1) | ||
| 319 | (- (point-at-eol) (point))))) | ||
| 320 | orig-len len diff pos line-nb) | ||
| 321 | (make-directory subdir 'parents) | ||
| 322 | (unwind-protect | ||
| 323 | (with-current-buffer (dired-noselect subdir) | ||
| 324 | (setq orig-len (funcall header-len-fn) | ||
| 325 | pos (point) | ||
| 326 | line-nb (line-number-at-pos)) | ||
| 327 | ;; Bug arises when the header line changes its length; this may | ||
| 328 | ;; happen if the used space has changed: for instance, with the | ||
| 329 | ;; creation of additional files. | ||
| 330 | (make-directory "subdir" t) | ||
| 331 | (dired-revert) | ||
| 332 | ;; Change the header line. | ||
| 333 | (save-excursion | ||
| 334 | (goto-char 1) | ||
| 335 | (forward-line 1) | ||
| 336 | (let ((inhibit-read-only t) | ||
| 337 | (new-header " test-bug27968")) | ||
| 338 | (delete-region (point) (point-at-eol)) | ||
| 339 | (when (= orig-len (length new-header)) | ||
| 340 | ;; Wow lucky guy! I must buy lottery today. | ||
| 341 | (setq new-header (concat new-header " :-)"))) | ||
| 342 | (insert new-header))) | ||
| 343 | (setq len (funcall header-len-fn) | ||
| 344 | diff (- len orig-len)) | ||
| 345 | (should-not (zerop diff)) ; Header length has changed. | ||
| 346 | ;; If diff > 0, then the point moves back. | ||
| 347 | ;; If diff < 0, then the point moves forward. | ||
| 348 | ;; If diff = 0, then the point doesn't move. | ||
| 349 | ;; Sometimes this point movement causes | ||
| 350 | ;; line-nb != (line-number-at-pos pos), so that we get | ||
| 351 | ;; an unexpected file at point if we store buffer points. | ||
| 352 | ;; Note that the line number before/after revert | ||
| 353 | ;; doesn't change. | ||
| 354 | (should (= line-nb | ||
| 355 | (line-number-at-pos) | ||
| 356 | (line-number-at-pos (+ pos diff)))) | ||
| 357 | ;; After revert, the point must be in 'subdir' line. | ||
| 358 | (should (equal "subdir" (dired-get-filename 'local t)))) | ||
| 359 | (delete-directory top-dir t)))) | ||
| 360 | |||
| 178 | (provide 'dired-tests) | 361 | (provide 'dired-tests) |
| 179 | ;; dired-tests.el ends here | 362 | ;; dired-tests.el ends here |
diff --git a/test/lisp/emacs-lisp/cl-generic-tests.el b/test/lisp/emacs-lisp/cl-generic-tests.el index 0768e31f7e6..31f65413c88 100644 --- a/test/lisp/emacs-lisp/cl-generic-tests.el +++ b/test/lisp/emacs-lisp/cl-generic-tests.el | |||
| @@ -219,5 +219,29 @@ | |||
| 219 | (should (equal (cl--generic-1 '(5) nil) '("cinq" (5)))) | 219 | (should (equal (cl--generic-1 '(5) nil) '("cinq" (5)))) |
| 220 | (should (equal (cl--generic-1 '(6) nil) '("six" a)))) | 220 | (should (equal (cl--generic-1 '(6) nil) '("six" a)))) |
| 221 | 221 | ||
| 222 | (cl-defgeneric cl-generic-tests--generic (x)) | ||
| 223 | (cl-defmethod cl-generic-tests--generic ((x string)) | ||
| 224 | (message "%s is a string" x)) | ||
| 225 | (cl-defmethod cl-generic-tests--generic ((x integer)) | ||
| 226 | (message "%s is a number" x)) | ||
| 227 | (cl-defgeneric cl-generic-tests--generic-without-methods (x y)) | ||
| 228 | (defvar cl-generic-tests--this-file | ||
| 229 | (file-truename (or load-file-name buffer-file-name))) | ||
| 230 | |||
| 231 | (ert-deftest cl-generic-tests--method-files--finds-methods () | ||
| 232 | "`method-files' returns a list of files and methods for a generic function." | ||
| 233 | (let ((retval (cl--generic-method-files 'cl-generic-tests--generic))) | ||
| 234 | (should (equal (length retval) 2)) | ||
| 235 | (mapc (lambda (x) | ||
| 236 | (should (equal (car x) cl-generic-tests--this-file)) | ||
| 237 | (should (equal (cadr x) 'cl-generic-tests--generic))) | ||
| 238 | retval) | ||
| 239 | (should-not (equal (nth 0 retval) (nth 1 retval))))) | ||
| 240 | |||
| 241 | (ert-deftest cl-generic-tests--method-files--nonexistent-methods () | ||
| 242 | "`method-files' returns nil if asked to find a method which doesn't exist." | ||
| 243 | (should-not (cl--generic-method-files 'cl-generic-tests--undefined-generic)) | ||
| 244 | (should-not (cl--generic-method-files 'cl-generic-tests--generic-without-methods))) | ||
| 245 | |||
| 222 | (provide 'cl-generic-tests) | 246 | (provide 'cl-generic-tests) |
| 223 | ;;; cl-generic-tests.el ends here | 247 | ;;; cl-generic-tests.el ends here |
diff --git a/test/lisp/emacs-lisp/ert-tests.el b/test/lisp/emacs-lisp/ert-tests.el index 317838b250f..57463ad932d 100644 --- a/test/lisp/emacs-lisp/ert-tests.el +++ b/test/lisp/emacs-lisp/ert-tests.el | |||
| @@ -352,7 +352,7 @@ This macro is used to test if macroexpansion in `should' works." | |||
| 352 | (let ((abc (ert-get-test 'ert-test-abc))) | 352 | (let ((abc (ert-get-test 'ert-test-abc))) |
| 353 | (should (equal (ert-test-tags abc) '(bar))) | 353 | (should (equal (ert-test-tags abc) '(bar))) |
| 354 | (should (equal (ert-test-documentation abc) "foo"))) | 354 | (should (equal (ert-test-documentation abc) "foo"))) |
| 355 | (should (equal (symbol-file 'ert-test-deftest 'ert-deftest) | 355 | (should (equal (symbol-file 'ert-test-deftest 'ert--test) |
| 356 | (symbol-file 'ert-test--which-file 'defun))) | 356 | (symbol-file 'ert-test--which-file 'defun))) |
| 357 | 357 | ||
| 358 | (ert-deftest ert-test-def () :expected-result ':passed) | 358 | (ert-deftest ert-test-def () :expected-result ':passed) |
diff --git a/test/lisp/emacs-lisp/map-tests.el b/test/lisp/emacs-lisp/map-tests.el index 15b0655040c..fc0a6a57c71 100644 --- a/test/lisp/emacs-lisp/map-tests.el +++ b/test/lisp/emacs-lisp/map-tests.el | |||
| @@ -64,9 +64,11 @@ Evaluate BODY for each created map. | |||
| 64 | (should (= 5 (map-elt map 7 5))))) | 64 | (should (= 5 (map-elt map 7 5))))) |
| 65 | 65 | ||
| 66 | (ert-deftest test-map-elt-testfn () | 66 | (ert-deftest test-map-elt-testfn () |
| 67 | (let ((map (list (cons "a" 1) (cons "b" 2)))) | 67 | (let ((map (list (cons "a" 1) (cons "b" 2))) |
| 68 | (should-not (map-elt map "a")) | 68 | ;; Make sure to use a non-eq "a", even when compiled. |
| 69 | (should (map-elt map "a" nil 'equal)))) | 69 | (noneq-key (string ?a))) |
| 70 | (should-not (map-elt map noneq-key)) | ||
| 71 | (should (map-elt map noneq-key nil 'equal)))) | ||
| 70 | 72 | ||
| 71 | (ert-deftest test-map-elt-with-nil-value () | 73 | (ert-deftest test-map-elt-with-nil-value () |
| 72 | (should (null (map-elt '((a . 1) | 74 | (should (null (map-elt '((a . 1) |
| @@ -100,10 +102,12 @@ Evaluate BODY for each created map. | |||
| 100 | 'b)))) | 102 | 'b)))) |
| 101 | 103 | ||
| 102 | (ert-deftest test-map-put-testfn-alist () | 104 | (ert-deftest test-map-put-testfn-alist () |
| 103 | (let ((alist (list (cons "a" 1) (cons "b" 2)))) | 105 | (let ((alist (list (cons "a" 1) (cons "b" 2))) |
| 104 | (map-put alist "a" 3 'equal) | 106 | ;; Make sure to use a non-eq "a", even when compiled. |
| 107 | (noneq-key (string ?a))) | ||
| 108 | (map-put alist noneq-key 3 'equal) | ||
| 105 | (should-not (cddr alist)) | 109 | (should-not (cddr alist)) |
| 106 | (map-put alist "a" 9) | 110 | (map-put alist noneq-key 9) |
| 107 | (should (cddr alist)))) | 111 | (should (cddr alist)))) |
| 108 | 112 | ||
| 109 | (ert-deftest test-map-put-return-value () | 113 | (ert-deftest test-map-put-return-value () |
diff --git a/test/lisp/eshell/em-ls-tests.el b/test/lisp/eshell/em-ls-tests.el new file mode 100644 index 00000000000..8e7b91d9792 --- /dev/null +++ b/test/lisp/eshell/em-ls-tests.el | |||
| @@ -0,0 +1,98 @@ | |||
| 1 | ;;; tests/em-ls-tests.el --- em-ls test suite | ||
| 2 | |||
| 3 | ;; Copyright (C) 2017 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Tino Calancha <tino.calancha@gmail.com> | ||
| 6 | |||
| 7 | ;; This file is part of GNU Emacs. | ||
| 8 | |||
| 9 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 10 | ;; it under the terms of the GNU General Public License as published by | ||
| 11 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 12 | ;; (at your option) any later version. | ||
| 13 | |||
| 14 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | ;; GNU General Public License for more details. | ||
| 18 | |||
| 19 | ;; You should have received a copy of the GNU General Public License | ||
| 20 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | |||
| 22 | ;;; Commentary: | ||
| 23 | |||
| 24 | |||
| 25 | ;;; Code: | ||
| 26 | |||
| 27 | (require 'ert) | ||
| 28 | (require 'em-ls) | ||
| 29 | |||
| 30 | (ert-deftest em-ls-test-bug27631 () | ||
| 31 | "Test for http://debbugs.gnu.org/27631 ." | ||
| 32 | (let* ((dir (make-temp-file "bug27631" 'dir)) | ||
| 33 | (dir1 (expand-file-name "dir1" dir)) | ||
| 34 | (dir2 (expand-file-name "dir2" dir)) | ||
| 35 | (default-directory dir) | ||
| 36 | (orig eshell-ls-use-in-dired) | ||
| 37 | buf) | ||
| 38 | (unwind-protect | ||
| 39 | (progn | ||
| 40 | (customize-set-value 'eshell-ls-use-in-dired t) | ||
| 41 | (make-directory dir1) | ||
| 42 | (make-directory dir2) | ||
| 43 | (with-temp-file (expand-file-name "a.txt" dir1)) | ||
| 44 | (with-temp-file (expand-file-name "b.txt" dir2)) | ||
| 45 | (setq buf (dired (expand-file-name "dir*/*.txt" dir))) | ||
| 46 | (dired-toggle-marks) | ||
| 47 | (should (cdr (dired-get-marked-files)))) | ||
| 48 | (customize-set-variable 'eshell-ls-use-in-dired orig) | ||
| 49 | (delete-directory dir 'recursive) | ||
| 50 | (when (buffer-live-p buf) (kill-buffer buf))))) | ||
| 51 | |||
| 52 | (ert-deftest em-ls-test-bug27817 () | ||
| 53 | "Test for http://debbugs.gnu.org/27817 ." | ||
| 54 | (let ((orig eshell-ls-use-in-dired) | ||
| 55 | (dired-use-ls-dired 'unspecified) | ||
| 56 | buf insert-directory-program) | ||
| 57 | (unwind-protect | ||
| 58 | (progn | ||
| 59 | (customize-set-variable 'eshell-ls-use-in-dired t) | ||
| 60 | (should (setq buf (dired source-directory)))) | ||
| 61 | (customize-set-variable 'eshell-ls-use-in-dired orig) | ||
| 62 | (and (buffer-live-p buf) (kill-buffer))))) | ||
| 63 | |||
| 64 | (ert-deftest em-ls-test-bug27843 () | ||
| 65 | "Test for http://debbugs.gnu.org/27843 ." | ||
| 66 | (let ((orig eshell-ls-use-in-dired) | ||
| 67 | (dired-use-ls-dired 'unspecified) | ||
| 68 | buf insert-directory-program) | ||
| 69 | (unwind-protect | ||
| 70 | (progn | ||
| 71 | (customize-set-variable 'eshell-ls-use-in-dired t) | ||
| 72 | (setq buf (dired (list source-directory "lisp"))) | ||
| 73 | (dired-toggle-marks) | ||
| 74 | (should-not (cdr (dired-get-marked-files)))) | ||
| 75 | (customize-set-variable 'eshell-ls-use-in-dired orig) | ||
| 76 | (and (buffer-live-p buf) (kill-buffer))))) | ||
| 77 | |||
| 78 | (ert-deftest em-ls-test-bug27844 () | ||
| 79 | "Test for http://debbugs.gnu.org/27844 ." | ||
| 80 | (let ((orig eshell-ls-use-in-dired) | ||
| 81 | (dired-use-ls-dired 'unspecified) | ||
| 82 | buf insert-directory-program) | ||
| 83 | (unwind-protect | ||
| 84 | (progn | ||
| 85 | (customize-set-variable 'eshell-ls-use-in-dired t) | ||
| 86 | (setq buf (dired (expand-file-name "lisp/*.el" source-directory))) | ||
| 87 | (dired-toggle-marks) | ||
| 88 | (should (cdr (dired-get-marked-files))) | ||
| 89 | (kill-buffer buf) | ||
| 90 | (setq buf (dired (expand-file-name "lisp/subr.el" source-directory))) | ||
| 91 | (should (looking-at "subr\\.el"))) | ||
| 92 | (customize-set-variable 'eshell-ls-use-in-dired orig) | ||
| 93 | (and (buffer-live-p buf) (kill-buffer))))) | ||
| 94 | |||
| 95 | |||
| 96 | (provide 'em-ls-test) | ||
| 97 | |||
| 98 | ;;; em-ls-tests.el ends here | ||
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index 4583b1af3c3..7bfdca53e08 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el | |||
| @@ -247,10 +247,11 @@ be $HOME." | |||
| 247 | (ert-deftest files-tests--file-name-non-special--subprocess () | 247 | (ert-deftest files-tests--file-name-non-special--subprocess () |
| 248 | "Check that Bug#25949 is fixed." | 248 | "Check that Bug#25949 is fixed." |
| 249 | (skip-unless (executable-find "true")) | 249 | (skip-unless (executable-find "true")) |
| 250 | (should (eq (let ((default-directory "/:/")) (process-file "true")) 0)) | 250 | (let ((defdir (if (memq system-type '(ms-dos windows-nt)) "/:c:/" "/:/"))) |
| 251 | (should (processp (let ((default-directory "/:/")) | 251 | (should (eq (let ((default-directory defdir)) (process-file "true")) 0)) |
| 252 | (start-file-process "foo" nil "true")))) | 252 | (should (processp (let ((default-directory defdir)) |
| 253 | (should (eq (let ((default-directory "/:/")) (shell-command "true")) 0))) | 253 | (start-file-process "foo" nil "true")))) |
| 254 | (should (eq (let ((default-directory defdir)) (shell-command "true")) 0)))) | ||
| 254 | 255 | ||
| 255 | (defmacro files-tests--with-advice (symbol where function &rest body) | 256 | (defmacro files-tests--with-advice (symbol where function &rest body) |
| 256 | (declare (indent 3)) | 257 | (declare (indent 3)) |
| @@ -313,5 +314,23 @@ be invoked with the right arguments." | |||
| 313 | `((verify-visited-file-modtime ,buffer-visiting-file) | 314 | `((verify-visited-file-modtime ,buffer-visiting-file) |
| 314 | (verify-visited-file-modtime nil)))))))) | 315 | (verify-visited-file-modtime nil)))))))) |
| 315 | 316 | ||
| 317 | (ert-deftest files-tests--insert-directory-wildcard-in-dir-p () | ||
| 318 | (let ((alist (list (cons "/home/user/*/.txt" (cons "/home/user/" "*/.txt")) | ||
| 319 | (cons "/home/user/.txt" nil) | ||
| 320 | (cons "/home/*/.txt" (cons "/home/" "*/.txt")) | ||
| 321 | (cons "/home/*/" (cons "/home/" "*/")) | ||
| 322 | (cons "/*/.txt" (cons "/" "*/.txt")) | ||
| 323 | ;; | ||
| 324 | (cons "c:/tmp/*/*.txt" (cons "c:/tmp/" "*/*.txt")) | ||
| 325 | (cons "c:/tmp/*.txt" nil) | ||
| 326 | (cons "c:/tmp/*/" (cons "c:/tmp/" "*/")) | ||
| 327 | (cons "c:/*/*.txt" (cons "c:/" "*/*.txt"))))) | ||
| 328 | (dolist (path-res alist) | ||
| 329 | (should | ||
| 330 | (equal | ||
| 331 | (cdr path-res) | ||
| 332 | (insert-directory-wildcard-in-dir-p (car path-res))))))) | ||
| 333 | |||
| 334 | |||
| 316 | (provide 'files-tests) | 335 | (provide 'files-tests) |
| 317 | ;;; files-tests.el ends here | 336 | ;;; files-tests.el ends here |
diff --git a/test/lisp/ls-lisp-tests.el b/test/lisp/ls-lisp-tests.el new file mode 100644 index 00000000000..d24b30e5f22 --- /dev/null +++ b/test/lisp/ls-lisp-tests.el | |||
| @@ -0,0 +1,94 @@ | |||
| 1 | ;;; ls-lisp-tests.el --- tests for ls-lisp.el -*- lexical-binding: t-*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2017 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Tino Calacha <tino.calancha@gmail.com> | ||
| 6 | ;; Keywords: | ||
| 7 | |||
| 8 | ;; This file is part of GNU Emacs. | ||
| 9 | |||
| 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 11 | ;; it under the terms of the GNU General Public License as published by | ||
| 12 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 13 | ;; (at your option) any later version. | ||
| 14 | |||
| 15 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | ;; GNU General Public License for more details. | ||
| 19 | |||
| 20 | ;; You should have received a copy of the GNU General Public License | ||
| 21 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 22 | |||
| 23 | ;;; Commentary: | ||
| 24 | |||
| 25 | |||
| 26 | ;;; Code: | ||
| 27 | (require 'ert) | ||
| 28 | (require 'ls-lisp) | ||
| 29 | |||
| 30 | (ert-deftest ls-lisp-unload () | ||
| 31 | "Test for http://debbugs.gnu.org/xxxxx ." | ||
| 32 | (should (advice-member-p 'ls-lisp--insert-directory 'insert-directory)) | ||
| 33 | (unload-feature 'ls-lisp 'force) | ||
| 34 | (should-not (advice-member-p 'ls-lisp--insert-directory 'insert-directory)) | ||
| 35 | (require 'ls-lisp)) | ||
| 36 | |||
| 37 | (ert-deftest ls-lisp-test-bug27762 () | ||
| 38 | "Test for http://debbugs.gnu.org/27762 ." | ||
| 39 | (let* ((dir source-directory) | ||
| 40 | (default-directory dir) | ||
| 41 | (files (mapcar (lambda (f) (concat "src/" f)) | ||
| 42 | (directory-files | ||
| 43 | (expand-file-name "src") nil "\\.*\\.c\\'"))) | ||
| 44 | ls-lisp-use-insert-directory-program buf) | ||
| 45 | (unwind-protect | ||
| 46 | (let ((file1 "src/cygw32.c") | ||
| 47 | (file2 "src/atimer.c")) | ||
| 48 | (setq buf (dired (nconc (list dir) files))) | ||
| 49 | (dired-goto-file (expand-file-name file2 default-directory)) | ||
| 50 | (should-not (looking-at "^ -")) ; Must be 2 spaces not 3. | ||
| 51 | (setq files (cons file1 (delete file1 files))) | ||
| 52 | (kill-buffer buf) | ||
| 53 | (setq buf (dired (nconc (list dir) files))) | ||
| 54 | (should (looking-at "src")) | ||
| 55 | (next-line) ; File names must be aligned. | ||
| 56 | (should (looking-at "src"))) | ||
| 57 | (when (buffer-live-p buf) (kill-buffer buf))))) | ||
| 58 | |||
| 59 | (ert-deftest ls-lisp-test-bug27631 () | ||
| 60 | "Test for http://debbugs.gnu.org/27631 ." | ||
| 61 | (let* ((dir (make-temp-file "bug27631" 'dir)) | ||
| 62 | (dir1 (expand-file-name "dir1" dir)) | ||
| 63 | (dir2 (expand-file-name "dir2" dir)) | ||
| 64 | (default-directory dir) | ||
| 65 | ls-lisp-use-insert-directory-program buf) | ||
| 66 | (unwind-protect | ||
| 67 | (progn | ||
| 68 | (make-directory dir1) | ||
| 69 | (make-directory dir2) | ||
| 70 | (with-temp-file (expand-file-name "a.txt" dir1)) | ||
| 71 | (with-temp-file (expand-file-name "b.txt" dir2)) | ||
| 72 | (setq buf (dired (expand-file-name "dir*/*.txt" dir))) | ||
| 73 | (dired-toggle-marks) | ||
| 74 | (should (cdr (dired-get-marked-files)))) | ||
| 75 | (delete-directory dir 'recursive) | ||
| 76 | (when (buffer-live-p buf) (kill-buffer buf))))) | ||
| 77 | |||
| 78 | (ert-deftest ls-lisp-test-bug27693 () | ||
| 79 | "Test for http://debbugs.gnu.org/27693 ." | ||
| 80 | (let ((dir (expand-file-name "lisp" source-directory)) | ||
| 81 | (size "") | ||
| 82 | ls-lisp-use-insert-directory-program buf) | ||
| 83 | (unwind-protect | ||
| 84 | (progn | ||
| 85 | (setq buf (dired (list dir "simple.el" "subr.el")) | ||
| 86 | size (number-to-string | ||
| 87 | (file-attribute-size | ||
| 88 | (file-attributes (dired-get-filename))))) | ||
| 89 | (search-backward-regexp size nil t) | ||
| 90 | (should (looking-back "[[:space:]]" (1- (point))))) | ||
| 91 | (when (buffer-live-p buf) (kill-buffer buf))))) | ||
| 92 | |||
| 93 | (provide 'ls-lisp-tests) | ||
| 94 | ;;; ls-lisp-tests.el ends here | ||
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index bb1bafa789f..50dfd6fac2e 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -123,9 +123,10 @@ being the result.") | |||
| 123 | (cdr tramp--test-enabled-checked)) | 123 | (cdr tramp--test-enabled-checked)) |
| 124 | 124 | ||
| 125 | (defun tramp--test-make-temp-name (&optional local quoted) | 125 | (defun tramp--test-make-temp-name (&optional local quoted) |
| 126 | "Create a temporary file name for test. | 126 | "Return a temporary file name for test. |
| 127 | If LOCAL is non-nil, a local file is created. | 127 | If LOCAL is non-nil, a local file name is returned. |
| 128 | If QUOTED is non-nil, the local part of the file is quoted." | 128 | If QUOTED is non-nil, the local part of the file name is quoted. |
| 129 | The temporary file is not created." | ||
| 129 | (funcall | 130 | (funcall |
| 130 | (if quoted 'tramp-compat-file-name-quote 'identity) | 131 | (if quoted 'tramp-compat-file-name-quote 'identity) |
| 131 | (expand-file-name | 132 | (expand-file-name |
| @@ -2201,6 +2202,110 @@ This tests also `file-directory-p' and `file-accessible-directory-p'." | |||
| 2201 | ;; Cleanup. | 2202 | ;; Cleanup. |
| 2202 | (ignore-errors (delete-directory tmp-name1 'recursive)))))) | 2203 | (ignore-errors (delete-directory tmp-name1 'recursive)))))) |
| 2203 | 2204 | ||
| 2205 | (ert-deftest tramp-test17-dired-with-wildcards () | ||
| 2206 | "Check `dired' with wildcards." | ||
| 2207 | (skip-unless (tramp--test-enabled)) | ||
| 2208 | (skip-unless (tramp--test-sh-p)) | ||
| 2209 | ;; Since Emacs 26.1. | ||
| 2210 | (skip-unless (fboundp 'insert-directory-wildcard-in-dir-p)) | ||
| 2211 | |||
| 2212 | (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) | ||
| 2213 | (let* ((tmp-name1 | ||
| 2214 | (expand-file-name (tramp--test-make-temp-name nil quoted))) | ||
| 2215 | (tmp-name2 | ||
| 2216 | (expand-file-name (tramp--test-make-temp-name nil quoted))) | ||
| 2217 | (tmp-name3 (expand-file-name "foo" tmp-name1)) | ||
| 2218 | (tmp-name4 (expand-file-name "bar" tmp-name2)) | ||
| 2219 | (tramp-test-temporary-file-directory | ||
| 2220 | (funcall | ||
| 2221 | (if quoted 'tramp-compat-file-name-quote 'identity) | ||
| 2222 | tramp-test-temporary-file-directory)) | ||
| 2223 | buffer) | ||
| 2224 | (unwind-protect | ||
| 2225 | (progn | ||
| 2226 | (make-directory tmp-name1) | ||
| 2227 | (write-region "foo" nil tmp-name3) | ||
| 2228 | (should (file-directory-p tmp-name1)) | ||
| 2229 | (should (file-exists-p tmp-name3)) | ||
| 2230 | (make-directory tmp-name2) | ||
| 2231 | (write-region "foo" nil tmp-name4) | ||
| 2232 | (should (file-directory-p tmp-name2)) | ||
| 2233 | (should (file-exists-p tmp-name4)) | ||
| 2234 | |||
| 2235 | ;; Check for expanded directory names. | ||
| 2236 | (with-current-buffer | ||
| 2237 | (setq buffer | ||
| 2238 | (dired-noselect | ||
| 2239 | (expand-file-name | ||
| 2240 | "tramp-test*" tramp-test-temporary-file-directory))) | ||
| 2241 | (goto-char (point-min)) | ||
| 2242 | (should | ||
| 2243 | (re-search-forward | ||
| 2244 | (regexp-quote | ||
| 2245 | (file-relative-name | ||
| 2246 | tmp-name1 tramp-test-temporary-file-directory)))) | ||
| 2247 | (goto-char (point-min)) | ||
| 2248 | (should | ||
| 2249 | (re-search-forward | ||
| 2250 | (regexp-quote | ||
| 2251 | (file-relative-name | ||
| 2252 | tmp-name2 tramp-test-temporary-file-directory))))) | ||
| 2253 | (kill-buffer buffer) | ||
| 2254 | |||
| 2255 | ;; Check for expanded directory and file names. | ||
| 2256 | (with-current-buffer | ||
| 2257 | (setq buffer | ||
| 2258 | (dired-noselect | ||
| 2259 | (expand-file-name | ||
| 2260 | "tramp-test*/*" tramp-test-temporary-file-directory))) | ||
| 2261 | (goto-char (point-min)) | ||
| 2262 | (should | ||
| 2263 | (re-search-forward | ||
| 2264 | (regexp-quote | ||
| 2265 | (file-relative-name | ||
| 2266 | tmp-name3 tramp-test-temporary-file-directory)))) | ||
| 2267 | (goto-char (point-min)) | ||
| 2268 | (should | ||
| 2269 | (re-search-forward | ||
| 2270 | (regexp-quote | ||
| 2271 | (file-relative-name | ||
| 2272 | tmp-name4 | ||
| 2273 | tramp-test-temporary-file-directory))))) | ||
| 2274 | (kill-buffer buffer) | ||
| 2275 | |||
| 2276 | ;; Check for special characters. | ||
| 2277 | (setq tmp-name3 (expand-file-name "*?" tmp-name1)) | ||
| 2278 | (setq tmp-name4 (expand-file-name "[a-z0-9]" tmp-name2)) | ||
| 2279 | (write-region "foo" nil tmp-name3) | ||
| 2280 | (should (file-exists-p tmp-name3)) | ||
| 2281 | (write-region "foo" nil tmp-name4) | ||
| 2282 | (should (file-exists-p tmp-name4)) | ||
| 2283 | |||
| 2284 | (with-current-buffer | ||
| 2285 | (setq buffer | ||
| 2286 | (dired-noselect | ||
| 2287 | (expand-file-name | ||
| 2288 | "tramp-test*/*" tramp-test-temporary-file-directory))) | ||
| 2289 | (goto-char (point-min)) | ||
| 2290 | (should | ||
| 2291 | (re-search-forward | ||
| 2292 | (regexp-quote | ||
| 2293 | (file-relative-name | ||
| 2294 | tmp-name3 tramp-test-temporary-file-directory)))) | ||
| 2295 | (goto-char (point-min)) | ||
| 2296 | (should | ||
| 2297 | (re-search-forward | ||
| 2298 | (regexp-quote | ||
| 2299 | (file-relative-name | ||
| 2300 | tmp-name4 | ||
| 2301 | tramp-test-temporary-file-directory))))) | ||
| 2302 | (kill-buffer buffer)) | ||
| 2303 | |||
| 2304 | ;; Cleanup. | ||
| 2305 | (ignore-errors (kill-buffer buffer)) | ||
| 2306 | (ignore-errors (delete-directory tmp-name1 'recursive)) | ||
| 2307 | (ignore-errors (delete-directory tmp-name2 'recursive)))))) | ||
| 2308 | |||
| 2204 | (ert-deftest tramp-test18-file-attributes () | 2309 | (ert-deftest tramp-test18-file-attributes () |
| 2205 | "Check `file-attributes'. | 2310 | "Check `file-attributes'. |
| 2206 | This tests also `file-readable-p', `file-regular-p' and | 2311 | This tests also `file-readable-p', `file-regular-p' and |
| @@ -3005,6 +3110,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 3005 | :tags '(:expensive-test) | 3110 | :tags '(:expensive-test) |
| 3006 | (skip-unless (tramp--test-enabled)) | 3111 | (skip-unless (tramp--test-enabled)) |
| 3007 | (skip-unless (tramp--test-sh-p)) | 3112 | (skip-unless (tramp--test-sh-p)) |
| 3113 | ;; Since Emacs 26.1. | ||
| 3008 | (skip-unless (and (fboundp 'connection-local-set-profile-variables) | 3114 | (skip-unless (and (fboundp 'connection-local-set-profile-variables) |
| 3009 | (fboundp 'connection-local-set-profiles))) | 3115 | (fboundp 'connection-local-set-profiles))) |
| 3010 | 3116 | ||
| @@ -3214,6 +3320,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 3214 | (ert-deftest tramp-test33-make-nearby-temp-file () | 3320 | (ert-deftest tramp-test33-make-nearby-temp-file () |
| 3215 | "Check `make-nearby-temp-file' and `temporary-file-directory'." | 3321 | "Check `make-nearby-temp-file' and `temporary-file-directory'." |
| 3216 | (skip-unless (tramp--test-enabled)) | 3322 | (skip-unless (tramp--test-enabled)) |
| 3323 | ;; Since Emacs 26.1. | ||
| 3217 | (skip-unless | 3324 | (skip-unless |
| 3218 | (and (fboundp 'make-nearby-temp-file) (fboundp 'temporary-file-directory))) | 3325 | (and (fboundp 'make-nearby-temp-file) (fboundp 'temporary-file-directory))) |
| 3219 | 3326 | ||
| @@ -3680,6 +3787,10 @@ Use the `ls' command." | |||
| 3680 | tramp-connection-properties))) | 3787 | tramp-connection-properties))) |
| 3681 | (tramp--test-utf8))) | 3788 | (tramp--test-utf8))) |
| 3682 | 3789 | ||
| 3790 | (defun tramp--test-timeout-handler () | ||
| 3791 | (interactive) | ||
| 3792 | (ert-fail (format "`%s' timed out" (ert-test-name (ert-running-test))))) | ||
| 3793 | |||
| 3683 | ;; This test is inspired by Bug#16928. | 3794 | ;; This test is inspired by Bug#16928. |
| 3684 | (ert-deftest tramp-test36-asynchronous-requests () | 3795 | (ert-deftest tramp-test36-asynchronous-requests () |
| 3685 | "Check parallel asynchronous requests. | 3796 | "Check parallel asynchronous requests. |
| @@ -3689,10 +3800,16 @@ process sentinels. They shall not disturb each other." | |||
| 3689 | (skip-unless (tramp--test-enabled)) | 3800 | (skip-unless (tramp--test-enabled)) |
| 3690 | (skip-unless (tramp--test-sh-p)) | 3801 | (skip-unless (tramp--test-sh-p)) |
| 3691 | 3802 | ||
| 3692 | ;; This test could be blocked on hydra. | 3803 | ;; This test could be blocked on hydra. So we set a timeout of 300 |
| 3693 | (with-timeout | 3804 | ;; seconds, and we send a SIGUSR1 signal after 300 seconds. |
| 3694 | (300 (ert-fail "`tramp-test36-asynchronous-requests' timed out")) | 3805 | (with-timeout (300 (tramp--test-timeout-handler)) |
| 3695 | (let* ((tmp-name (tramp--test-make-temp-name)) | 3806 | (define-key special-event-map [sigusr1] 'tramp--test-timeout-handler) |
| 3807 | (tramp--test-instrument-test-case (if (getenv "EMACS_HYDRA_CI") 10 0) | ||
| 3808 | (let* ((watchdog | ||
| 3809 | (start-process | ||
| 3810 | "*watchdog*" nil shell-file-name shell-command-switch | ||
| 3811 | (format "sleep 300; kill -USR1 %d" (emacs-pid)))) | ||
| 3812 | (tmp-name (tramp--test-make-temp-name)) | ||
| 3696 | (default-directory tmp-name) | 3813 | (default-directory tmp-name) |
| 3697 | ;; Do not cache Tramp properties. | 3814 | ;; Do not cache Tramp properties. |
| 3698 | (remote-file-name-inhibit-cache t) | 3815 | (remote-file-name-inhibit-cache t) |
| @@ -3791,25 +3908,18 @@ process sentinels. They shall not disturb each other." | |||
| 3791 | (count (process-get proc 'bar))) | 3908 | (count (process-get proc 'bar))) |
| 3792 | (tramp--test-message | 3909 | (tramp--test-message |
| 3793 | "Start action %d %s %s" count buf (current-time-string)) | 3910 | "Start action %d %s %s" count buf (current-time-string)) |
| 3794 | ;; Regular operation. | 3911 | ;; Regular operation prior process action. |
| 3795 | (if (= count 0) | 3912 | (if (= count 0) |
| 3796 | (should-not (file-attributes file)) | 3913 | (should-not (file-attributes file)) |
| 3797 | (should (file-attributes file))) | 3914 | (should (file-attributes file))) |
| 3798 | ;; Send string to process. | 3915 | ;; Send string to process. |
| 3799 | (tramp--test-message | ||
| 3800 | "Trace 1 action %d %s %s" count buf (current-time-string)) | ||
| 3801 | (process-send-string proc (format "%s\n" (buffer-name buf))) | 3916 | (process-send-string proc (format "%s\n" (buffer-name buf))) |
| 3802 | (tramp--test-message | ||
| 3803 | "Trace 2 action %d %s %s" count buf (current-time-string)) | ||
| 3804 | (accept-process-output proc 0.1 nil 0) | 3917 | (accept-process-output proc 0.1 nil 0) |
| 3805 | ;; Regular operation. | 3918 | ;; Give the watchdog a chance. |
| 3806 | (tramp--test-message | 3919 | (read-event nil nil 0.01) |
| 3807 | "Trace 3 action %d %s %s" count buf (current-time-string)) | 3920 | ;; Regular operation post process action. |
| 3808 | (if (= count 2) | 3921 | (if (= count 2) |
| 3809 | (if (= (length buffers) 1) | 3922 | (should-not (file-attributes file)) |
| 3810 | (tramp--test-instrument-test-case 10 | ||
| 3811 | (should-not (file-attributes file))) | ||
| 3812 | (should-not (file-attributes file))) | ||
| 3813 | (should (file-attributes file))) | 3923 | (should (file-attributes file))) |
| 3814 | (tramp--test-message | 3924 | (tramp--test-message |
| 3815 | "Stop action %d %s %s" count buf (current-time-string)) | 3925 | "Stop action %d %s %s" count buf (current-time-string)) |
| @@ -3820,8 +3930,7 @@ process sentinels. They shall not disturb each other." | |||
| 3820 | ;; Checks. All process output shall exists in the | 3930 | ;; Checks. All process output shall exists in the |
| 3821 | ;; respective buffers. All created files shall be | 3931 | ;; respective buffers. All created files shall be |
| 3822 | ;; deleted. | 3932 | ;; deleted. |
| 3823 | (tramp--test-message | 3933 | (tramp--test-message "Check %s" (current-time-string)) |
| 3824 | "Check %s" (current-time-string)) | ||
| 3825 | (dolist (buf buffers) | 3934 | (dolist (buf buffers) |
| 3826 | (with-current-buffer buf | 3935 | (with-current-buffer buf |
| 3827 | (should (string-equal (format "%s\n" buf) (buffer-string))))) | 3936 | (should (string-equal (format "%s\n" buf) (buffer-string))))) |
| @@ -3830,11 +3939,13 @@ process sentinels. They shall not disturb each other." | |||
| 3830 | tmp-name nil directory-files-no-dot-files-regexp))) | 3939 | tmp-name nil directory-files-no-dot-files-regexp))) |
| 3831 | 3940 | ||
| 3832 | ;; Cleanup. | 3941 | ;; Cleanup. |
| 3942 | (define-key special-event-map [sigusr1] 'ignore) | ||
| 3943 | (ignore-errors (quit-process watchdog)) | ||
| 3833 | (dolist (buf buffers) | 3944 | (dolist (buf buffers) |
| 3834 | (ignore-errors (delete-process (get-buffer-process buf))) | 3945 | (ignore-errors (delete-process (get-buffer-process buf))) |
| 3835 | (ignore-errors (kill-buffer buf))) | 3946 | (ignore-errors (kill-buffer buf))) |
| 3836 | (ignore-errors (cancel-timer timer)) | 3947 | (ignore-errors (cancel-timer timer)) |
| 3837 | (ignore-errors (delete-directory tmp-name 'recursive)))))) | 3948 | (ignore-errors (delete-directory tmp-name 'recursive))))))) |
| 3838 | 3949 | ||
| 3839 | (ert-deftest tramp-test37-recursive-load () | 3950 | (ert-deftest tramp-test37-recursive-load () |
| 3840 | "Check that Tramp does not fail due to recursive load." | 3951 | "Check that Tramp does not fail due to recursive load." |
| @@ -3911,8 +4022,8 @@ Since it unloads Tramp, it shall be the last test to run." | |||
| 3911 | (should-not (cl--find-class 'tramp-file-name)) | 4022 | (should-not (cl--find-class 'tramp-file-name)) |
| 3912 | (mapatoms | 4023 | (mapatoms |
| 3913 | (lambda (x) | 4024 | (lambda (x) |
| 3914 | (and (string-match "tramp-file-name" (symbol-name x)) | 4025 | (and (functionp x) |
| 3915 | (functionp x) | 4026 | (string-match "tramp-file-name" (symbol-name x)) |
| 3916 | (ert-fail (format "Structure function `%s' still exists" x))))) | 4027 | (ert-fail (format "Structure function `%s' still exists" x))))) |
| 3917 | ;; There shouldn't be left a hook function containing a Tramp | 4028 | ;; There shouldn't be left a hook function containing a Tramp |
| 3918 | ;; function. We do not regard the Tramp unload hooks. | 4029 | ;; function. We do not regard the Tramp unload hooks. |
diff --git a/test/lisp/register-tests.el b/test/lisp/register-tests.el new file mode 100644 index 00000000000..0425bc0e0f4 --- /dev/null +++ b/test/lisp/register-tests.el | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | ;;; register-tests.el --- tests for register.el -*- lexical-binding: t-*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2017 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Tino Calacha <tino.calancha@gmail.com> | ||
| 6 | ;; Keywords: | ||
| 7 | |||
| 8 | ;; This file is part of GNU Emacs. | ||
| 9 | |||
| 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 11 | ;; it under the terms of the GNU General Public License as published by | ||
| 12 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 13 | ;; (at your option) any later version. | ||
| 14 | |||
| 15 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | ;; GNU General Public License for more details. | ||
| 19 | |||
| 20 | ;; You should have received a copy of the GNU General Public License | ||
| 21 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 22 | |||
| 23 | ;;; Commentary: | ||
| 24 | |||
| 25 | |||
| 26 | ;;; Code: | ||
| 27 | (require 'ert) | ||
| 28 | (require 'cl-lib) | ||
| 29 | |||
| 30 | (ert-deftest register-test-bug27634 () | ||
| 31 | "Test for http://debbugs.gnu.org/27634 ." | ||
| 32 | (dolist (event (list ?\C-g 'escape ?\C-\[)) | ||
| 33 | (cl-letf (((symbol-function 'read-key) #'ignore) | ||
| 34 | (last-input-event event) | ||
| 35 | (register-alist nil)) | ||
| 36 | (should (equal 'quit | ||
| 37 | (condition-case err | ||
| 38 | (call-interactively 'point-to-register) | ||
| 39 | (quit (car err))))) | ||
| 40 | (should-not register-alist)))) | ||
| 41 | |||
| 42 | (provide 'register-tests) | ||
| 43 | ;;; register-tests.el ends here | ||
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index 7e50429a5bf..a59f0ca90e1 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el | |||
| @@ -292,31 +292,6 @@ cf. Bug#25477." | |||
| 292 | (should-error (eval '(dolist "foo") t) | 292 | (should-error (eval '(dolist "foo") t) |
| 293 | :type 'wrong-type-argument)) | 293 | :type 'wrong-type-argument)) |
| 294 | 294 | ||
| 295 | (require 'cl-generic) | ||
| 296 | (cl-defgeneric subr-tests--generic (x)) | ||
| 297 | (cl-defmethod subr-tests--generic ((x string)) | ||
| 298 | (message "%s is a string" x)) | ||
| 299 | (cl-defmethod subr-tests--generic ((x integer)) | ||
| 300 | (message "%s is a number" x)) | ||
| 301 | (cl-defgeneric subr-tests--generic-without-methods (x y)) | ||
| 302 | (defvar subr-tests--this-file | ||
| 303 | (file-truename (or load-file-name buffer-file-name))) | ||
| 304 | |||
| 305 | (ert-deftest subr-tests--method-files--finds-methods () | ||
| 306 | "`method-files' returns a list of files and methods for a generic function." | ||
| 307 | (let ((retval (method-files 'subr-tests--generic))) | ||
| 308 | (should (equal (length retval) 2)) | ||
| 309 | (mapc (lambda (x) | ||
| 310 | (should (equal (car x) subr-tests--this-file)) | ||
| 311 | (should (equal (cadr x) 'subr-tests--generic))) | ||
| 312 | retval) | ||
| 313 | (should-not (equal (nth 0 retval) (nth 1 retval))))) | ||
| 314 | |||
| 315 | (ert-deftest subr-tests--method-files--nonexistent-methods () | ||
| 316 | "`method-files' returns nil if asked to find a method which doesn't exist." | ||
| 317 | (should-not (method-files 'subr-tests--undefined-generic)) | ||
| 318 | (should-not (method-files 'subr-tests--generic-without-methods))) | ||
| 319 | |||
| 320 | (ert-deftest subr-tests-bug22027 () | 295 | (ert-deftest subr-tests-bug22027 () |
| 321 | "Test for http://debbugs.gnu.org/22027 ." | 296 | "Test for http://debbugs.gnu.org/22027 ." |
| 322 | (let ((default "foo") res) | 297 | (let ((default "foo") res) |
diff --git a/test/lisp/vc/ediff-ptch-tests.el b/test/lisp/vc/ediff-ptch-tests.el index 387786ced06..6fbc1b0a8bd 100644 --- a/test/lisp/vc/ediff-ptch-tests.el +++ b/test/lisp/vc/ediff-ptch-tests.el | |||
| @@ -66,41 +66,55 @@ index 6a07f80..6e8e947 100644 | |||
| 66 | (write-region nil nil bar nil 'silent)) | 66 | (write-region nil nil bar nil 'silent)) |
| 67 | (call-process git-program nil `(:file ,patch) nil "diff") | 67 | (call-process git-program nil `(:file ,patch) nil "diff") |
| 68 | (call-process git-program nil nil nil "reset" "--hard" "HEAD") | 68 | (call-process git-program nil nil nil "reset" "--hard" "HEAD") |
| 69 | ;; Visit the diff file i.e., patch; extract from it the parts | ||
| 70 | ;; affecting just each of the files: store in patch-bar the part | ||
| 71 | ;; affecting 'bar', and in patch-qux the part affecting 'qux'. | ||
| 69 | (find-file patch) | 72 | (find-file patch) |
| 70 | (unwind-protect | 73 | (unwind-protect |
| 71 | (let* ((info | 74 | (let* ((info |
| 72 | (progn (ediff-map-patch-buffer (current-buffer)) ediff-patch-map)) | 75 | (progn (ediff-map-patch-buffer (current-buffer)) ediff-patch-map)) |
| 73 | (patch1 | 76 | (patch-bar |
| 74 | (buffer-substring-no-properties | 77 | (buffer-substring-no-properties |
| 75 | (car (nth 3 (car info))) | 78 | (car (nth 3 (car info))) |
| 76 | (car (nth 4 (car info))))) | 79 | (car (nth 4 (car info))))) |
| 77 | (patch2 | 80 | (patch-qux |
| 78 | (buffer-substring-no-properties | 81 | (buffer-substring-no-properties |
| 79 | (car (nth 3 (cadr info))) | 82 | (car (nth 3 (cadr info))) |
| 80 | (car (nth 4 (cadr info)))))) | 83 | (car (nth 4 (cadr info)))))) |
| 81 | ;; Apply both patches. | 84 | ;; Apply both patches. |
| 82 | (dolist (x (list (cons patch1 bar) (cons patch2 qux))) | 85 | (dolist (x (list (cons patch-bar bar) (cons patch-qux qux))) |
| 83 | (with-temp-buffer | 86 | (with-temp-buffer |
| 84 | (insert (car x)) | 87 | ;; Some windows variants require the option '--binary' |
| 85 | (call-process-region (point-min) | 88 | ;; in order to 'patch' create backup files. |
| 86 | (point-max) | 89 | (let ((opts (format "--backup%s" |
| 87 | ediff-patch-program | 90 | (if (memq system-type '(windows-nt ms-dos)) |
| 88 | nil nil nil | 91 | " --binary" "")))) |
| 89 | "-b" (cdr x)))) | 92 | (insert (car x)) |
| 90 | ;; Check backup files were saved correctly. | 93 | (call-process-region (point-min) |
| 94 | (point-max) | ||
| 95 | ediff-patch-program | ||
| 96 | nil nil nil | ||
| 97 | opts (cdr x))))) | ||
| 98 | ;; Check backup files were saved correctly; in Bug#26084 some | ||
| 99 | ;; of the backup files are overwritten with the actual content | ||
| 100 | ;; of the updated file. To ensure that the bug is fixed we just | ||
| 101 | ;; need to check that every backup file produced has different | ||
| 102 | ;; content that the current updated file. | ||
| 91 | (dolist (x (list qux bar)) | 103 | (dolist (x (list qux bar)) |
| 92 | (let ((backup | 104 | (let ((backup |
| 93 | (car | 105 | (car |
| 94 | (directory-files | 106 | (directory-files |
| 95 | tmpdir 'full | 107 | tmpdir 'full |
| 96 | (concat (file-name-nondirectory x) "."))))) | 108 | (concat (file-name-nondirectory x) "."))))) |
| 97 | (should-not | 109 | ;; Compare files only if the backup has being created. |
| 98 | (string= (with-temp-buffer | 110 | (when backup |
| 99 | (insert-file-contents x) | 111 | (should-not |
| 100 | (buffer-string)) | 112 | (string= (with-temp-buffer |
| 101 | (with-temp-buffer | 113 | (insert-file-contents x) |
| 102 | (insert-file-contents backup) | 114 | (buffer-string)) |
| 103 | (buffer-string)))))) | 115 | (with-temp-buffer |
| 116 | (insert-file-contents backup) | ||
| 117 | (buffer-string))))))) | ||
| 104 | (delete-directory tmpdir 'recursive) | 118 | (delete-directory tmpdir 'recursive) |
| 105 | (delete-file patch))))) | 119 | (delete-file patch))))) |
| 106 | 120 | ||
diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el index 793dddd8bd4..87406740a78 100644 --- a/test/src/buffer-tests.el +++ b/test/src/buffer-tests.el | |||
| @@ -45,4 +45,9 @@ with parameters from the *Messages* buffer modification." | |||
| 45 | (should (eq buf (current-buffer)))) | 45 | (should (eq buf (current-buffer)))) |
| 46 | (when msg-ov (delete-overlay msg-ov)))))) | 46 | (when msg-ov (delete-overlay msg-ov)))))) |
| 47 | 47 | ||
| 48 | (ert-deftest test-generate-new-buffer-name-bug27966 () | ||
| 49 | (should-not (string-equal "nil" | ||
| 50 | (progn (get-buffer-create "nil") | ||
| 51 | (generate-new-buffer-name "nil"))))) | ||
| 52 | |||
| 48 | ;;; buffer-tests.el ends here | 53 | ;;; buffer-tests.el ends here |
diff --git a/test/src/eval-tests.el b/test/src/eval-tests.el index 03f408716b1..b98de0aa65e 100644 --- a/test/src/eval-tests.el +++ b/test/src/eval-tests.el | |||
| @@ -59,4 +59,24 @@ Bug#24912 and Bug#24913." | |||
| 59 | (should-error (,form ,arg) :type 'wrong-type-argument)) | 59 | (should-error (,form ,arg) :type 'wrong-type-argument)) |
| 60 | t))) | 60 | t))) |
| 61 | 61 | ||
| 62 | (ert-deftest eval-tests--if-dot-string () | ||
| 63 | "Check that Emacs rejects (if . \"string\")." | ||
| 64 | (should-error (eval '(if . "abc")) :type 'wrong-type-argument) | ||
| 65 | (let ((if-tail (list '(setcdr if-tail "abc") t))) | ||
| 66 | (should-error (eval (cons 'if if-tail)))) | ||
| 67 | (let ((if-tail (list '(progn (setcdr if-tail "abc") nil) t))) | ||
| 68 | (should-error (eval (cons 'if if-tail))))) | ||
| 69 | |||
| 70 | (ert-deftest eval-tests--let-with-circular-defs () | ||
| 71 | "Check that Emacs reports an error for (let VARS ...) when VARS is circular." | ||
| 72 | (let ((vars (list 'v))) | ||
| 73 | (setcdr vars vars) | ||
| 74 | (dolist (let-sym '(let let*)) | ||
| 75 | (should-error (eval (list let-sym vars)))))) | ||
| 76 | |||
| 77 | (ert-deftest eval-tests--mutating-cond () | ||
| 78 | "Check that Emacs doesn't crash on a cond clause that mutates during eval." | ||
| 79 | (let ((clauses (list '((progn (setcdr clauses "ouch") nil))))) | ||
| 80 | (should-error (eval (cons 'cond clauses))))) | ||
| 81 | |||
| 62 | ;;; eval-tests.el ends here | 82 | ;;; eval-tests.el ends here |