Fix problem in `shadow-define-literal-group' (Bug#49596)

* lisp/shadowfile.el (shadow-make-fullname): HOST can also be a
remote file name.  Bug#49596.

* test/lisp/shadowfile-tests.el (auth-source-save-behavior)
(tramp-cache-read-persistent-data, tramp-persistency-file-name):
Set them globally.
(shadow-test06-literal-groups): Extend test.
This commit is contained in:
Michael Albinus 2021-07-18 15:57:41 +02:00
parent c112f73668
commit 12a193f876
2 changed files with 17 additions and 6 deletions

View file

@ -284,9 +284,13 @@ Argument can be a simple name, remote file name, or already a
(defsubst shadow-make-fullname (hup &optional host name)
"Make a Tramp style fullname out of HUP, a `tramp-file-name' structure.
Replace HOST, and NAME when non-nil."
Replace HOST, and NAME when non-nil. HOST can also be a remote file name."
(let ((hup (copy-tramp-file-name hup)))
(when host (setf (tramp-file-name-host hup) host))
(when host
(if (file-remote-p host)
(setq name (or name (and hup (tramp-file-name-localname hup)))
hup (tramp-dissect-file-name (file-remote-p host)))
(setf (tramp-file-name-host hup) host)))
(when name (setf (tramp-file-name-localname hup) name))
(if (null (tramp-file-name-method hup))
(format

View file

@ -69,12 +69,15 @@
(format "/mock::%s" temporary-file-directory)))
"Temporary directory for Tramp tests.")
(setq password-cache-expiry nil
(setq auth-source-save-behavior nil
password-cache-expiry nil
shadow-debug (or (getenv "EMACS_HYDRA_CI") (getenv "EMACS_EMBA_CI"))
tramp-verbose 0
;; When the remote user id is 0, Tramp refuses unsafe temporary files.
tramp-allow-unsafe-temporary-files
(or tramp-allow-unsafe-temporary-files noninteractive)
tramp-cache-read-persistent-data t ;; For auth-sources.
tramp-persistency-file-name nil
tramp-verbose 0
;; On macOS, `temporary-file-directory' is a symlinked directory.
temporary-file-directory (file-truename temporary-file-directory)
shadow-test-remote-temporary-file-directory
@ -643,7 +646,9 @@ guaranteed by the originator of a cluster definition."
(expand-file-name
"shadowfile-tests"
shadow-test-remote-temporary-file-directory))
mocked-input `(,cluster1 ,file1 ,cluster2 ,file2 ,(kbd "RET")))
mocked-input
`(,cluster1 ,file1 ,cluster2 ,file2
,primary ,file1 ,(kbd "RET")))
(with-temp-buffer
(set-visited-file-name file1)
(call-interactively #'shadow-define-literal-group)
@ -657,7 +662,9 @@ guaranteed by the originator of a cluster definition."
(should (member (format "/%s:%s" cluster1 (file-local-name file1))
(car shadow-literal-groups)))
(should (member (format "/%s:%s" cluster2 (file-local-name file2))
(car shadow-literal-groups))))
(car shadow-literal-groups)))
;; Bug#49596.
(should (member (concat primary file1) (car shadow-literal-groups))))
;; Cleanup.
(shadow--tests-cleanup))))