From 1baa1e49d84061e964802eba34713052804185f8 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Wed, 27 Nov 2013 15:23:32 +0100 Subject: [PATCH] * automated/file-notify-tests.el (file-notify-test-remote-temporary-file-directory): Check $REMOTE_TEMPORARY_FILE_DIRECTORY. (tramp-read-passwd): Check $REMOTE_ALLOW_PASSWORD. (file-notify--deftest-remote): Cleanup connection initially. (file-notify-test03-autorevert): Run also in batch mode. Use a larger timeout for remote files. `sit-for' 1 second; 0.1 second does not work on MS Windows. Call `accept-process-output' for remote files. Apply `string-match' instead of `string-equal', the messages are different on MS Windows. * automated/tramp-tests.el (tramp-test-temporary-file-directory): Use $REMOTE_TEMPORARY_FILE_DIRECTORY. (tramp-read-passwd): Check $REMOTE_ALLOW_PASSWORD. --- test/ChangeLog | 17 ++++++++++++ test/automated/file-notify-tests.el | 43 +++++++++++++++++++---------- test/automated/tramp-tests.el | 14 +++++++--- 3 files changed, 56 insertions(+), 18 deletions(-) diff --git a/test/ChangeLog b/test/ChangeLog index d22c47f62df..1237d4629a9 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,20 @@ +2013-11-27 Michael Albinus + + * automated/file-notify-tests.el + (file-notify-test-remote-temporary-file-directory): + Check $REMOTE_TEMPORARY_FILE_DIRECTORY. + (tramp-read-passwd): Check $REMOTE_ALLOW_PASSWORD. + (file-notify--deftest-remote): Cleanup connection initially. + (file-notify-test03-autorevert): Run also in batch mode. Use a + larger timeout for remote files. `sit-for' 1 second; 0.1 second + does not work on MS Windows. Call `accept-process-output' for + remote files. Apply `string-match' instead of `string-equal', the + messages are different on MS Windows. + + * automated/tramp-tests.el (tramp-test-temporary-file-directory): + Use $REMOTE_TEMPORARY_FILE_DIRECTORY. + (tramp-read-passwd): Check $REMOTE_ALLOW_PASSWORD. + 2013-11-23 Glenn Morris * automated/python-tests.el (python-shell-make-comint-1) diff --git a/test/automated/file-notify-tests.el b/test/automated/file-notify-tests.el index e0852fb5705..1d0a63b6ada 100644 --- a/test/automated/file-notify-tests.el +++ b/test/automated/file-notify-tests.el @@ -19,13 +19,17 @@ ;;; Commentary: -;; Some of the tests are intended to run over remote files. Set -;; `file-notify-test-remote-temporary-file-directory' to a suitable -;; value. It must NOT require an interactive password prompt, when -;; running the tests in batch mode. +;; Some of the tests require access to a remote host files. Set +;; $REMOTE_TEMPORARY_FILE_DIRECTORY to a suitable value in order +;; to overwrite the default value. If you want to skip tests +;; accessing a remote host, set this environment variable to +;; "/dev/null" or whatever is appropriate on your system. -;; If you want to skip tests for remote files, set this variable to -;; `null-device'. +;; When running the tests in batch mode, it must NOT require an +;; interactive password prompt unless the environment variable +;; $REMOTE_ALLOW_PASSWORD is set. + +;; A whole test run can be performed calling the command `file-notify-test-all'. ;;; Code: @@ -34,7 +38,10 @@ ;; There is no default value on w32 systems, which could work out of the box. (defconst file-notify-test-remote-temporary-file-directory - (if (eq system-type 'windows-nt) null-device "/ssh::/tmp") + (cond + ((getenv "REMOTE_TEMPORARY_FILE_DIRECTORY")) + ((eq system-type 'windows-nt) null-device) + (t (format "/ssh::%s" temporary-file-directory))) "Temporary directory for Tramp tests.") (defvar file-notify--test-tmpfile nil) @@ -45,7 +52,11 @@ (require 'tramp) (setq tramp-verbose 0 tramp-message-show-message nil) -(when noninteractive (defalias 'tramp-read-passwd 'ignore)) + +;; Disable interactive passwords in batch mode. +(when (and noninteractive (not (getenv "REMOTE_ALLOW_PASSWORD"))) + (defalias 'tramp-read-passwd 'ignore)) + ;; This shall happen on hydra only. (when (getenv "NIX_STORE") (add-to-list 'tramp-remote-path 'tramp-own-remote-path)) @@ -96,6 +107,8 @@ being the result.") ;; That's why we skip only for failed local tests. (skip-unless (not (ert-test-failed-p (ert-test-most-recent-result ert-test)))) + (tramp-cleanup-connection + (tramp-dissect-file-name temporary-file-directory) nil 'keep-password) (funcall (ert-test-body ert-test))))) (ert-deftest file-notify-test00-availability () @@ -228,11 +241,11 @@ Save the result in `file-notify--test-results', for later analysis." "Check autorevert via file notification. This test is skipped in batch mode." (skip-unless (file-notify--test-local-enabled)) - (skip-unless (not noninteractive)) ;; `auto-revert-buffers' runs every 5". And we must wait, until the ;; file has been reverted. - (let ((timeout 10) - buf) + (let* ((remote (file-remote-p temporary-file-directory)) + (timeout (if remote 60 10)) + buf) (unwind-protect (progn (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)) @@ -247,7 +260,7 @@ This test is skipped in batch mode." ;; `auto-revert-buffers' runs every 5". (with-timeout (timeout (ignore)) (while (null auto-revert-notify-watch-descriptor) - (sit-for 0.1 'nodisplay))) + (sit-for 1 'nodisplay))) ;; Check, that file notification has been used. (should auto-revert-mode) @@ -269,8 +282,10 @@ This test is skipped in batch mode." (null (string-match (format "Reverting buffer `%s'." (buffer-name buf)) (buffer-string))) - (sit-for 0.1 'nodisplay)))) - (should (string-equal (buffer-string) "another text")))) + ;; We must trigger the process filter to run. + (when remote (accept-process-output nil 1)) + (sit-for 1 'nodisplay)))) + (should (string-match "another text" (buffer-string))))) ;; Exit. (ignore-errors (kill-buffer buf)) diff --git a/test/automated/tramp-tests.el b/test/automated/tramp-tests.el index 2bb815bda5a..c7087877126 100644 --- a/test/automated/tramp-tests.el +++ b/test/automated/tramp-tests.el @@ -22,14 +22,14 @@ ;; The tests require a recent ert.el from Emacs 24.4. ;; Some of the tests require access to a remote host files. Set -;; $TRAMP_TEST_TEMPORARY_FILE_DIRECTORY to a suitable value in order +;; $REMOTE_TEMPORARY_FILE_DIRECTORY to a suitable value in order ;; to overwrite the default value. If you want to skip tests ;; accessing a remote host, set this environment variable to ;; "/dev/null" or whatever is appropriate on your system. ;; When running the tests in batch mode, it must NOT require an ;; interactive password prompt unless the environment variable -;; $TRAMP_TEST_ALLOW_PASSWORD is set. +;; $REMOTE_ALLOW_PASSWORD is set. ;; A whole test run can be performed calling the command `tramp-test-all'. @@ -41,7 +41,7 @@ ;; There is no default value on w32 systems, which could work out of the box. (defconst tramp-test-temporary-file-directory (cond - ((getenv "TRAMP_TEST_TEMPORARY_FILE_DIRECTORY")) + ((getenv "REMOTE_TEMPORARY_FILE_DIRECTORY")) ((eq system-type 'windows-nt) null-device) (t (format "/ssh::%s" temporary-file-directory))) "Temporary directory for Tramp tests.") @@ -50,7 +50,7 @@ tramp-message-show-message nil) ;; Disable interactive passwords in batch mode. -(when (and noninteractive (not (getenv "TRAMP_TEST_ALLOW_PASSWORD"))) +(when (and noninteractive (not (getenv "REMOTE_ALLOW_PASSWORD"))) (defalias 'tramp-read-passwd 'ignore)) ;; This shall happen on hydra only. @@ -1193,6 +1193,12 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." ;; * set-file-selinux-context ;; * vc-registered +;; * Fix `tramp-test17-insert-directory' for +;; `ls-lisp-insert-directory' ("plink" and friends). +;; * Fix `tramp-test27-start-file-process' on MS Windows +;; (`process-send-eof'?). +;; * Fix `tramp-test29-utf8' on MS Windows. + (defun tramp-test-all (&optional interactive) "Run all tests for \\[tramp]." (interactive "p") -- 2.39.2