unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
blob 3b739e59cc4a67982127fbb4326eb2b50f805acd 3908 bytes (raw)
name: test/src/dired-tests.el 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
 
;;; dired-tests.el --- Tests for directory-files in dired.c  -*- lexical-binding: t; -*-

;; Copyright (C) 2015-2020 Free Software Foundation, Inc.

;; Author: Arthur Miller <arthur.miller@live.com>
;; Keywords:

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;;

;;; Code:
(require 'ert)

(ert-deftest directory-files-tests ()
  (let ((name (expand-file-name "directory-files-test"
                                (temporary-file-directory)))
        ;; nodots expression from dired+ by Drew A.
        (nodots "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"))

    (message name)
    (when (file-directory-p name)
      (delete-directory name t))
    (make-directory name)
    (when (file-directory-p name)
      (should (= 2 (length (directory-files name))))
      (should-not (directory-files name nil nodots t 1))
      (dolist (file '(a b c d))
        (make-empty-file (expand-file-name (symbol-name file) name)))
      (should (= 6 (length (directory-files name))))
      (should (equal "abcd" (string-join (directory-files name nil
                                                          nodots) "")))
      (should (= 2 (length (directory-files name nil "[bc]"))))
      (should (= 3 (length (directory-files name nil nodots nil 3))))
      (dolist (file '(5 4 3 2 1))
        (make-empty-file (expand-file-name (number-to-string file) name)))
      (should (= 0 (length (directory-files name nil "[0-9]" t -1))))
      (should (= 5 (length (directory-files name nil "[0-9]" t))))
      (should (= 5 (length (directory-files name nil "[0-9]" t 50))))
  )))

(ert-deftest directory-files-and-attributes-tests ()
  (let ((name (expand-file-name "directory-files-test"
                                (temporary-file-directory)))
        ;; nodots expression from dired+ by Drew A.
        (nodots "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"))

    (message name)
    (when (file-directory-p name)
      (delete-directory name t))
    (make-directory name)
    (when (file-directory-p name)
      (should (= 2 (length (directory-files name))))
      (should-not (directory-files-and-attributes name t nodots t 1))
      (dolist (file '(a b c d))
        (make-directory (expand-file-name (symbol-name file) name)))
      (should (= 6 (length (directory-files-and-attributes name))))
      (dolist (dir (directory-files-and-attributes name t nodots))
        (should (file-directory-p (car dir)))
        (should-not (file-regular-p (car dir))))
      (should (= 2 (length
                    (directory-files-and-attributes name nil "[bc]"))))
      (should (= 3 (length
                    (directory-files-and-attributes name nil nodots
                                                    nil nil 3))))
      (dolist (file '(5 4 3 2 1))
        (make-empty-file (expand-file-name (number-to-string file) name)))
      (should (= 0 (length
                    (directory-files-and-attributes name nil
                                                    "[0-9]" t 1 -1))))
      (should (= 5 (length
                    (directory-files-and-attributes name nil "[0-9]" t))))
      (should (= 5 (length
                    (directory-files-and-attributes name nil
                                                    "[0-9]" t nil 50))))
      )))

(provide 'dired-tests)
;;; dired-tests.el ends here

debug log:

solving 3b739e59cc ...
found 3b739e59cc in https://yhetil.org/emacs-devel/VI1PR06MB45261F3309D31EC7DEDE4C8B96000@VI1PR06MB4526.eurprd06.prod.outlook.com/

applying [1/1] https://yhetil.org/emacs-devel/VI1PR06MB45261F3309D31EC7DEDE4C8B96000@VI1PR06MB4526.eurprd06.prod.outlook.com/
diff --git a/test/src/dired-tests.el b/test/src/dired-tests.el
new file mode 100644
index 0000000000..3b739e59cc

Checking patch test/src/dired-tests.el...
Applied patch test/src/dired-tests.el cleanly.

index at:
100644 3b739e59cc4a67982127fbb4326eb2b50f805acd	test/src/dired-tests.el

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).