Add tests for secrets.el
[emacs.git] / test / lisp / ls-lisp-tests.el
blob91e8b0b7011cab59f5588aee571a9025c618523b
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>
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)
29 (require 'dired)
31 (ert-deftest ls-lisp-unload ()
32 "Test for https://debbugs.gnu.org/xxxxx ."
33 (should (advice-member-p 'ls-lisp--insert-directory 'insert-directory))
34 (unload-feature 'ls-lisp 'force)
35 (should-not (advice-member-p 'ls-lisp--insert-directory 'insert-directory))
36 (require 'ls-lisp))
38 (ert-deftest ls-lisp-test-bug27762 ()
39 "Test for https://debbugs.gnu.org/27762 ."
40 (let* ((dir source-directory)
41 (default-directory dir)
42 (files (mapcar (lambda (f) (concat "src/" f))
43 (directory-files
44 (expand-file-name "src") nil "\\.*\\.c\\'")))
45 ls-lisp-use-insert-directory-program buf)
46 (unwind-protect
47 (let ((file1 "src/cygw32.c")
48 (file2 "src/atimer.c"))
49 (setq buf (dired (nconc (list dir) files)))
50 (dired-goto-file (expand-file-name file2 default-directory))
51 (should-not (looking-at "^ -")) ; Must be 2 spaces not 3.
52 (setq files (cons file1 (delete file1 files)))
53 (kill-buffer buf)
54 (setq buf (dired (nconc (list dir) files)))
55 (should (looking-at "src"))
56 (next-line) ; File names must be aligned.
57 (should (looking-at "src")))
58 (when (buffer-live-p buf) (kill-buffer buf)))))
60 (ert-deftest ls-lisp-test-bug27631 ()
61 "Test for https://debbugs.gnu.org/27631 ."
62 (let* ((dir (make-temp-file "bug27631" 'dir))
63 (dir1 (expand-file-name "dir1" dir))
64 (dir2 (expand-file-name "dir2" dir))
65 (default-directory dir)
66 ls-lisp-use-insert-directory-program buf)
67 (unwind-protect
68 (progn
69 (make-directory dir1)
70 (make-directory dir2)
71 (with-temp-file (expand-file-name "a.txt" dir1))
72 (with-temp-file (expand-file-name "b.txt" dir2))
73 (setq buf (dired (expand-file-name "dir*/*.txt" dir)))
74 (dired-toggle-marks)
75 (should (cdr (dired-get-marked-files))))
76 (delete-directory dir 'recursive)
77 (when (buffer-live-p buf) (kill-buffer buf)))))
79 (ert-deftest ls-lisp-test-bug27693 ()
80 "Test for https://debbugs.gnu.org/27693 ."
81 (let ((dir (expand-file-name "lisp" source-directory))
82 (size "")
83 ls-lisp-use-insert-directory-program buf)
84 (unwind-protect
85 (progn
86 (setq buf (dired (list dir "simple.el" "subr.el"))
87 size (number-to-string
88 (file-attribute-size
89 (file-attributes (dired-get-filename)))))
90 (search-backward-regexp size nil t)
91 (should (looking-back "[[:space:]]" (1- (point)))))
92 (when (buffer-live-p buf) (kill-buffer buf)))))
94 (provide 'ls-lisp-tests)
95 ;;; ls-lisp-tests.el ends here