* test/lisp/net/tramp-tests.el (tramp-test41-delay-load): New test.
[emacs.git] / test / lisp / ls-lisp-tests.el
blob8e419d59bf4280541e0b94f2518f4253a335f9f9
1 ;;; ls-lisp-tests.el --- tests for ls-lisp.el -*- lexical-binding: t-*-
3 ;; Copyright (C) 2017 Free Software Foundation, Inc.
5 ;; Author: Tino Calancha <tino.calancha@gmail.com>
6 ;; Keywords:
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/>.
23 ;;; Commentary:
26 ;;; Code:
27 (require 'ert)
28 (require 'ls-lisp)
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))
35 (require 'ls-lisp))
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))
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)))))
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)
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)))))
78 (ert-deftest ls-lisp-test-bug27693 ()
79 "Test for https://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)))))
93 (provide 'ls-lisp-tests)
94 ;;; ls-lisp-tests.el ends here