5050(require 'vc-hg)
5151
5252(declare-function tramp-find-executable "tramp-sh")
53+ (declare-function tramp-get-remote-gid "tramp-sh")
5354(declare-function tramp-get-remote-path "tramp-sh")
5455(declare-function tramp-get-remote-perl "tramp-sh")
5556(declare-function tramp-get-remote-stat "tramp-sh")
@@ -3113,22 +3114,38 @@ This tests also `access-file', `file-readable-p',
31133114 (file-remote-p tmp-name1)
31143115 (replace-regexp-in-string
31153116 "/" "//" (file-remote-p tmp-name1 'localname))))
3117+ ;; `file-ownership-preserved-p' is implemented only in tramp-sh.el.
3118+ (test-file-ownership-preserved-p (tramp--test-sh-p))
31163119 attr)
31173120 (unwind-protect
31183121 (progn
3122+ ;; A sticky bit could damage the `file-ownership-preserved-p' test.
3123+ (when
3124+ (and test-file-ownership-preserved-p
3125+ (zerop (logand
3126+ #o1000
3127+ (file-modes tramp-test-temporary-file-directory))))
3128+ (write-region "foo" nil tmp-name1)
3129+ (setq test-file-ownership-preserved-p
3130+ (= (tramp-compat-file-attribute-group-id
3131+ (file-attributes tmp-name1))
3132+ (tramp-get-remote-gid
3133+ (tramp-dissect-file-name tmp-name1) 'integer)))
3134+ (delete-file tmp-name1))
3135+
31193136 (should-error
31203137 (access-file tmp-name1 "error")
31213138 :type tramp-file-missing)
31223139 ;; `file-ownership-preserved-p' should return t for
3123- ;; non-existing files. It is implemented only in tramp-sh.el.
3124- (when (tramp--test-sh-p)
3140+ ;; non-existing files.
3141+ (when test-file-ownership-preserved-p
31253142 (should (file-ownership-preserved-p tmp-name1 'group)))
31263143 (write-region "foo" nil tmp-name1)
31273144 (should (file-exists-p tmp-name1))
31283145 (should (file-readable-p tmp-name1))
31293146 (should (file-regular-p tmp-name1))
31303147 (should-not (access-file tmp-name1 "error"))
3131- (when (tramp--test-sh-p)
3148+ (when test-file-ownership-preserved-p
31323149 (should (file-ownership-preserved-p tmp-name1 'group)))
31333150
31343151 ;; We do not test inodes and device numbers.
@@ -3158,16 +3175,16 @@ This tests also `access-file', `file-readable-p',
31583175 (should (stringp (tramp-compat-file-attribute-group-id attr)))
31593176
31603177 (tramp--test-ignore-make-symbolic-link-error
3161- (should-error
3162- (access-file tmp-name2 "error")
3163- :type tramp-file-missing)
3164- (when (tramp--test-sh-p)
3178+ (should-error
3179+ (access-file tmp-name2 "error")
3180+ :type tramp-file-missing)
3181+ (when test-file-ownership-preserved-p
31653182 (should (file-ownership-preserved-p tmp-name2 'group)))
31663183 (make-symbolic-link tmp-name1 tmp-name2)
31673184 (should (file-exists-p tmp-name2))
31683185 (should (file-symlink-p tmp-name2))
31693186 (should-not (access-file tmp-name2 "error"))
3170- (when (tramp--test-sh-p)
3187+ (when test-file-ownership-preserved-p
31713188 (should (file-ownership-preserved-p tmp-name2 'group)))
31723189 (setq attr (file-attributes tmp-name2))
31733190 (should
@@ -3198,15 +3215,15 @@ This tests also `access-file', `file-readable-p',
31983215 (tramp-dissect-file-name tmp-name3))))
31993216 (delete-file tmp-name2))
32003217
3201- (when (tramp--test-sh-p)
3218+ (when test-file-ownership-preserved-p
32023219 (should (file-ownership-preserved-p tmp-name1 'group)))
32033220 (delete-file tmp-name1)
32043221 (make-directory tmp-name1)
32053222 (should (file-exists-p tmp-name1))
32063223 (should (file-readable-p tmp-name1))
32073224 (should-not (file-regular-p tmp-name1))
32083225 (should-not (access-file tmp-name1 ""))
3209- (when (tramp--test-sh-p)
3226+ (when test-file-ownership-preserved-p
32103227 (should (file-ownership-preserved-p tmp-name1 'group)))
32113228 (setq attr (file-attributes tmp-name1))
32123229 (should (eq (tramp-compat-file-attribute-type attr) t)))
@@ -4357,7 +4374,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
43574374 (with-no-warnings
43584375 (make-process
43594376 :name "test5" :buffer (current-buffer)
4360- :command '("cat" "/")
4377+ :command '("cat" "/does-not-exist ")
43614378 :stderr stderr
43624379 :file-handler t)))
43634380 (should (processp proc))
@@ -4367,7 +4384,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
43674384 (delete-process proc)
43684385 (with-current-buffer stderr
43694386 (should
4370- (string-match "cat:.* Is a directory" (buffer-string)))))
4387+ (string-match
4388+ "cat:.* No such file or directory" (buffer-string)))))
43714389
43724390 ;; Cleanup.
43734391 (ignore-errors (delete-process proc))
@@ -4381,7 +4399,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
43814399 (with-no-warnings
43824400 (make-process
43834401 :name "test6" :buffer (current-buffer)
4384- :command '("cat" "/")
4402+ :command '("cat" "/does-not-exist ")
43854403 :stderr tmpfile
43864404 :file-handler t)))
43874405 (should (processp proc))
@@ -4392,7 +4410,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
43924410 (with-temp-buffer
43934411 (insert-file-contents tmpfile)
43944412 (should
4395- (string-match "cat:.* Is a directory" (buffer-string)))))
4413+ (string-match
4414+ "cat:.* No such file or directory" (buffer-string)))))
43964415
43974416 ;; Cleanup.
43984417 (ignore-errors (delete-process proc))
0 commit comments