]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix Bug#29163
authorMichael Albinus <michael.albinus@gmx.de>
Mon, 27 Nov 2017 12:31:53 +0000 (13:31 +0100)
committerMichael Albinus <michael.albinus@gmx.de>
Mon, 27 Nov 2017 12:31:53 +0000 (13:31 +0100)
* lisp/net/tramp.el (tramp-autoload-file-name-regexp):
Do not use "\\'" in regexp.  (Bug#29163)
(top) Do not run (tramp-register-autoload-file-name-handlers)
when loading tramp.el.

* test/lisp/net/tramp-tests.el (tramp--test-mock-p): New defun.
(tramp-test32-environment-variables-and-port-numbers)
(tramp-test41-asynchronous-requests): Use it.
(tramp-test42-auto-load): New test.
(tramp-test43-recursive-load, tramp-test44-remote-load-path)
(tramp-test45-delay-load, tramp-test46-unload): Rename.

lisp/net/tramp.el
test/lisp/net/tramp-tests.el

index efd31b26be64af14244b8531b815801327511440..13277ec6f34c630f02ec8ee0a4b43cfa33ad0ae3 100644 (file)
@@ -1055,7 +1055,7 @@ Also see `tramp-file-name-structure'.")
        "\\(-\\|[^/|:]\\{2,\\}\\)"
      ;; At least one character for method.
      "[^/|:]+")
-   ":\\'")
+   ":")
   "Regular expression matching file names handled by Tramp autoload.
 It must match the initial `tramp-syntax' settings.  It should not
 match file names at root of the underlying local file system,
@@ -2323,8 +2323,7 @@ Falls back to normal file name handler if no Tramp file name handler exists."
                     'tramp-autoload-file-name-handler))
   (put 'tramp-autoload-file-name-handler 'safe-magic t)))
 
-;;;###autoload
-(tramp-register-autoload-file-name-handlers)
+;;;###autoload (tramp-register-autoload-file-name-handlers)
 
 (defun tramp-use-absolute-autoload-file-names ()
   "Change Tramp autoload objects to use absolute file names.
index 08c58c8027d13e5a78cca9b2cf68b8eed4f20c78..2141f52cb208608cd0a39a59a6b769bc1b486bb6 100644 (file)
@@ -3627,11 +3627,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
   (skip-unless (tramp--test-enabled))
   ;; We test it only for the mock-up connection; otherwise there might
   ;; be problems with the used ports.
-  (skip-unless
-   (and
-    (eq tramp-syntax 'default)
-    (string-equal
-     "mock" (file-remote-p tramp-test-temporary-file-directory 'method))))
+  (skip-unless (and (eq tramp-syntax 'default)
+                    (tramp--test-mock-p)))
 
   ;; We force a reconnect, in order to have a clean environment.
   (dolist (dir `(,tramp-test-temporary-file-directory
@@ -4041,6 +4038,12 @@ Several special characters do not work properly there."
       (file-truename tramp-test-temporary-file-directory) nil
     (string-match "^HP-UX" (tramp-get-connection-property v "uname" ""))))
 
+(defun tramp--test-mock-p ()
+  "Check, whether the mock method is used.
+This does not support external Emacs calls."
+  (string-equal
+   "mock" (file-remote-p tramp-test-temporary-file-directory 'method)))
+
 (defun tramp--test-rsync-p ()
   "Check, whether the rsync method is used.
 This does not support special file names."
@@ -4495,8 +4498,7 @@ process sentinels.  They shall not disturb each other."
            ;; We must distinguish due to performance reasons.
            (timer-operation
             (cond
-             ((string-equal "mock" (file-remote-p tmp-name 'method))
-              'vc-registered)
+             ((tramp--test-mock-p) 'vc-registered)
              (t 'file-attributes)))
            timer buffers kill-buffer-query-functions)
 
@@ -4604,7 +4606,27 @@ process sentinels.  They shall not disturb each other."
         (ignore-errors (cancel-timer timer))
         (ignore-errors (delete-directory tmp-name 'recursive))))))
 
-(ert-deftest tramp-test42-recursive-load ()
+(ert-deftest tramp-test42-auto-load ()
+  "Check that Tramp autoloads properly."
+  (skip-unless (tramp--test-enabled))
+  (skip-unless (not (tramp--test-mock-p)))
+
+  (let ((default-directory (expand-file-name temporary-file-directory)))
+    (let ((code
+          (format
+           "(message \"Tramp loaded: %%s\" (consp (file-attributes \"%s\")))"
+           tramp-test-temporary-file-directory)))
+      (should
+       (string-match
+        "Tramp loaded: t[\n\r]+"
+       (shell-command-to-string
+        (format
+         "%s -batch -Q -L %s --eval %s"
+         (expand-file-name invocation-name invocation-directory)
+         (mapconcat 'shell-quote-argument load-path " -L ")
+         (shell-quote-argument code))))))))
+
+(ert-deftest tramp-test43-recursive-load ()
   "Check that Tramp does not fail due to recursive load."
   (skip-unless (tramp--test-enabled))
 
@@ -4627,7 +4649,7 @@ process sentinels.  They shall not disturb each other."
          (mapconcat 'shell-quote-argument load-path " -L ")
          (shell-quote-argument code))))))))
 
-(ert-deftest tramp-test43-remote-load-path ()
+(ert-deftest tramp-test44-remote-load-path ()
   "Check that Tramp autoloads its packages with remote `load-path'."
   ;; `tramp-cleanup-all-connections' is autoloaded from tramp-cmds.el.
   ;; It shall still work, when a remote file name is in the
@@ -4650,7 +4672,7 @@ process sentinels.  They shall not disturb each other."
        (mapconcat 'shell-quote-argument load-path " -L ")
        (shell-quote-argument code)))))))
 
-(ert-deftest tramp-test44-delay-load ()
+(ert-deftest tramp-test45-delay-load ()
   "Check that Tramp is loaded lazily, only when needed."
   ;; Tramp is neither loaded at Emacs startup, nor when completing a
   ;; non-Tramp file name like "/foo".  Completing a Tramp-alike file
@@ -4677,7 +4699,7 @@ process sentinels.  They shall not disturb each other."
          (mapconcat 'shell-quote-argument load-path " -L ")
          (shell-quote-argument (format code tm)))))))))
 
-(ert-deftest tramp-test45-unload ()
+(ert-deftest tramp-test46-unload ()
   "Check that Tramp and its subpackages unload completely.
 Since it unloads Tramp, it shall be the last test to run."
   :tags '(:expensive-test)