diff options
| author | Michael Albinus | 2018-02-03 18:49:56 +0100 |
|---|---|---|
| committer | Michael Albinus | 2018-02-03 18:49:56 +0100 |
| commit | a2cb52cd2e7c497df51d751b91b331f59f9637e7 (patch) | |
| tree | 837fb576472a2ca5b0fc283a3f30eb496f6dc871 | |
| parent | f7c8a12b12f5344100d3da192c0ec80f69ed55a9 (diff) | |
| download | emacs-a2cb52cd2e7c497df51d751b91b331f59f9637e7.tar.gz emacs-a2cb52cd2e7c497df51d751b91b331f59f9637e7.zip | |
Prevent loading tramp-archive when it cannot be used
* lisp/files.el (locate-dominating-file): Check, that FILE is
a directory when traversing the tree.
* lisp/net/tramp-archive.el (tramp-archive-enabled): New defvar.
(tramp-archive-file-name-regexp): Protect against errors.
(tramp-archive-file-name-handler)
(tramp-register-archive-file-name-handler): Use it.
(all) Call `tramp-register-archive-file-name-handler'.
* lisp/net/tramp.el (tramp-register-file-name-handlers):
Use `tramp-archive-enabled'.
* test/lisp/net/tramp-archive-tests.el (all):
Use `tramp-archive-enabled' instead of `tramp-gvfs-enabled'.
(tramp-archive--test-emacs27-p): New defun.
(tramp-archive-test42-auto-load): Skip for older Emacsen.
(tramp-archive-test42-delay-load): Skip for older Emacsen.
Test also behavior when `tramp-archive-enabled' is nil.
| -rw-r--r-- | lisp/files.el | 3 | ||||
| -rw-r--r-- | lisp/net/tramp-archive.el | 23 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 9 | ||||
| -rw-r--r-- | test/lisp/net/tramp-archive-tests.el | 102 |
4 files changed, 82 insertions, 55 deletions
diff --git a/lisp/files.el b/lisp/files.el index e884a3acc18..414eb3f93af 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -963,7 +963,8 @@ the function needs to examine, starting with FILE." | |||
| 963 | (null file) | 963 | (null file) |
| 964 | (string-match locate-dominating-stop-dir-regexp file))) | 964 | (string-match locate-dominating-stop-dir-regexp file))) |
| 965 | (setq try (if (stringp name) | 965 | (setq try (if (stringp name) |
| 966 | (file-exists-p (expand-file-name name file)) | 966 | (and (file-directory-p file) |
| 967 | (file-exists-p (expand-file-name name file))) | ||
| 967 | (funcall name file))) | 968 | (funcall name file))) |
| 968 | (cond (try (setq root file)) | 969 | (cond (try (setq root file)) |
| 969 | ((equal file (setq file (file-name-directory | 970 | ((equal file (setq file (file-name-directory |
diff --git a/lisp/net/tramp-archive.el b/lisp/net/tramp-archive.el index 23191f11f3e..ac1c4e1448d 100644 --- a/lisp/net/tramp-archive.el +++ b/lisp/net/tramp-archive.el | |||
| @@ -112,6 +112,14 @@ | |||
| 112 | (defvar url-handler-regexp) | 112 | (defvar url-handler-regexp) |
| 113 | (defvar url-tramp-protocols) | 113 | (defvar url-tramp-protocols) |
| 114 | 114 | ||
| 115 | ;; We cannot check `tramp-gvfs-enabled' in loaddefs.el, because this | ||
| 116 | ;; would load Tramp. So we make a cheaper check. | ||
| 117 | ;;;###autoload | ||
| 118 | (defvar tramp-archive-enabled (featurep 'dbusbind) | ||
| 119 | "Non-nil when GVFS is available.") | ||
| 120 | |||
| 121 | (setq tramp-archive-enabled tramp-gvfs-enabled) | ||
| 122 | |||
| 115 | ;; <https://github.com/libarchive/libarchive/wiki/LibarchiveFormats> | 123 | ;; <https://github.com/libarchive/libarchive/wiki/LibarchiveFormats> |
| 116 | ;;;###autoload | 124 | ;;;###autoload |
| 117 | (defconst tramp-archive-suffixes | 125 | (defconst tramp-archive-suffixes |
| @@ -169,7 +177,7 @@ It must be supported by libarchive(3).") | |||
| 169 | 177 | ||
| 170 | ;;;###tramp-autoload | 178 | ;;;###tramp-autoload |
| 171 | (defconst tramp-archive-file-name-regexp | 179 | (defconst tramp-archive-file-name-regexp |
| 172 | (tramp-archive-autoload-file-name-regexp) | 180 | (ignore-errors (tramp-archive-autoload-file-name-regexp)) |
| 173 | "Regular expression matching archive file names.") | 181 | "Regular expression matching archive file names.") |
| 174 | 182 | ||
| 175 | ;;;###tramp-autoload | 183 | ;;;###tramp-autoload |
| @@ -291,7 +299,7 @@ pass to the OPERATION." | |||
| 291 | (tramp-archive-run-real-handler 'file-directory-p (list archive))) | 299 | (tramp-archive-run-real-handler 'file-directory-p (list archive))) |
| 292 | (tramp-archive-run-real-handler operation args) | 300 | (tramp-archive-run-real-handler operation args) |
| 293 | ;; Now run the handler. | 301 | ;; Now run the handler. |
| 294 | (unless tramp-gvfs-enabled | 302 | (unless tramp-archive-enabled |
| 295 | (tramp-compat-user-error nil "Package `tramp-archive' not supported")) | 303 | (tramp-compat-user-error nil "Package `tramp-archive' not supported")) |
| 296 | (let ((tramp-methods (cons `(,tramp-archive-method) tramp-methods)) | 304 | (let ((tramp-methods (cons `(,tramp-archive-method) tramp-methods)) |
| 297 | (tramp-gvfs-methods tramp-archive-all-gvfs-methods) | 305 | (tramp-gvfs-methods tramp-archive-all-gvfs-methods) |
| @@ -308,14 +316,17 @@ pass to the OPERATION." | |||
| 308 | ;;;###autoload | 316 | ;;;###autoload |
| 309 | (progn (defun tramp-register-archive-file-name-handler () | 317 | (progn (defun tramp-register-archive-file-name-handler () |
| 310 | "Add archive file name handler to `file-name-handler-alist'." | 318 | "Add archive file name handler to `file-name-handler-alist'." |
| 311 | (add-to-list 'file-name-handler-alist | 319 | (when tramp-archive-enabled |
| 312 | (cons (tramp-archive-autoload-file-name-regexp) | 320 | (add-to-list 'file-name-handler-alist |
| 313 | 'tramp-autoload-file-name-handler)) | 321 | (cons (tramp-archive-autoload-file-name-regexp) |
| 314 | (put 'tramp-archive-file-name-handler 'safe-magic t))) | 322 | 'tramp-autoload-file-name-handler)) |
| 323 | (put 'tramp-archive-file-name-handler 'safe-magic t)))) | ||
| 315 | 324 | ||
| 316 | ;;;###autoload | 325 | ;;;###autoload |
| 317 | (add-hook 'after-init-hook 'tramp-register-archive-file-name-handler) | 326 | (add-hook 'after-init-hook 'tramp-register-archive-file-name-handler) |
| 318 | 327 | ||
| 328 | (tramp-register-archive-file-name-handler) | ||
| 329 | |||
| 319 | ;; Mark `operations' the handler is responsible for. | 330 | ;; Mark `operations' the handler is responsible for. |
| 320 | (put 'tramp-archive-file-name-handler 'operations | 331 | (put 'tramp-archive-file-name-handler 'operations |
| 321 | (mapcar 'car tramp-archive-file-name-handler-alist)) | 332 | (mapcar 'car tramp-archive-file-name-handler-alist)) |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 5a2e358daa1..09abd482260 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -2401,10 +2401,11 @@ remote file names." | |||
| 2401 | (put 'tramp-completion-file-name-handler 'operations | 2401 | (put 'tramp-completion-file-name-handler 'operations |
| 2402 | (mapcar 'car tramp-completion-file-name-handler-alist)) | 2402 | (mapcar 'car tramp-completion-file-name-handler-alist)) |
| 2403 | 2403 | ||
| 2404 | (add-to-list 'file-name-handler-alist | 2404 | (when (bound-and-true-p tramp-archive-enabled) |
| 2405 | (cons tramp-archive-file-name-regexp | 2405 | (add-to-list 'file-name-handler-alist |
| 2406 | 'tramp-archive-file-name-handler)) | 2406 | (cons tramp-archive-file-name-regexp |
| 2407 | (put 'tramp-archive-file-name-handler 'safe-magic t) | 2407 | 'tramp-archive-file-name-handler)) |
| 2408 | (put 'tramp-archive-file-name-handler 'safe-magic t)) | ||
| 2408 | 2409 | ||
| 2409 | ;; If jka-compr or epa-file are already loaded, move them to the | 2410 | ;; If jka-compr or epa-file are already loaded, move them to the |
| 2410 | ;; front of `file-name-handler-alist'. | 2411 | ;; front of `file-name-handler-alist'. |
diff --git a/test/lisp/net/tramp-archive-tests.el b/test/lisp/net/tramp-archive-tests.el index bebdf108c66..e4ae1217002 100644 --- a/test/lisp/net/tramp-archive-tests.el +++ b/test/lisp/net/tramp-archive-tests.el | |||
| @@ -86,12 +86,18 @@ Some semantics has been changed for there, w/o new functions or | |||
| 86 | variables, so we check the Emacs version directly." | 86 | variables, so we check the Emacs version directly." |
| 87 | (>= emacs-major-version 26)) | 87 | (>= emacs-major-version 26)) |
| 88 | 88 | ||
| 89 | (defun tramp-archive--test-emacs27-p () | ||
| 90 | "Check for Emacs version >= 27.1. | ||
| 91 | Some semantics has been changed for there, w/o new functions or | ||
| 92 | variables, so we check the Emacs version directly." | ||
| 93 | (>= emacs-major-version 27)) | ||
| 94 | |||
| 89 | (ert-deftest tramp-archive-test00-availability () | 95 | (ert-deftest tramp-archive-test00-availability () |
| 90 | "Test availability of Tramp functions." | 96 | "Test availability of archive file name functions." |
| 91 | :expected-result (if tramp-gvfs-enabled :passed :failed) | 97 | :expected-result (if tramp-archive-enabled :passed :failed) |
| 92 | (should | 98 | (should |
| 93 | (and | 99 | (and |
| 94 | tramp-gvfs-enabled | 100 | tramp-archive-enabled |
| 95 | (file-exists-p tramp-archive-test-file-archive) | 101 | (file-exists-p tramp-archive-test-file-archive) |
| 96 | (tramp-archive-file-name-p tramp-archive-test-archive)))) | 102 | (tramp-archive-file-name-p tramp-archive-test-archive)))) |
| 97 | 103 | ||
| @@ -147,7 +153,7 @@ variables, so we check the Emacs version directly." | |||
| 147 | 153 | ||
| 148 | (ert-deftest tramp-archive-test02-file-name-dissect () | 154 | (ert-deftest tramp-archive-test02-file-name-dissect () |
| 149 | "Check archive file name components." | 155 | "Check archive file name components." |
| 150 | (skip-unless tramp-gvfs-enabled) | 156 | (skip-unless tramp-archive-enabled) |
| 151 | 157 | ||
| 152 | (with-parsed-tramp-archive-file-name tramp-archive-test-archive nil | 158 | (with-parsed-tramp-archive-file-name tramp-archive-test-archive nil |
| 153 | (should (string-equal method tramp-archive-method)) | 159 | (should (string-equal method tramp-archive-method)) |
| @@ -266,7 +272,7 @@ They shall still be supported" | |||
| 266 | "Check `directory-file-name'. | 272 | "Check `directory-file-name'. |
| 267 | This checks also `file-name-as-directory', `file-name-directory', | 273 | This checks also `file-name-as-directory', `file-name-directory', |
| 268 | `file-name-nondirectory' and `unhandled-file-name-directory'." | 274 | `file-name-nondirectory' and `unhandled-file-name-directory'." |
| 269 | (skip-unless tramp-gvfs-enabled) | 275 | (skip-unless tramp-archive-enabled) |
| 270 | 276 | ||
| 271 | (should | 277 | (should |
| 272 | (string-equal | 278 | (string-equal |
| @@ -305,7 +311,7 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 305 | 311 | ||
| 306 | (ert-deftest tramp-archive-test07-file-exists-p () | 312 | (ert-deftest tramp-archive-test07-file-exists-p () |
| 307 | "Check `file-exist-p', `write-region' and `delete-file'." | 313 | "Check `file-exist-p', `write-region' and `delete-file'." |
| 308 | (skip-unless tramp-gvfs-enabled) | 314 | (skip-unless tramp-archive-enabled) |
| 309 | 315 | ||
| 310 | (unwind-protect | 316 | (unwind-protect |
| 311 | (let ((default-directory tramp-archive-test-archive)) | 317 | (let ((default-directory tramp-archive-test-archive)) |
| @@ -327,7 +333,7 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 327 | 333 | ||
| 328 | (ert-deftest tramp-archive-test08-file-local-copy () | 334 | (ert-deftest tramp-archive-test08-file-local-copy () |
| 329 | "Check `file-local-copy'." | 335 | "Check `file-local-copy'." |
| 330 | (skip-unless tramp-gvfs-enabled) | 336 | (skip-unless tramp-archive-enabled) |
| 331 | 337 | ||
| 332 | (let (tmp-name) | 338 | (let (tmp-name) |
| 333 | (unwind-protect | 339 | (unwind-protect |
| @@ -353,7 +359,7 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 353 | 359 | ||
| 354 | (ert-deftest tramp-archive-test09-insert-file-contents () | 360 | (ert-deftest tramp-archive-test09-insert-file-contents () |
| 355 | "Check `insert-file-contents'." | 361 | "Check `insert-file-contents'." |
| 356 | (skip-unless tramp-gvfs-enabled) | 362 | (skip-unless tramp-archive-enabled) |
| 357 | 363 | ||
| 358 | (let ((tmp-name (expand-file-name "bar/bar" tramp-archive-test-archive))) | 364 | (let ((tmp-name (expand-file-name "bar/bar" tramp-archive-test-archive))) |
| 359 | (unwind-protect | 365 | (unwind-protect |
| @@ -379,7 +385,7 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 379 | 385 | ||
| 380 | (ert-deftest tramp-archive-test11-copy-file () | 386 | (ert-deftest tramp-archive-test11-copy-file () |
| 381 | "Check `copy-file'." | 387 | "Check `copy-file'." |
| 382 | (skip-unless tramp-gvfs-enabled) | 388 | (skip-unless tramp-archive-enabled) |
| 383 | 389 | ||
| 384 | ;; Copy simple file. | 390 | ;; Copy simple file. |
| 385 | (let ((tmp-name1 (expand-file-name "bar/bar" tramp-archive-test-archive)) | 391 | (let ((tmp-name1 (expand-file-name "bar/bar" tramp-archive-test-archive)) |
| @@ -444,7 +450,7 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 444 | 450 | ||
| 445 | (ert-deftest tramp-archive-test15-copy-directory () | 451 | (ert-deftest tramp-archive-test15-copy-directory () |
| 446 | "Check `copy-directory'." | 452 | "Check `copy-directory'." |
| 447 | (skip-unless tramp-gvfs-enabled) | 453 | (skip-unless tramp-archive-enabled) |
| 448 | 454 | ||
| 449 | (let* ((tmp-name1 (expand-file-name "bar" tramp-archive-test-archive)) | 455 | (let* ((tmp-name1 (expand-file-name "bar" tramp-archive-test-archive)) |
| 450 | (tmp-name2 (tramp-archive--test-make-temp-name)) | 456 | (tmp-name2 (tramp-archive--test-make-temp-name)) |
| @@ -498,7 +504,7 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 498 | 504 | ||
| 499 | (ert-deftest tramp-archive-test16-directory-files () | 505 | (ert-deftest tramp-archive-test16-directory-files () |
| 500 | "Check `directory-files'." | 506 | "Check `directory-files'." |
| 501 | (skip-unless tramp-gvfs-enabled) | 507 | (skip-unless tramp-archive-enabled) |
| 502 | 508 | ||
| 503 | (let ((tmp-name tramp-archive-test-archive) | 509 | (let ((tmp-name tramp-archive-test-archive) |
| 504 | (files '("." ".." "bar" "baz.tar" "foo.hrd" "foo.lnk" "foo.txt"))) | 510 | (files '("." ".." "bar" "baz.tar" "foo.hrd" "foo.lnk" "foo.txt"))) |
| @@ -521,7 +527,7 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 521 | 527 | ||
| 522 | (ert-deftest tramp-archive-test17-insert-directory () | 528 | (ert-deftest tramp-archive-test17-insert-directory () |
| 523 | "Check `insert-directory'." | 529 | "Check `insert-directory'." |
| 524 | (skip-unless tramp-gvfs-enabled) | 530 | (skip-unless tramp-archive-enabled) |
| 525 | 531 | ||
| 526 | (let (;; We test for the summary line. Keyword "total" could be localized. | 532 | (let (;; We test for the summary line. Keyword "total" could be localized. |
| 527 | (process-environment | 533 | (process-environment |
| @@ -563,7 +569,7 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 563 | (ert-deftest tramp-archive-test18-file-attributes () | 569 | (ert-deftest tramp-archive-test18-file-attributes () |
| 564 | "Check `file-attributes'. | 570 | "Check `file-attributes'. |
| 565 | This tests also `file-readable-p' and `file-regular-p'." | 571 | This tests also `file-readable-p' and `file-regular-p'." |
| 566 | (skip-unless tramp-gvfs-enabled) | 572 | (skip-unless tramp-archive-enabled) |
| 567 | 573 | ||
| 568 | (let ((tmp-name1 (expand-file-name "foo.txt" tramp-archive-test-archive)) | 574 | (let ((tmp-name1 (expand-file-name "foo.txt" tramp-archive-test-archive)) |
| 569 | (tmp-name2 (expand-file-name "foo.lnk" tramp-archive-test-archive)) | 575 | (tmp-name2 (expand-file-name "foo.lnk" tramp-archive-test-archive)) |
| @@ -613,7 +619,7 @@ This tests also `file-readable-p' and `file-regular-p'." | |||
| 613 | 619 | ||
| 614 | (ert-deftest tramp-archive-test19-directory-files-and-attributes () | 620 | (ert-deftest tramp-archive-test19-directory-files-and-attributes () |
| 615 | "Check `directory-files-and-attributes'." | 621 | "Check `directory-files-and-attributes'." |
| 616 | (skip-unless tramp-gvfs-enabled) | 622 | (skip-unless tramp-archive-enabled) |
| 617 | 623 | ||
| 618 | (let ((tmp-name (expand-file-name "bar" tramp-archive-test-archive)) | 624 | (let ((tmp-name (expand-file-name "bar" tramp-archive-test-archive)) |
| 619 | attr) | 625 | attr) |
| @@ -638,7 +644,7 @@ This tests also `file-readable-p' and `file-regular-p'." | |||
| 638 | (ert-deftest tramp-archive-test20-file-modes () | 644 | (ert-deftest tramp-archive-test20-file-modes () |
| 639 | "Check `file-modes'. | 645 | "Check `file-modes'. |
| 640 | This tests also `file-executable-p', `file-writable-p' and `set-file-modes'." | 646 | This tests also `file-executable-p', `file-writable-p' and `set-file-modes'." |
| 641 | (skip-unless tramp-gvfs-enabled) | 647 | (skip-unless tramp-archive-enabled) |
| 642 | 648 | ||
| 643 | (let ((tmp-name1 (expand-file-name "foo.txt" tramp-archive-test-archive)) | 649 | (let ((tmp-name1 (expand-file-name "foo.txt" tramp-archive-test-archive)) |
| 644 | (tmp-name2 (expand-file-name "bar" tramp-archive-test-archive))) | 650 | (tmp-name2 (expand-file-name "bar" tramp-archive-test-archive))) |
| @@ -667,7 +673,7 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'." | |||
| 667 | 673 | ||
| 668 | (ert-deftest tramp-archive-test21-file-links () | 674 | (ert-deftest tramp-archive-test21-file-links () |
| 669 | "Check `file-symlink-p' and `file-truename'" | 675 | "Check `file-symlink-p' and `file-truename'" |
| 670 | (skip-unless tramp-gvfs-enabled) | 676 | (skip-unless tramp-archive-enabled) |
| 671 | 677 | ||
| 672 | ;; We must use `file-truename' for the file archive, because it | 678 | ;; We must use `file-truename' for the file archive, because it |
| 673 | ;; could be located on a symlinked directory. This would let the | 679 | ;; could be located on a symlinked directory. This would let the |
| @@ -705,7 +711,7 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'." | |||
| 705 | 711 | ||
| 706 | (ert-deftest tramp-archive-test26-file-name-completion () | 712 | (ert-deftest tramp-archive-test26-file-name-completion () |
| 707 | "Check `file-name-completion' and `file-name-all-completions'." | 713 | "Check `file-name-completion' and `file-name-all-completions'." |
| 708 | (skip-unless tramp-gvfs-enabled) | 714 | (skip-unless tramp-archive-enabled) |
| 709 | 715 | ||
| 710 | (let ((tmp-name tramp-archive-test-archive)) | 716 | (let ((tmp-name tramp-archive-test-archive)) |
| 711 | (unwind-protect | 717 | (unwind-protect |
| @@ -744,7 +750,7 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'." | |||
| 744 | ;; The functions were introduced in Emacs 26.1. | 750 | ;; The functions were introduced in Emacs 26.1. |
| 745 | (ert-deftest tramp-archive-test37-make-nearby-temp-file () | 751 | (ert-deftest tramp-archive-test37-make-nearby-temp-file () |
| 746 | "Check `make-nearby-temp-file' and `temporary-file-directory'." | 752 | "Check `make-nearby-temp-file' and `temporary-file-directory'." |
| 747 | (skip-unless tramp-gvfs-enabled) | 753 | (skip-unless tramp-archive-enabled) |
| 748 | ;; Since Emacs 26.1. | 754 | ;; Since Emacs 26.1. |
| 749 | (skip-unless | 755 | (skip-unless |
| 750 | (and (fboundp 'make-nearby-temp-file) (fboundp 'temporary-file-directory))) | 756 | (and (fboundp 'make-nearby-temp-file) (fboundp 'temporary-file-directory))) |
| @@ -781,7 +787,7 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'." | |||
| 781 | 787 | ||
| 782 | (ert-deftest tramp-archive-test40-file-system-info () | 788 | (ert-deftest tramp-archive-test40-file-system-info () |
| 783 | "Check that `file-system-info' returns proper values." | 789 | "Check that `file-system-info' returns proper values." |
| 784 | (skip-unless tramp-gvfs-enabled) | 790 | (skip-unless tramp-archive-enabled) |
| 785 | ;; Since Emacs 27.1. | 791 | ;; Since Emacs 27.1. |
| 786 | (skip-unless (fboundp 'file-system-info)) | 792 | (skip-unless (fboundp 'file-system-info)) |
| 787 | 793 | ||
| @@ -798,7 +804,9 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'." | |||
| 798 | 804 | ||
| 799 | (ert-deftest tramp-archive-test42-auto-load () | 805 | (ert-deftest tramp-archive-test42-auto-load () |
| 800 | "Check that `tramp-archive' autoloads properly." | 806 | "Check that `tramp-archive' autoloads properly." |
| 801 | (skip-unless tramp-gvfs-enabled) | 807 | (skip-unless tramp-archive-enabled) |
| 808 | ;; Autoloading tramp-archive works since Emacs 27.1. | ||
| 809 | (skip-unless (tramp-archive--test-emacs27-p)) | ||
| 802 | 810 | ||
| 803 | (let ((default-directory (expand-file-name temporary-file-directory)) | 811 | (let ((default-directory (expand-file-name temporary-file-directory)) |
| 804 | (code | 812 | (code |
| @@ -818,38 +826,44 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'." | |||
| 818 | 826 | ||
| 819 | (ert-deftest tramp-archive-test42-delay-load () | 827 | (ert-deftest tramp-archive-test42-delay-load () |
| 820 | "Check that `tramp-archive' is loaded lazily, only when needed." | 828 | "Check that `tramp-archive' is loaded lazily, only when needed." |
| 821 | (skip-unless tramp-gvfs-enabled) | 829 | (skip-unless tramp-archive-enabled) |
| 830 | ;; Autoloading tramp-archive works since Emacs 27.1. | ||
| 831 | (skip-unless (tramp-archive--test-emacs27-p)) | ||
| 822 | 832 | ||
| 823 | ;; Tramp is neither loaded at Emacs startup, nor when completing a | 833 | ;; tramp-archive is neither loaded at Emacs startup, nor when |
| 824 | ;; non archive file name like "/foo". Completing an archive file | 834 | ;; loading a file like "/foo.tar". It is loaded only when |
| 825 | ;; name like "/foo.tar/" autoloads Tramp, when `tramp-mode' is t. | 835 | ;; `tramp-archive-enabled' is t. |
| 826 | (let ((default-directory (expand-file-name temporary-file-directory)) | 836 | (let ((default-directory (expand-file-name temporary-file-directory)) |
| 827 | (code | 837 | (code |
| 838 | "(progn \ | ||
| 839 | (setq tramp-archive-enabled %s) \ | ||
| 840 | (message \"Tramp loaded: %%s\" (featurep 'tramp-archive)) \ | ||
| 841 | (find-file %S \"/\") \ | ||
| 842 | (message \"Tramp loaded: %%s\" (featurep 'tramp-archive)) \ | ||
| 843 | (file-attributes %S \"/\") \ | ||
| 844 | (message \"Tramp loaded: %%s\" (featurep 'tramp-archive)))")) | ||
| 845 | ;; tramp-archive doesn't load when `tramp-archive-enabled' is nil. | ||
| 846 | (dolist (tae '(t nil)) | ||
| 847 | (should | ||
| 848 | (string-match | ||
| 849 | (format | ||
| 850 | "Tramp loaded: nil[[:ascii:]]+Tramp loaded: nil[[:ascii:]]+Tramp loaded: %s" | ||
| 851 | tae) | ||
| 852 | (shell-command-to-string | ||
| 828 | (format | 853 | (format |
| 829 | "(progn \ | 854 | "%s -batch -Q -L %s --eval %s" |
| 830 | (message \"Tramp loaded: %%s\" (featurep 'tramp-archive)) \ | 855 | (shell-quote-argument |
| 831 | (file-name-all-completions %S \"/\") \ | 856 | (expand-file-name invocation-name invocation-directory)) |
| 832 | (message \"Tramp loaded: %%s\" (featurep 'tramp-archive)) \ | 857 | (mapconcat 'shell-quote-argument load-path " -L ") |
| 833 | (file-name-all-completions %S \"/\") \ | 858 | (shell-quote-argument |
| 834 | (message \"Tramp loaded: %%s\" (featurep 'tramp-archive)))" | 859 | (format |
| 835 | tramp-archive-test-file-archive | 860 | code tae tramp-archive-test-file-archive |
| 836 | tramp-archive-test-archive))) | 861 | (concat tramp-archive-test-archive "foo")))))))))) |
| 837 | ;; Tramp doesn't load when `tramp-mode' is nil. | ||
| 838 | (should | ||
| 839 | (string-match | ||
| 840 | "Tramp loaded: nil[\n\r]+Tramp loaded: nil[\n\r]+Tramp loaded: t[\n\r]+" | ||
| 841 | (shell-command-to-string | ||
| 842 | (format | ||
| 843 | "%s -batch -Q -L %s --eval %s" | ||
| 844 | (shell-quote-argument | ||
| 845 | (expand-file-name invocation-name invocation-directory)) | ||
| 846 | (mapconcat 'shell-quote-argument load-path " -L ") | ||
| 847 | (shell-quote-argument code))))))) | ||
| 848 | 862 | ||
| 849 | (ert-deftest tramp-archive-test99-libarchive-tests () | 863 | (ert-deftest tramp-archive-test99-libarchive-tests () |
| 850 | "Run tests of libarchive test files." | 864 | "Run tests of libarchive test files." |
| 851 | :tags '(:expensive-test) | 865 | :tags '(:expensive-test) |
| 852 | (skip-unless tramp-gvfs-enabled) | 866 | (skip-unless tramp-archive-enabled) |
| 853 | ;; We do not want to run unless chosen explicitly. This test makes | 867 | ;; We do not want to run unless chosen explicitly. This test makes |
| 854 | ;; sense only in my local environment. Michael Albinus. | 868 | ;; sense only in my local environment. Michael Albinus. |
| 855 | (skip-unless | 869 | (skip-unless |