From 2fffc1dfdff0a37f826a67d90d8a97091207dcb2 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Tue, 3 Nov 2020 18:47:32 +0100 Subject: Some Tramp fixes for directory-files-* and delete-* * lisp/files.el (delete-directory): Simplify check for trash. * lisp/net/ange-ftp.el (ange-ftp-delete-file): Implement TRASH. * lisp/net/tramp-compat.el (tramp-compat-directory-files) (tramp-compat-directory-files-and-attributes) (tramp-compat-directory-empty-p): New defaliases. * lisp/net/tramp.el (tramp-handle-directory-files-and-attributes) (tramp-skeleton-delete-directory): * lisp/net/tramp-gvfs.el (tramp-gvfs-handle-delete-directory): Use them. * lisp/net/tramp-sh.el (tramp-sh-handle-directory-files-and-attributes): Implement COUNT. * test/lisp/net/tramp-tests.el (tramp-test14-delete-directory): Do not run trash test for ange-ftp. (tramp-test16-directory-files) (tramp-test19-directory-files-and-attributes): Check COUNT argument. --- test/lisp/net/tramp-tests.el | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 50db55ebb4f..2670723ecdc 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -2783,8 +2783,9 @@ This tests also `file-directory-p' and `file-accessible-directory-p'." (should-not (file-directory-p tmp-name1)) ;; Trashing directories works only since Emacs 27.1. It doesn't - ;; work for crypted remote directories. - (when (and (not (tramp--test-crypt-p)) (tramp--test-emacs27-p)) + ;; work for crypted remote directories and for ange-ftp. + (when (and (not (tramp--test-crypt-p)) (not (tramp--test-ftp-p)) + (tramp--test-emacs27-p)) (let ((trash-directory (tramp--test-make-temp-name 'local quoted)) (delete-by-moving-to-trash t)) (make-directory trash-directory) @@ -2925,7 +2926,15 @@ This tests also `file-directory-p' and `file-accessible-directory-p'." '("bla" "foo"))) (should (equal (directory-files tmp-name1 'full directory-files-no-dot-files-regexp) - `(,tmp-name2 ,tmp-name3)))) + `(,tmp-name2 ,tmp-name3))) + ;; Check the COUNT arg. It exists since Emacs 28. + (when (tramp--test-emacs28-p) + (with-no-warnings + (should + (= 1 (length + (directory-files + tmp-name1 nil directory-files-no-dot-files-regexp + nil 1))))))) ;; Cleanup. (ignore-errors (delete-directory tmp-name1 'recursive)))))) @@ -3443,7 +3452,13 @@ They might differ only in time attributes or directory size." (file-attributes (car elt)) (cdr elt)))) (setq attr (directory-files-and-attributes tmp-name2 nil "\\`b")) - (should (equal (mapcar #'car attr) '("bar" "boz")))) + (should (equal (mapcar #'car attr) '("bar" "boz"))) + + ;; Check the COUNT arg. It exists since Emacs 28. + (when (tramp--test-emacs28-p) + (with-no-warnings + (should (= 1 (length (directory-files-and-attributes + tmp-name2 nil "\\`b" nil nil 1))))))) ;; Cleanup. (ignore-errors (delete-directory tmp-name1 'recursive)))))) -- cgit v1.2.1