aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp/eshell/em-basic-tests.el
diff options
context:
space:
mode:
authorJim Porter2022-03-26 15:09:51 -0700
committerLars Ingebrigtsen2022-03-29 16:50:45 +0200
commit705de330725715c355b63cf49d56aa13132a5f3c (patch)
tree9685f8d6afed69fbb24205b1a2da2b6b007625b9 /test/lisp/eshell/em-basic-tests.el
parent271c03d89f3b1f67b44a46ee43447e25f5eef1a8 (diff)
downloademacs-705de330725715c355b63cf49d56aa13132a5f3c.tar.gz
emacs-705de330725715c355b63cf49d56aa13132a5f3c.zip
Add tests for Eshell's umask command
'em-basic-test/umask-set' fails when passing an actual number to the command, but this is fixed in the subsequent commit. test/lisp/eshell/em-basic-tests.el: New file.
Diffstat (limited to 'test/lisp/eshell/em-basic-tests.el')
-rw-r--r--test/lisp/eshell/em-basic-tests.el71
1 files changed, 71 insertions, 0 deletions
diff --git a/test/lisp/eshell/em-basic-tests.el b/test/lisp/eshell/em-basic-tests.el
new file mode 100644
index 00000000000..7a24f8b46c3
--- /dev/null
+++ b/test/lisp/eshell/em-basic-tests.el
@@ -0,0 +1,71 @@
1;;; em-basic-tests.el --- em-basic test suite -*- lexical-binding:t -*-
2
3;; Copyright (C) 2022 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; GNU Emacs is free software: you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
19
20;;; Commentary:
21
22;; Tests for basic Eshell commands.
23
24;;; Code:
25
26(require 'ert)
27(require 'em-basic)
28
29(require 'eshell-tests-helpers
30 (expand-file-name "eshell-tests-helpers"
31 (file-name-directory (or load-file-name
32 default-directory))))
33
34;;; Tests:
35
36(ert-deftest em-basic-test/umask-print-numeric ()
37 "Test printing umask numerically."
38 (cl-letf (((symbol-function 'default-file-modes) (lambda () #o775)))
39 (should (equal (eshell-test-command-result "umask") "002\n")))
40 (cl-letf (((symbol-function 'default-file-modes) (lambda () #o654)))
41 (should (equal (eshell-test-command-result "umask") "123\n")))
42 ;; Make sure larger numbers don't cause problems.
43 (cl-letf (((symbol-function 'default-file-modes) (lambda () #o1775)))
44 (should (equal (eshell-test-command-result "umask") "002\n"))))
45
46(ert-deftest em-basic-test/umask-read-symbolic ()
47 "Test printing umask symbolically."
48 (cl-letf (((symbol-function 'default-file-modes) (lambda () #o775)))
49 (should (equal (eshell-test-command-result "umask -S")
50 "u=rwx,g=rwx,o=rx\n")))
51 (cl-letf (((symbol-function 'default-file-modes) (lambda () #o654)))
52 (should (equal (eshell-test-command-result "umask -S")
53 "u=wx,g=rx,o=x\n")))
54 ;; Make sure larger numbers don't cause problems.
55 (cl-letf (((symbol-function 'default-file-modes) (lambda () #o1775)))
56 (should (equal (eshell-test-command-result "umask -S")
57 "u=rwx,g=rwx,o=rx\n"))))
58
59(ert-deftest em-basic-test/umask-set ()
60 "Test setting umask."
61 (let ((file-modes 0))
62 (cl-letf (((symbol-function 'set-default-file-modes)
63 (lambda (mode) (setq file-modes mode))))
64 (eshell-test-command-result "umask 002")
65 (should (= file-modes #o775))
66 (eshell-test-command-result "umask 123")
67 (should (= file-modes #o654))
68 (eshell-test-command-result "umask $(identity #o222)")
69 (should (= file-modes #o555)))))
70
71;; em-basic-tests.el ends here