aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp/net
diff options
context:
space:
mode:
authorMichael Albinus2019-02-19 14:00:17 +0100
committerMichael Albinus2019-02-19 14:00:17 +0100
commit0a6c4479cff17b487580abe3a7ee202e71be25d2 (patch)
tree8a24cd4d5742520afb9ef949da2b3f60eaf84d13 /test/lisp/net
parente8b6cc9a99374b135a3a71dabefcdf98fe2bc6e6 (diff)
downloademacs-0a6c4479cff17b487580abe3a7ee202e71be25d2.tar.gz
emacs-0a6c4479cff17b487580abe3a7ee202e71be25d2.zip
Implement access-file in Tramp
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): * lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist): * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): * lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist): * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist) * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist): Add `access-file'. * lisp/net/tramp-archive.el (tramp-archive-handle-access-file): * lisp/net/tramp.el (tramp-handle-access-file): New defun. (tramp-condition-case-unless-debug): Add declaration. (tramp-handle-insert-directory): * lisp/net/tramp-sh.el (tramp-sh-handle-insert-directory): * lisp/net/tramp-smb.el (tramp-smb-handle-insert-directory): Check, whether directory is accessible. * test/lisp/net/tramp-archive-tests.el (tramp-archive-test17-insert-directory) (tramp-archive-test18-file-attributes): * test/lisp/net/tramp-tests.el (tramp-test17-insert-directory) (tramp-test18-file-attributes): Test error cases.
Diffstat (limited to 'test/lisp/net')
-rw-r--r--test/lisp/net/tramp-archive-tests.el21
-rw-r--r--test/lisp/net/tramp-tests.el26
2 files changed, 39 insertions, 8 deletions
diff --git a/test/lisp/net/tramp-archive-tests.el b/test/lisp/net/tramp-archive-tests.el
index 1d9de39ae96..9f06ab1000c 100644
--- a/test/lisp/net/tramp-archive-tests.el
+++ b/test/lisp/net/tramp-archive-tests.el
@@ -570,26 +570,35 @@ This checks also `file-name-as-directory', `file-name-directory',
570 (format 570 (format
571 "\\(.+ %s\\( ->.+\\)?\n\\)\\{%d\\}" 571 "\\(.+ %s\\( ->.+\\)?\n\\)\\{%d\\}"
572 (regexp-opt (directory-files tramp-archive-test-archive)) 572 (regexp-opt (directory-files tramp-archive-test-archive))
573 (length (directory-files tramp-archive-test-archive)))))))) 573 (length (directory-files tramp-archive-test-archive)))))))
574
575 ;; Check error case.
576 (with-temp-buffer
577 (should-error
578 (insert-directory
579 (expand-file-name "baz" tramp-archive-test-archive) nil)
580 :type tramp-file-missing)))
574 581
575 ;; Cleanup. 582 ;; Cleanup.
576 (tramp-archive-cleanup-hash)))) 583 (tramp-archive-cleanup-hash))))
577 584
578(ert-deftest tramp-archive-test18-file-attributes () 585(ert-deftest tramp-archive-test18-file-attributes ()
579 "Check `file-attributes'. 586 "Check `file-attributes'.
580This tests also `file-readable-p' and `file-regular-p'." 587This tests also `access-file', `file-readable-p' and `file-regular-p'."
581 :tags '(:expensive-test) 588 :tags '(:expensive-test)
582 (skip-unless tramp-archive-enabled) 589 (skip-unless tramp-archive-enabled)
583 590
584 (let ((tmp-name1 (expand-file-name "foo.txt" tramp-archive-test-archive)) 591 (let ((tmp-name1 (expand-file-name "foo.txt" tramp-archive-test-archive))
585 (tmp-name2 (expand-file-name "foo.lnk" tramp-archive-test-archive)) 592 (tmp-name2 (expand-file-name "foo.lnk" tramp-archive-test-archive))
586 (tmp-name3 (expand-file-name "bar" tramp-archive-test-archive)) 593 (tmp-name3 (expand-file-name "bar" tramp-archive-test-archive))
594 (tmp-name4 (expand-file-name "baz" tramp-archive-test-archive))
587 attr) 595 attr)
588 (unwind-protect 596 (unwind-protect
589 (progn 597 (progn
590 (should (file-exists-p tmp-name1)) 598 (should (file-exists-p tmp-name1))
591 (should (file-readable-p tmp-name1)) 599 (should (file-readable-p tmp-name1))
592 (should (file-regular-p tmp-name1)) 600 (should (file-regular-p tmp-name1))
601 (should-not (access-file tmp-name1 "error"))
593 602
594 ;; We do not test inodes and device numbers. 603 ;; We do not test inodes and device numbers.
595 (setq attr (file-attributes tmp-name1)) 604 (setq attr (file-attributes tmp-name1))
@@ -622,7 +631,13 @@ This tests also `file-readable-p' and `file-regular-p'."
622 (should (file-readable-p tmp-name3)) 631 (should (file-readable-p tmp-name3))
623 (should-not (file-regular-p tmp-name3)) 632 (should-not (file-regular-p tmp-name3))
624 (setq attr (file-attributes tmp-name3)) 633 (setq attr (file-attributes tmp-name3))
625 (should (eq (car attr) t))) 634 (should (eq (car attr) t))
635 (should-not (access-file tmp-name3 "error"))
636
637 ;; Check error case.
638 (should-error
639 (access-file tmp-name4 "error")
640 :type tramp-file-missing))
626 641
627 ;; Cleanup. 642 ;; Cleanup.
628 (tramp-archive-cleanup-hash)))) 643 (tramp-archive-cleanup-hash))))
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 3eb424c62dc..3afe9ad557d 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -2730,7 +2730,14 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
2730 (format 2730 (format
2731 "\\(.+ %s\\( ->.+\\)?\n\\)\\{%d\\}" 2731 "\\(.+ %s\\( ->.+\\)?\n\\)\\{%d\\}"
2732 (regexp-opt (directory-files tmp-name1)) 2732 (regexp-opt (directory-files tmp-name1))
2733 (length (directory-files tmp-name1)))))))) 2733 (length (directory-files tmp-name1)))))))
2734
2735 ;; Check error case. We do not check for the error type,
2736 ;; because ls-lisp returns `file-error', and native Tramp
2737 ;; returns `file-missing'.
2738 (delete-directory tmp-name1 'recursive)
2739 (with-temp-buffer
2740 (should-error (insert-directory tmp-name1 nil))))
2734 2741
2735 ;; Cleanup. 2742 ;; Cleanup.
2736 (ignore-errors (delete-directory tmp-name1 'recursive)))))) 2743 (ignore-errors (delete-directory tmp-name1 'recursive))))))
@@ -2856,8 +2863,8 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
2856 2863
2857(ert-deftest tramp-test18-file-attributes () 2864(ert-deftest tramp-test18-file-attributes ()
2858 "Check `file-attributes'. 2865 "Check `file-attributes'.
2859This tests also `file-readable-p', `file-regular-p' and 2866This tests also `access-file', `file-readable-p',
2860`file-ownership-preserved-p'." 2867`file-regular-p' and `file-ownership-preserved-p'."
2861 (skip-unless (tramp--test-enabled)) 2868 (skip-unless (tramp--test-enabled))
2862 2869
2863 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil))) 2870 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
@@ -2878,6 +2885,9 @@ This tests also `file-readable-p', `file-regular-p' and
2878 attr) 2885 attr)
2879 (unwind-protect 2886 (unwind-protect
2880 (progn 2887 (progn
2888 (should-error
2889 (access-file tmp-name1 "error")
2890 :type tramp-file-missing)
2881 ;; `file-ownership-preserved-p' should return t for 2891 ;; `file-ownership-preserved-p' should return t for
2882 ;; non-existing files. It is implemented only in tramp-sh.el. 2892 ;; non-existing files. It is implemented only in tramp-sh.el.
2883 (when (tramp--test-sh-p) 2893 (when (tramp--test-sh-p)
@@ -2886,6 +2896,7 @@ This tests also `file-readable-p', `file-regular-p' and
2886 (should (file-exists-p tmp-name1)) 2896 (should (file-exists-p tmp-name1))
2887 (should (file-readable-p tmp-name1)) 2897 (should (file-readable-p tmp-name1))
2888 (should (file-regular-p tmp-name1)) 2898 (should (file-regular-p tmp-name1))
2899 (should-not (access-file tmp-name1 "error"))
2889 (when (tramp--test-sh-p) 2900 (when (tramp--test-sh-p)
2890 (should (file-ownership-preserved-p tmp-name1 'group))) 2901 (should (file-ownership-preserved-p tmp-name1 'group)))
2891 2902
@@ -2910,11 +2921,15 @@ This tests also `file-readable-p', `file-regular-p' and
2910 (should (stringp (nth 3 attr))) ;; Gid. 2921 (should (stringp (nth 3 attr))) ;; Gid.
2911 2922
2912 (tramp--test-ignore-make-symbolic-link-error 2923 (tramp--test-ignore-make-symbolic-link-error
2924 (should-error
2925 (access-file tmp-name2 "error")
2926 :type tramp-file-missing)
2913 (when (tramp--test-sh-p) 2927 (when (tramp--test-sh-p)
2914 (should (file-ownership-preserved-p tmp-name2 'group))) 2928 (should (file-ownership-preserved-p tmp-name2 'group)))
2915 (make-symbolic-link tmp-name1 tmp-name2) 2929 (make-symbolic-link tmp-name1 tmp-name2)
2916 (should (file-exists-p tmp-name2)) 2930 (should (file-exists-p tmp-name2))
2917 (should (file-symlink-p tmp-name2)) 2931 (should (file-symlink-p tmp-name2))
2932 (should-not (access-file tmp-name2 "error"))
2918 (when (tramp--test-sh-p) 2933 (when (tramp--test-sh-p)
2919 (should (file-ownership-preserved-p tmp-name2 'group))) 2934 (should (file-ownership-preserved-p tmp-name2 'group)))
2920 (setq attr (file-attributes tmp-name2)) 2935 (setq attr (file-attributes tmp-name2))
@@ -2953,6 +2968,7 @@ This tests also `file-readable-p', `file-regular-p' and
2953 (should (file-exists-p tmp-name1)) 2968 (should (file-exists-p tmp-name1))
2954 (should (file-readable-p tmp-name1)) 2969 (should (file-readable-p tmp-name1))
2955 (should-not (file-regular-p tmp-name1)) 2970 (should-not (file-regular-p tmp-name1))
2971 (should-not (access-file tmp-name1 ""))
2956 (when (tramp--test-sh-p) 2972 (when (tramp--test-sh-p)
2957 (should (file-ownership-preserved-p tmp-name1 'group))) 2973 (should (file-ownership-preserved-p tmp-name1 'group)))
2958 (setq attr (file-attributes tmp-name1)) 2974 (setq attr (file-attributes tmp-name1))
@@ -5590,8 +5606,8 @@ Since it unloads Tramp, it shall be the last test to run."
5590;; * Fix `tramp-test06-directory-file-name' for `ftp'. 5606;; * Fix `tramp-test06-directory-file-name' for `ftp'.
5591;; * Investigate, why `tramp-test11-copy-file' and `tramp-test12-rename-file' 5607;; * Investigate, why `tramp-test11-copy-file' and `tramp-test12-rename-file'
5592;; do not work properly for `nextcloud'. 5608;; do not work properly for `nextcloud'.
5593;; * Fix `tramp-test29-start-file-process' on MS Windows (`process-send-eof'?). 5609;; * Fix `tramp-test29-start-file-process' and
5594;; * Fix `tramp-test31-interrupt-process', timeout doesn't work reliably. 5610;; `tramp-test30-make-process' on MS Windows (`process-send-eof'?).
5595;; * Fix Bug#16928 in `tramp-test43-asynchronous-requests'. 5611;; * Fix Bug#16928 in `tramp-test43-asynchronous-requests'.
5596 5612
5597(provide 'tramp-tests) 5613(provide 'tramp-tests)