1 ;;; ls-lisp-tests.el --- tests for ls-lisp.el -*- lexical-binding: t-*-
3 ;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
5 ;; Author: Tino Calancha <tino.calancha@gmail.com>
8 ;; This file is part of GNU Emacs.
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.
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.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
30 (ert-deftest ls-lisp-unload
()
31 "Test for https://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
))
37 (ert-deftest ls-lisp-test-bug27762
()
38 "Test for https://debbugs.gnu.org/27762 ."
39 (let* ((dir source-directory
)
40 (default-directory dir
)
41 (files (mapcar (lambda (f) (concat "src/" f
))
43 (expand-file-name "src") nil
"\\.*\\.c\\'")))
44 ls-lisp-use-insert-directory-program buf
)
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
)))
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
)))))
59 (ert-deftest ls-lisp-test-bug27631
()
60 "Test for https://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
)
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
)))
74 (should (cdr (dired-get-marked-files))))
75 (delete-directory dir
'recursive
)
76 (when (buffer-live-p buf
) (kill-buffer buf
)))))
78 (ert-deftest ls-lisp-test-bug27693
()
79 "Test for https://debbugs.gnu.org/27693 ."
80 (let ((dir (expand-file-name "lisp" source-directory
))
82 ls-lisp-use-insert-directory-program buf
)
85 (setq buf
(dired (list dir
"simple.el" "subr.el"))
86 size
(number-to-string
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
)))))
93 (provide 'ls-lisp-tests
)
94 ;;; ls-lisp-tests.el ends here