diff options
| author | Jim Porter | 2023-03-04 22:11:23 -0800 |
|---|---|---|
| committer | Jim Porter | 2024-01-27 22:21:23 -0800 |
| commit | a3cd284b90edcc7e06b21110cdbf55d11fb6fd0d (patch) | |
| tree | 3fc7c170c6fc0e025f97e0ef136e4aa1e9c68f63 /test/lisp/eshell/em-basic-tests.el | |
| parent | 236317e5d2284399d6ca0413ea2a29b84270d545 (diff) | |
| download | emacs-a3cd284b90edcc7e06b21110cdbf55d11fb6fd0d.tar.gz emacs-a3cd284b90edcc7e06b21110cdbf55d11fb6fd0d.zip | |
Support setting umask symbolically in Eshell
* lisp/eshell/em-basic.el (eshell/umask): Handle setting umask
symbolically, and make setting umask take precedence over "-S".
* test/lisp/eshell/em-basic-tests.el
(em-basic-test/umask-print-numeric, em-basic-test/umask-read-symbolic,
em-basic-test/umask-set): Rename to...
(em-basic-test/umask/print-numeric)
(em-basic-test/umask/print-symbolic, em-basic-test/umask/set-numeric):
... these.
(em-basic-test/umask/set-symbolic, em-basic-test/umask/set-with-S):
New tests.
* etc/NEWS: Announce this change.
Diffstat (limited to 'test/lisp/eshell/em-basic-tests.el')
| -rw-r--r-- | test/lisp/eshell/em-basic-tests.el | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/test/lisp/eshell/em-basic-tests.el b/test/lisp/eshell/em-basic-tests.el index 960e04690a5..ebb91cdeea0 100644 --- a/test/lisp/eshell/em-basic-tests.el +++ b/test/lisp/eshell/em-basic-tests.el | |||
| @@ -33,7 +33,7 @@ | |||
| 33 | 33 | ||
| 34 | ;;; Tests: | 34 | ;;; Tests: |
| 35 | 35 | ||
| 36 | (ert-deftest em-basic-test/umask-print-numeric () | 36 | (ert-deftest em-basic-test/umask/print-numeric () |
| 37 | "Test printing umask numerically." | 37 | "Test printing umask numerically." |
| 38 | (cl-letf (((symbol-function 'default-file-modes) (lambda () #o775))) | 38 | (cl-letf (((symbol-function 'default-file-modes) (lambda () #o775))) |
| 39 | (eshell-command-result-equal "umask" "002\n")) | 39 | (eshell-command-result-equal "umask" "002\n")) |
| @@ -43,7 +43,7 @@ | |||
| 43 | (cl-letf (((symbol-function 'default-file-modes) (lambda () #o1775))) | 43 | (cl-letf (((symbol-function 'default-file-modes) (lambda () #o1775))) |
| 44 | (eshell-command-result-equal "umask" "002\n"))) | 44 | (eshell-command-result-equal "umask" "002\n"))) |
| 45 | 45 | ||
| 46 | (ert-deftest em-basic-test/umask-read-symbolic () | 46 | (ert-deftest em-basic-test/umask/print-symbolic () |
| 47 | "Test printing umask symbolically." | 47 | "Test printing umask symbolically." |
| 48 | (cl-letf (((symbol-function 'default-file-modes) (lambda () #o775))) | 48 | (cl-letf (((symbol-function 'default-file-modes) (lambda () #o775))) |
| 49 | (eshell-command-result-equal "umask -S" | 49 | (eshell-command-result-equal "umask -S" |
| @@ -56,8 +56,8 @@ | |||
| 56 | (eshell-command-result-equal "umask -S" | 56 | (eshell-command-result-equal "umask -S" |
| 57 | "u=rwx,g=rwx,o=rx\n"))) | 57 | "u=rwx,g=rwx,o=rx\n"))) |
| 58 | 58 | ||
| 59 | (ert-deftest em-basic-test/umask-set () | 59 | (ert-deftest em-basic-test/umask/set-numeric () |
| 60 | "Test setting umask." | 60 | "Test setting umask numerically." |
| 61 | (let ((file-modes 0)) | 61 | (let ((file-modes 0)) |
| 62 | (cl-letf (((symbol-function 'set-default-file-modes) | 62 | (cl-letf (((symbol-function 'set-default-file-modes) |
| 63 | (lambda (mode) (setq file-modes mode)))) | 63 | (lambda (mode) (setq file-modes mode)))) |
| @@ -68,4 +68,30 @@ | |||
| 68 | (eshell-test-command-result "umask $(identity #o222)") | 68 | (eshell-test-command-result "umask $(identity #o222)") |
| 69 | (should (= file-modes #o555))))) | 69 | (should (= file-modes #o555))))) |
| 70 | 70 | ||
| 71 | (ert-deftest em-basic-test/umask/set-symbolic () | ||
| 72 | "Test setting umask symbolically." | ||
| 73 | (let ((file-modes 0)) | ||
| 74 | (cl-letf (((symbol-function 'default-file-modes) | ||
| 75 | (lambda() file-modes)) | ||
| 76 | ((symbol-function 'set-default-file-modes) | ||
| 77 | (lambda (mode) (setq file-modes mode)))) | ||
| 78 | (eshell-test-command-result "umask u=rwx,g=rwx,o=rx") | ||
| 79 | (should (= file-modes #o775)) | ||
| 80 | (eshell-test-command-result "umask u=rw,g=rx,o=x") | ||
| 81 | (should (= file-modes #o651)) | ||
| 82 | (eshell-test-command-result "umask u+x,o-x") | ||
| 83 | (should (= file-modes #o750)) | ||
| 84 | (eshell-test-command-result "umask a+rx") | ||
| 85 | (should (= file-modes #o755))))) | ||
| 86 | |||
| 87 | (ert-deftest em-basic-test/umask/set-with-S () | ||
| 88 | "Test that passing \"-S\" and a umask still sets the umask." | ||
| 89 | (let ((file-modes 0)) | ||
| 90 | (cl-letf (((symbol-function 'set-default-file-modes) | ||
| 91 | (lambda (mode) (setq file-modes mode)))) | ||
| 92 | (eshell-test-command-result "umask -S 002") | ||
| 93 | (should (= file-modes #o775)) | ||
| 94 | (eshell-test-command-result "umask -S 123") | ||
| 95 | (should (= file-modes #o654))))) | ||
| 96 | |||
| 71 | ;; em-basic-tests.el ends here | 97 | ;; em-basic-tests.el ends here |