]> code.delx.au - gnu-emacs/blobdiff - test/lisp/net/tramp-tests.el
; Instrument tramp-tests.el
[gnu-emacs] / test / lisp / net / tramp-tests.el
index efb19e9f5062ad3514839b4e31aeb85ae778e2b6..0f40468ec98101f34f51416d72f4630446596aef 100644 (file)
@@ -639,19 +639,31 @@ This checks also `file-name-as-directory', `file-name-directory',
   (should-not
    (unhandled-file-name-directory "/method:host:/path/to/file"))
 
+  (unwind-protect
   ;; Bug#10085.
   (dolist (n-e '(nil t))
     (let ((non-essential n-e))
+      (when (getenv "NIX_STORE")
+        (dolist (elt (all-completions "tramp-" obarray 'functionp))
+          (trace-function-background (intern elt))))
       (dolist (file
               `(,(file-remote-p tramp-test-temporary-file-directory 'method)
                 ,(file-remote-p tramp-test-temporary-file-directory 'host)))
        (unless (zerop (length file))
          (setq file (format "/%s:" file))
          (should (string-equal (directory-file-name file) file))
+          (when (getenv "NIX_STORE")
+            (message "file %s non-essential %s tramp-completion-mode-p %s"
+                     file non-essential (tramp-completion-mode-p)))
          (should
-          (string-equal (file-name-as-directory file) (concat file "./")))
+          (string-equal
+           (file-name-as-directory file)
+           (if (tramp-completion-mode-p) file (concat file "./"))))
          (should (string-equal (file-name-directory file) file))
-         (should (string-equal (file-name-nondirectory file) "")))))))
+         (should (string-equal (file-name-nondirectory file) ""))))))
+  (when (getenv "NIX_STORE")
+    (untrace-all)
+    (message "%s" (with-current-buffer trace-buffer (buffer-string))))))
 
 (ert-deftest tramp-test07-file-exists-p ()
   "Check `file-exist-p', `write-region' and `delete-file'."
@@ -1367,25 +1379,52 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
   "Check `file-name-completion' and `file-name-all-completions'."
   (skip-unless (tramp--test-enabled))
 
-  (let ((tmp-name (tramp--test-make-temp-name)))
-    (unwind-protect
-       (progn
-         (make-directory tmp-name)
-         (should (file-directory-p tmp-name))
-         (write-region "foo" nil (expand-file-name "foo" tmp-name))
-         (write-region "bar" nil (expand-file-name "bold" tmp-name))
-         (make-directory (expand-file-name "boz" tmp-name))
-         (should (equal (file-name-completion "fo" tmp-name) "foo"))
-         (should (equal (file-name-completion "b" tmp-name) "bo"))
-         (should
-          (equal (file-name-completion "b" tmp-name 'file-directory-p) "boz/"))
-         (should (equal (file-name-all-completions "fo" tmp-name) '("foo")))
-         (should
-          (equal (sort (file-name-all-completions "b" tmp-name) 'string-lessp)
-                 '("bold" "boz/"))))
+  (dolist (n-e '(nil t))
+    (let ((non-essential n-e)
+         (tmp-name (tramp--test-make-temp-name))
+         (method (file-remote-p tramp-test-temporary-file-directory 'method))
+         (host (file-remote-p tramp-test-temporary-file-directory 'host)))
+
+      (unwind-protect
+         (progn
+           ;; Method and host name in completion mode.
+           (when (tramp-completion-mode-p)
+             (unless (zerop (length method))
+               (should
+                (member
+                 (format "%s:" method)
+                 (file-name-all-completions (substring method 0 1) "/"))))
+             (unless (zerop (length host))
+               (should
+                (member
+                 (format "%s:" host)
+                 (file-name-all-completions (substring host 0 1) "/"))))
+             (unless (or (zerop (length method)) (zerop (length host)))
+               (should
+                (member
+                 (format "%s:" host)
+                 (file-name-all-completions
+                  (substring host 0 1) (format "/%s:" method))))))
+
+           ;; Local files.
+           (make-directory tmp-name)
+           (should (file-directory-p tmp-name))
+           (write-region "foo" nil (expand-file-name "foo" tmp-name))
+           (write-region "bar" nil (expand-file-name "bold" tmp-name))
+           (make-directory (expand-file-name "boz" tmp-name))
+           (should (equal (file-name-completion "fo" tmp-name) "foo"))
+           (should (equal (file-name-completion "b" tmp-name) "bo"))
+           (should
+            (equal
+             (file-name-completion "b" tmp-name 'file-directory-p) "boz/"))
+           (should (equal (file-name-all-completions "fo" tmp-name) '("foo")))
+           (should
+            (equal
+             (sort (file-name-all-completions "b" tmp-name) 'string-lessp)
+             '("bold" "boz/"))))
 
-      ;; Cleanup.
-      (ignore-errors (delete-directory tmp-name 'recursive)))))
+       ;; Cleanup.
+       (ignore-errors (delete-directory tmp-name 'recursive))))))
 
 (ert-deftest tramp-test25-load ()
   "Check `load'."