diff options
| author | Tino Calancha | 2017-08-02 16:39:11 +0900 |
|---|---|---|
| committer | Tino Calancha | 2017-08-02 16:47:28 +0900 |
| commit | a79671c97fb193ec44ca27e1eeb9e7f5bcf2e9f6 (patch) | |
| tree | cb73aab51f94aa1bc885abda82f36e5d6044de0d | |
| parent | 0668ecc0cd9c2ef7bc0e6f320af454aca1325c25 (diff) | |
| download | emacs-a79671c97fb193ec44ca27e1eeb9e7f5bcf2e9f6.tar.gz emacs-a79671c97fb193ec44ca27e1eeb9e7f5bcf2e9f6.zip | |
Move dired tests using ls emulation to different files
Suggested in:
https://lists.gnu.org/archive/html/emacs-devel/2017-08/msg00018.html
* test/lisp/dired-tests.el (dired-test-bug27693)
(dired-test-bug27762, dired-test-bug27817)
(dired-test-bug27631, dired-test-bug27843): Delete those
parts requiring either ls-lisp or eshell-ls.
* test/lisp/ls-lisp-tests.el (ls-lisp-test-bug27762)
(ls-lisp-test-bug27631, ls-lisp-test-bug27693):
Add all dired tests using ls-lisp here.
* test/lisp/eshell/em-ls-tests.el (em-ls-test-bug27631)
(em-ls-test-bug27817, em-ls-test-bug27843): New test file. Add
all dired tests using eshell-ls here.
| -rw-r--r-- | test/lisp/dired-tests.el | 91 | ||||
| -rw-r--r-- | test/lisp/eshell/em-ls-tests.el | 80 | ||||
| -rw-r--r-- | test/lisp/ls-lisp-tests.el | 61 |
3 files changed, 140 insertions, 92 deletions
diff --git a/test/lisp/dired-tests.el b/test/lisp/dired-tests.el index 047bfdcf71c..4ab6b37664b 100644 --- a/test/lisp/dired-tests.el +++ b/test/lisp/dired-tests.el | |||
| @@ -225,23 +225,6 @@ | |||
| 225 | (when (buffer-live-p buf) (kill-buffer buf))) | 225 | (when (buffer-live-p buf) (kill-buffer buf))) |
| 226 | (delete-directory test-dir t)))) | 226 | (delete-directory test-dir t)))) |
| 227 | 227 | ||
| 228 | (ert-deftest dired-test-bug27693 () | ||
| 229 | "Test for http://debbugs.gnu.org/27693 ." | ||
| 230 | (require 'ls-lisp) | ||
| 231 | (let ((dir (expand-file-name "lisp" source-directory)) | ||
| 232 | (size "") | ||
| 233 | ls-lisp-use-insert-directory-program buf) | ||
| 234 | (unwind-protect | ||
| 235 | (progn | ||
| 236 | (setq buf (dired (list dir "simple.el" "subr.el")) | ||
| 237 | size (number-to-string | ||
| 238 | (file-attribute-size | ||
| 239 | (file-attributes (dired-get-filename))))) | ||
| 240 | (search-backward-regexp size nil t) | ||
| 241 | (should (looking-back "[[:space:]]" (1- (point))))) | ||
| 242 | (unload-feature 'ls-lisp 'force) | ||
| 243 | (when (buffer-live-p buf) (kill-buffer buf))))) | ||
| 244 | |||
| 245 | (ert-deftest dired-test-bug7131 () | 228 | (ert-deftest dired-test-bug7131 () |
| 246 | "Test for http://debbugs.gnu.org/7131 ." | 229 | "Test for http://debbugs.gnu.org/7131 ." |
| 247 | (let* ((dir (expand-file-name "lisp" source-directory)) | 230 | (let* ((dir (expand-file-name "lisp" source-directory)) |
| @@ -258,44 +241,6 @@ | |||
| 258 | (should (cdr (dired-get-marked-files)))) | 241 | (should (cdr (dired-get-marked-files)))) |
| 259 | (when (buffer-live-p buf) (kill-buffer buf))))) | 242 | (when (buffer-live-p buf) (kill-buffer buf))))) |
| 260 | 243 | ||
| 261 | (ert-deftest dired-test-bug27762 () | ||
| 262 | "Test for http://debbugs.gnu.org/27762 ." | ||
| 263 | (require 'ls-lisp) | ||
| 264 | (let* ((dir source-directory) | ||
| 265 | (default-directory dir) | ||
| 266 | (files (mapcar (lambda (f) (concat "src/" f)) | ||
| 267 | (directory-files | ||
| 268 | (expand-file-name "src") nil "\\.*\\.c\\'"))) | ||
| 269 | ls-lisp-use-insert-directory-program buf) | ||
| 270 | (unwind-protect | ||
| 271 | (let ((file1 "src/cygw32.c") | ||
| 272 | (file2 "src/atimer.c")) | ||
| 273 | (setq buf (dired (nconc (list dir) files))) | ||
| 274 | (dired-goto-file (expand-file-name file2 default-directory)) | ||
| 275 | (should-not (looking-at "^ -")) ; Must be 2 spaces not 3. | ||
| 276 | (setq files (cons file1 (delete file1 files))) | ||
| 277 | (kill-buffer buf) | ||
| 278 | (setq buf (dired (nconc (list dir) files))) | ||
| 279 | (should (looking-at "src")) | ||
| 280 | (next-line) ; File names must be aligned. | ||
| 281 | (should (looking-at "src"))) | ||
| 282 | (unload-feature 'ls-lisp 'force) | ||
| 283 | (when (buffer-live-p buf) (kill-buffer buf))))) | ||
| 284 | |||
| 285 | (ert-deftest dired-test-bug27817 () | ||
| 286 | "Test for http://debbugs.gnu.org/27817 ." | ||
| 287 | (require 'em-ls) | ||
| 288 | (let ((orig eshell-ls-use-in-dired) | ||
| 289 | (dired-use-ls-dired 'unspecified) | ||
| 290 | buf insert-directory-program) | ||
| 291 | (unwind-protect | ||
| 292 | (progn | ||
| 293 | (customize-set-variable 'eshell-ls-use-in-dired t) | ||
| 294 | (should (setq buf (dired source-directory)))) | ||
| 295 | (customize-set-variable 'eshell-ls-use-in-dired orig) | ||
| 296 | (unload-feature 'em-ls 'force) | ||
| 297 | (and (buffer-live-p buf) (kill-buffer))))) | ||
| 298 | |||
| 299 | (ert-deftest dired-test-bug27631 () | 244 | (ert-deftest dired-test-bug27631 () |
| 300 | "Test for http://debbugs.gnu.org/27631 ." | 245 | "Test for http://debbugs.gnu.org/27631 ." |
| 301 | (let* ((dir (make-temp-file "bug27631" 'dir)) | 246 | (let* ((dir (make-temp-file "bug27631" 'dir)) |
| @@ -311,44 +256,10 @@ | |||
| 311 | (with-temp-file (expand-file-name "b.txt" dir2)) | 256 | (with-temp-file (expand-file-name "b.txt" dir2)) |
| 312 | (setq buf (dired (expand-file-name "dir*/*.txt" dir))) | 257 | (setq buf (dired (expand-file-name "dir*/*.txt" dir))) |
| 313 | (dired-toggle-marks) | 258 | (dired-toggle-marks) |
| 314 | (should (cdr (dired-get-marked-files))) | 259 | (should (cdr (dired-get-marked-files)))) |
| 315 | ;; Must work with ls-lisp ... | ||
| 316 | (require 'ls-lisp) | ||
| 317 | (kill-buffer buf) | ||
| 318 | (setq default-directory dir) | ||
| 319 | (let (ls-lisp-use-insert-directory-program) | ||
| 320 | (setq buf (dired (expand-file-name "dir*/*.txt" dir))) | ||
| 321 | (dired-toggle-marks) | ||
| 322 | (should (cdr (dired-get-marked-files)))) | ||
| 323 | ;; ... And with em-ls as well. | ||
| 324 | (kill-buffer buf) | ||
| 325 | (setq default-directory dir) | ||
| 326 | (unload-feature 'ls-lisp 'force) | ||
| 327 | (require 'em-ls) | ||
| 328 | (let ((orig eshell-ls-use-in-dired)) | ||
| 329 | (customize-set-value 'eshell-ls-use-in-dired t) | ||
| 330 | (setq buf (dired (expand-file-name "dir*/*.txt" dir))) | ||
| 331 | (dired-toggle-marks) | ||
| 332 | (should (cdr (dired-get-marked-files))))) | ||
| 333 | (unload-feature 'em-ls 'force) | ||
| 334 | (delete-directory dir 'recursive) | 260 | (delete-directory dir 'recursive) |
| 335 | (when (buffer-live-p buf) (kill-buffer buf))))) | 261 | (when (buffer-live-p buf) (kill-buffer buf))))) |
| 336 | 262 | ||
| 337 | (ert-deftest dired-test-bug27843 () | ||
| 338 | "Test for http://debbugs.gnu.org/27843 ." | ||
| 339 | (require 'em-ls) | ||
| 340 | (let ((orig eshell-ls-use-in-dired) | ||
| 341 | (dired-use-ls-dired 'unspecified) | ||
| 342 | buf insert-directory-program) | ||
| 343 | (unwind-protect | ||
| 344 | (progn | ||
| 345 | (customize-set-variable 'eshell-ls-use-in-dired t) | ||
| 346 | (setq buf (dired (list source-directory "lisp"))) | ||
| 347 | (dired-toggle-marks) | ||
| 348 | (should-not (cdr (dired-get-marked-files)))) | ||
| 349 | (customize-set-variable 'eshell-ls-use-in-dired orig) | ||
| 350 | (unload-feature 'em-ls 'force) | ||
| 351 | (and (buffer-live-p buf) (kill-buffer))))) | ||
| 352 | 263 | ||
| 353 | (provide 'dired-tests) | 264 | (provide 'dired-tests) |
| 354 | ;; dired-tests.el ends here | 265 | ;; dired-tests.el ends here |
diff --git a/test/lisp/eshell/em-ls-tests.el b/test/lisp/eshell/em-ls-tests.el new file mode 100644 index 00000000000..71a555d1eaf --- /dev/null +++ b/test/lisp/eshell/em-ls-tests.el | |||
| @@ -0,0 +1,80 @@ | |||
| 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 | (provide 'em-ls-test) | ||
| 79 | |||
| 80 | ;;; em-ls-tests.el ends here | ||
diff --git a/test/lisp/ls-lisp-tests.el b/test/lisp/ls-lisp-tests.el index 5ef7c78f4df..d24b30e5f22 100644 --- a/test/lisp/ls-lisp-tests.el +++ b/test/lisp/ls-lisp-tests.el | |||
| @@ -25,13 +25,70 @@ | |||
| 25 | 25 | ||
| 26 | ;;; Code: | 26 | ;;; Code: |
| 27 | (require 'ert) | 27 | (require 'ert) |
| 28 | (require 'ls-lisp) | ||
| 28 | 29 | ||
| 29 | (ert-deftest ls-lisp-unload () | 30 | (ert-deftest ls-lisp-unload () |
| 30 | "Test for http://debbugs.gnu.org/xxxxx ." | 31 | "Test for http://debbugs.gnu.org/xxxxx ." |
| 31 | (require 'ls-lisp) | ||
| 32 | (should (advice-member-p 'ls-lisp--insert-directory 'insert-directory)) | 32 | (should (advice-member-p 'ls-lisp--insert-directory 'insert-directory)) |
| 33 | (unload-feature 'ls-lisp 'force) | 33 | (unload-feature 'ls-lisp 'force) |
| 34 | (should-not (advice-member-p 'ls-lisp--insert-directory 'insert-directory))) | 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))))) | ||
| 35 | 92 | ||
| 36 | (provide 'ls-lisp-tests) | 93 | (provide 'ls-lisp-tests) |
| 37 | ;;; ls-lisp-tests.el ends here | 94 | ;;; ls-lisp-tests.el ends here |