]> code.delx.au - gnu-emacs/blobdiff - test/automated/tramp-tests.el
Merge from origin/emacs-24
[gnu-emacs] / test / automated / tramp-tests.el
index d30a5b0c9a7a06ed30137d7497dbad8a40b6304f..578b81cfac7a866190f313f9af397d764d616999 100644 (file)
@@ -116,18 +116,15 @@ shall not contain a timeout."
   `(let ((tramp-verbose ,verbose)
         (tramp-message-show-message t)
         (tramp-debug-on-error t))
-     (condition-case err
+     (unwind-protect
         (progn ,@body)
-       (ert-test-skipped
-       (signal (car err) (cdr err)))
-       ((error quit)
-       (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
-         (with-current-buffer (tramp-get-connection-buffer v)
-           (message "%s" (buffer-string)))
-         (with-current-buffer (tramp-get-debug-buffer v)
-           (message "%s" (buffer-string))))
-       (message "%s" err)
-       (signal (car err) (cdr err))))))
+       (when (> tramp-verbose 3)
+        (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
+          (with-current-buffer (tramp-get-connection-buffer v)
+            (message "%s" (buffer-string)))
+          (with-current-buffer
+              (tramp-get-debug-buffer v)
+            (message "%s" (buffer-string))))))))
 
 (ert-deftest tramp-test00-availability ()
   "Test availability of Tramp functions."
@@ -956,7 +953,12 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
            (goto-char (point-min))
            (should
             (looking-at-p
-             "\\(total.+[[:digit:]]+\n\\)?.+ \\.\n.+ \\.\\.\n.+ foo$"))))
+             (concat
+              ;; There might be a summary line.
+              "\\(total.+[[:digit:]]+\n\\)?"
+              ;; We don't know in which order "." and ".." appear.
+              "\\(.+ \\.?\\.\n\\)\\{2\\}"
+              ".+ foo$")))))
       (ignore-errors (delete-directory tmp-name1 'recursive)))))
 
 (ert-deftest tramp-test18-file-attributes ()
@@ -1246,9 +1248,10 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
      (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
      '(tramp-gvfs-file-name-handler tramp-smb-file-name-handler))))
 
-  (let ((tmp-name (tramp--test-make-temp-name))
-       (default-directory tramp-test-temporary-file-directory)
-       kill-buffer-query-functions)
+  (let* ((tmp-name (tramp--test-make-temp-name))
+        (fnnd (file-name-nondirectory tmp-name))
+        (default-directory tramp-test-temporary-file-directory)
+        kill-buffer-query-functions)
     (unwind-protect
        (progn
          ;; We cannot use "/bin/true" and "/bin/false"; those paths
@@ -1259,17 +1262,25 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
          (with-temp-buffer
            (write-region "foo" nil tmp-name)
            (should (file-exists-p tmp-name))
-           (should
-            (zerop
-             (process-file "ls" nil t nil (file-name-nondirectory tmp-name))))
+           (should (zerop (process-file "ls" nil t nil fnnd)))
+           ;; `ls' could produce colorized output.
+           (goto-char (point-min))
+           (while (re-search-forward tramp-color-escape-sequence-regexp nil t)
+             (replace-match "" nil nil))
+           (should (string-equal (format "%s\n" fnnd) (buffer-string)))
+           (should-not (get-buffer-window (current-buffer) t))
+
+           ;; Second run. The output must be appended.
+           (should (zerop (process-file "ls" nil t t fnnd)))
            ;; `ls' could produce colorized output.
            (goto-char (point-min))
            (while (re-search-forward tramp-color-escape-sequence-regexp nil t)
              (replace-match "" nil nil))
            (should
-            (string-equal
-             (format "%s\n" (file-name-nondirectory tmp-name))
-             (buffer-string)))))
+            (string-equal (format "%s\n%s\n" fnnd fnnd) (buffer-string)))
+           ;; A non-nil DISPLAY must not raise the buffer.
+           (should-not (get-buffer-window (current-buffer) t))))
+
       (ignore-errors (delete-file tmp-name)))))
 
 (ert-deftest tramp-test27-start-file-process ()
@@ -1463,13 +1474,27 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
            (vc-create-repo (car vc-handled-backends))
            ;; The structure of VC-FILESET is not documented.  Let's
            ;; hope it won't change.
-           (vc-register
-            nil (list (car vc-handled-backends)
-                      (list (file-name-nondirectory tmp-name2)))))
+           (condition-case nil
+               (vc-register
+                (list (car vc-handled-backends)
+                      (list (file-name-nondirectory tmp-name2))))
+             ;; `vc-register' has changed its arguments in Emacs 25.1.
+             (error
+              (vc-register
+               nil (list (car vc-handled-backends)
+                         (list (file-name-nondirectory tmp-name2)))))))
          (should (vc-registered tmp-name2)))
 
        (ignore-errors (delete-directory tmp-name1 'recursive)))))
 
+(defun tramp--test-smb-or-windows-nt-p ()
+  "Check, whether the locale or remote host runs MS Windows.
+This requires restrictions of file name syntax."
+  (or (eq system-type 'windows-nt)
+      (eq (tramp-find-foreign-file-name-handler
+          tramp-test-temporary-file-directory)
+       'tramp-smb-file-name-handler)))
+
 (defun tramp--test-check-files (&rest files)
   "Runs a simple but comprehensive test over every file in FILES."
   (let ((tmp-name1 (tramp--test-make-temp-name))
@@ -1478,7 +1503,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
        (progn
          (make-directory tmp-name1)
          (make-directory tmp-name2)
-         (dolist (elt files)
+         (dolist (elt (delq nil files))
            (let ((file1 (expand-file-name elt tmp-name1))
                  (file2 (expand-file-name elt tmp-name2)))
              (write-region elt nil file1)
@@ -1534,24 +1559,23 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
     (memq
      (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
      '(tramp-adb-file-name-handler
-       tramp-gvfs-file-name-handler
-       tramp-smb-file-name-handler))))
+       tramp-gvfs-file-name-handler))))
 
   ;; Newlines, slashes and backslashes in file names are not supported.
   ;; So we don't test.
   (tramp--test-check-files
-   " foo\tbar baz\t"
+   (if (tramp--test-smb-or-windows-nt-p) "foo bar baz" " foo\tbar baz\t")
    "$foo$bar$$baz$"
    "-foo-bar-baz-"
    "%foo%bar%baz%"
    "&foo&bar&baz&"
-   "?foo?bar?baz?"
-   "*foo*bar*baz*"
-   "'foo\"bar'baz\""
+   (unless (tramp--test-smb-or-windows-nt-p) "?foo?bar?baz?")
+   (unless (tramp--test-smb-or-windows-nt-p) "*foo*bar*baz*")
+   (if (tramp--test-smb-or-windows-nt-p) "'foo'bar'baz'" "'foo\"bar'baz\"")
    "#foo~bar#baz~"
-   "!foo|bar!baz|"
-   ":foo;bar:baz;"
-   "<foo>bar<baz>"
+   (if (tramp--test-smb-or-windows-nt-p) "!foo!bar!baz!" "!foo|bar!baz|")
+   (if (tramp--test-smb-or-windows-nt-p) ";foo;bar;baz;" ":foo;bar:baz;")
+   (unless (tramp--test-smb-or-windows-nt-p) "<foo>bar<baz>")
    "(foo)bar(baz)"
    "[foo]bar[baz]"
    "{foo}bar{baz}"))
@@ -1731,10 +1755,9 @@ Since it unloads Tramp, it shall be the last test to run."
 ;;   doesn't work well when an interactive password must be provided.
 ;; * Fix `tramp-test27-start-file-process' for `nc' and on MS
 ;;   Windows (`process-send-eof'?).
-;; * Fix `tramp-test28-shell-command' on MS Windows (nasty plink message).
-;; * Fix `tramp-test30-special-characters' for `adb', `nc' and `smb'.
-;; * Fix `tramp-test31-utf8' for MS Windows and `nc'/`telnet' (when
-;;   target is a dumb busybox).  Seems to be in `directory-files'.
+;; * Fix `tramp-test30-special-characters' for `adb' and `nc'.
+;; * Fix `tramp-test31-utf8' for `nc'/`telnet' (when target is a dumb
+;;   busybox).  Seems to be in `directory-files'.
 ;; * Fix Bug#16928.  Set expected error of `tramp-test32-asynchronous-requests'.
 ;; * Fix `tramp-test34-unload' (Not all symbols are unbound).  Set
 ;;   expected error.