diff options
| author | Michael Albinus | 2013-11-11 16:22:57 +0100 |
|---|---|---|
| committer | Michael Albinus | 2013-11-11 16:22:57 +0100 |
| commit | 8ee0219ffe51c77293ded1633c9edff816c151d7 (patch) | |
| tree | 16a17bd263cdddab8a35b9352062f7c5dcd156d8 | |
| parent | 7ce8fcc3224e694afb7add9461e56687ad317868 (diff) | |
| download | emacs-8ee0219ffe51c77293ded1633c9edff816c151d7.tar.gz emacs-8ee0219ffe51c77293ded1633c9edff816c151d7.zip | |
* automated/tramp-tests.el (tramp-test-temporary-file-directory):
Check $TRAMP_TEST_TEMPORARY_FILE_DIRECTORY.
(tramp-read-passwd): Check $TRAMP_TEST_ALLOW_PASSWORD.
(tramp-test09-insert-file-contents, tramp-test10-write-region):
(tramp-test26-process-file): Add tests.
(tramp-test11-copy-file): Remove debug message.
(tramp-test20-file-modes): Special case, if user is "root".
| -rw-r--r-- | test/ChangeLog | 10 | ||||
| -rw-r--r-- | test/automated/tramp-tests.el | 86 |
2 files changed, 72 insertions, 24 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 95827d65cf6..eb307a04102 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2013-11-11 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * automated/tramp-tests.el (tramp-test-temporary-file-directory): | ||
| 4 | Check $TRAMP_TEST_TEMPORARY_FILE_DIRECTORY. | ||
| 5 | (tramp-read-passwd): Check $TRAMP_TEST_ALLOW_PASSWORD. | ||
| 6 | (tramp-test09-insert-file-contents, tramp-test10-write-region): | ||
| 7 | (tramp-test26-process-file): Add tests. | ||
| 8 | (tramp-test11-copy-file): Remove debug message. | ||
| 9 | (tramp-test20-file-modes): Special case, if user is "root". | ||
| 10 | |||
| 1 | 2013-11-08 Michael Albinus <michael.albinus@gmx.de> | 11 | 2013-11-08 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 12 | ||
| 3 | * automated/file-notify-tests.el: | 13 | * automated/file-notify-tests.el: |
diff --git a/test/automated/tramp-tests.el b/test/automated/tramp-tests.el index 538def94a80..8cdc355a7a1 100644 --- a/test/automated/tramp-tests.el +++ b/test/automated/tramp-tests.el | |||
| @@ -22,12 +22,14 @@ | |||
| 22 | ;; The tests require a recent ert.el from Emacs 24.4. | 22 | ;; The tests require a recent ert.el from Emacs 24.4. |
| 23 | 23 | ||
| 24 | ;; Some of the tests require access to a remote host files. Set | 24 | ;; Some of the tests require access to a remote host files. Set |
| 25 | ;; `tramp-test-temporary-file-directory' to a suitable value. It must | 25 | ;; $TRAMP_TEST_TEMPORARY_FILE_DIRECTORY to a suitable value in order |
| 26 | ;; NOT require an interactive password prompt, when running the tests | 26 | ;; to overwrite the default value. If you want to skip tests |
| 27 | ;; in batch mode. | 27 | ;; accessing a remote host, set this environment variable to |
| 28 | ;; "/dev/null" or whatever is appropriate on your system. | ||
| 28 | 29 | ||
| 29 | ;; If you want to skip tests accessing a remote host, set this | 30 | ;; When running the tests in batch mode, it must NOT require an |
| 30 | ;; variable to `null-device'. | 31 | ;; interactive password prompt unless the environment variable |
| 32 | ;; $TRAMP_TEST_ALLOW_PASSWORD is set. | ||
| 31 | 33 | ||
| 32 | ;; A whole test run can be performed calling the command `tramp-test-all'. | 34 | ;; A whole test run can be performed calling the command `tramp-test-all'. |
| 33 | 35 | ||
| @@ -38,12 +40,19 @@ | |||
| 38 | 40 | ||
| 39 | ;; There is no default value on w32 systems, which could work out of the box. | 41 | ;; There is no default value on w32 systems, which could work out of the box. |
| 40 | (defconst tramp-test-temporary-file-directory | 42 | (defconst tramp-test-temporary-file-directory |
| 41 | (if (eq system-type 'windows-nt) null-device "/ssh::/tmp") | 43 | (cond |
| 44 | ((getenv "TRAMP_TEST_TEMPORARY_FILE_DIRECTORY")) | ||
| 45 | ((eq system-type 'windows-nt) null-device) | ||
| 46 | (t (format "/ssh::%s" temporary-file-directory))) | ||
| 42 | "Temporary directory for Tramp tests.") | 47 | "Temporary directory for Tramp tests.") |
| 43 | 48 | ||
| 44 | (setq tramp-verbose 0 | 49 | (setq tramp-verbose 0 |
| 45 | tramp-message-show-message nil) | 50 | tramp-message-show-message nil) |
| 46 | (when noninteractive (defalias 'tramp-read-passwd 'ignore)) | 51 | |
| 52 | ;; Disable interactive passwords in batch mode. | ||
| 53 | (when (and noninteractive (not (getenv "TRAMP_TEST_ALLOW_PASSWORD"))) | ||
| 54 | (defalias 'tramp-read-passwd 'ignore)) | ||
| 55 | |||
| 47 | ;; This shall happen on hydra only. | 56 | ;; This shall happen on hydra only. |
| 48 | (when (getenv "NIX_STORE") | 57 | (when (getenv "NIX_STORE") |
| 49 | (add-to-list 'tramp-remote-path 'tramp-own-remote-path)) | 58 | (add-to-list 'tramp-remote-path 'tramp-own-remote-path)) |
| @@ -542,6 +551,14 @@ and `file-name-nondirectory'." | |||
| 542 | (write-region "foo" nil tmp-name) | 551 | (write-region "foo" nil tmp-name) |
| 543 | (with-temp-buffer | 552 | (with-temp-buffer |
| 544 | (insert-file-contents tmp-name) | 553 | (insert-file-contents tmp-name) |
| 554 | (should (string-equal (buffer-string) "foo")) | ||
| 555 | (insert-file-contents tmp-name) | ||
| 556 | (should (string-equal (buffer-string) "foofoo")) | ||
| 557 | ;; Insert partly. | ||
| 558 | (insert-file-contents tmp-name nil 1 3) | ||
| 559 | (should (string-equal (buffer-string) "oofoofoo")) | ||
| 560 | ;; Replace. | ||
| 561 | (insert-file-contents tmp-name nil nil nil 'replace) | ||
| 545 | (should (string-equal (buffer-string) "foo")))) | 562 | (should (string-equal (buffer-string) "foo")))) |
| 546 | (ignore-errors (delete-file tmp-name))))) | 563 | (ignore-errors (delete-file tmp-name))))) |
| 547 | 564 | ||
| @@ -556,15 +573,33 @@ and `file-name-nondirectory'." | |||
| 556 | (write-region nil nil tmp-name)) | 573 | (write-region nil nil tmp-name)) |
| 557 | (with-temp-buffer | 574 | (with-temp-buffer |
| 558 | (insert-file-contents tmp-name) | 575 | (insert-file-contents tmp-name) |
| 559 | (should (string-equal (buffer-string) "foo")))) | 576 | (should (string-equal (buffer-string) "foo"))) |
| 560 | (ignore-errors (delete-file tmp-name))))) | 577 | ;; Append. |
| 578 | (with-temp-buffer | ||
| 579 | (insert "bla") | ||
| 580 | (write-region nil nil tmp-name 'append)) | ||
| 581 | (with-temp-buffer | ||
| 582 | (insert-file-contents tmp-name) | ||
| 583 | (should (string-equal (buffer-string) "foobla"))) | ||
| 584 | ;; Write string. | ||
| 585 | (write-region "foo" nil tmp-name) | ||
| 586 | (with-temp-buffer | ||
| 587 | (insert-file-contents tmp-name) | ||
| 588 | (should (string-equal (buffer-string) "foo"))) | ||
| 589 | ;; Write partly. | ||
| 590 | (with-temp-buffer | ||
| 591 | (insert "123456789") | ||
| 592 | (write-region 3 5 tmp-name)) | ||
| 593 | (with-temp-buffer | ||
| 594 | (insert-file-contents tmp-name) | ||
| 595 | (should (string-equal (buffer-string) "34")))) | ||
| 596 | (ignore-errors (delete-file tmp-name))))) | ||
| 561 | 597 | ||
| 562 | (ert-deftest tramp-test11-copy-file () | 598 | (ert-deftest tramp-test11-copy-file () |
| 563 | "Check `copy-file'." | 599 | "Check `copy-file'." |
| 564 | (skip-unless (tramp--test-enabled)) | 600 | (skip-unless (tramp--test-enabled)) |
| 565 | (let ((tmp-name1 (tramp--test-make-temp-name)) | 601 | (let ((tmp-name1 (tramp--test-make-temp-name)) |
| 566 | (tmp-name2 (tramp--test-make-temp-name))) | 602 | (tmp-name2 (tramp--test-make-temp-name))) |
| 567 | (message "%s %s" tmp-name1 tmp-name2) | ||
| 568 | (unwind-protect | 603 | (unwind-protect |
| 569 | (progn | 604 | (progn |
| 570 | (write-region "foo" nil tmp-name1) | 605 | (write-region "foo" nil tmp-name1) |
| @@ -779,22 +814,22 @@ This tests also `file-readable-p' and `file-regular-p'." | |||
| 779 | "Check `file-modes'. | 814 | "Check `file-modes'. |
| 780 | This tests also `file-executable-p', `file-writable-p' and `set-file-modes'." | 815 | This tests also `file-executable-p', `file-writable-p' and `set-file-modes'." |
| 781 | (skip-unless (tramp--test-enabled)) | 816 | (skip-unless (tramp--test-enabled)) |
| 782 | (let ((tmp-name1 (tramp--test-make-temp-name)) | 817 | (let ((tmp-name (tramp--test-make-temp-name))) |
| 783 | (tmp-name2 (tramp--test-make-temp-name))) | ||
| 784 | (unwind-protect | 818 | (unwind-protect |
| 785 | (progn | 819 | (progn |
| 786 | (write-region "foo" nil tmp-name1) | 820 | (write-region "foo" nil tmp-name) |
| 787 | (should (file-exists-p tmp-name1)) | 821 | (should (file-exists-p tmp-name)) |
| 788 | (set-file-modes tmp-name1 #o777) | 822 | (set-file-modes tmp-name #o777) |
| 789 | (should (= (file-modes tmp-name1) #o777)) | 823 | (should (= (file-modes tmp-name) #o777)) |
| 790 | (should (file-executable-p tmp-name1)) | 824 | (should (file-executable-p tmp-name)) |
| 791 | (should (file-writable-p tmp-name1)) | 825 | (should (file-writable-p tmp-name)) |
| 792 | (set-file-modes tmp-name1 #o444) | 826 | (set-file-modes tmp-name #o444) |
| 793 | (should (= (file-modes tmp-name1) #o444)) | 827 | (should (= (file-modes tmp-name) #o444)) |
| 794 | (should-not (file-executable-p tmp-name1)) | 828 | (should-not (file-executable-p tmp-name)) |
| 795 | (should-not (file-writable-p tmp-name1))) | 829 | ;; A file is always writable for user "root". |
| 796 | (delete-file tmp-name1) | 830 | (unless (string-equal (file-remote-p tmp-name 'user) "root") |
| 797 | (delete-file tmp-name2)))) | 831 | (should-not (file-writable-p tmp-name)))) |
| 832 | (delete-file tmp-name)))) | ||
| 798 | 833 | ||
| 799 | (ert-deftest tramp-test21-file-links () | 834 | (ert-deftest tramp-test21-file-links () |
| 800 | "Check `file-symlink-p'. | 835 | "Check `file-symlink-p'. |
| @@ -921,8 +956,11 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 921 | "Check `process-file'." | 956 | "Check `process-file'." |
| 922 | (skip-unless (tramp--test-enabled)) | 957 | (skip-unless (tramp--test-enabled)) |
| 923 | (let ((default-directory tramp-test-temporary-file-directory)) | 958 | (let ((default-directory tramp-test-temporary-file-directory)) |
| 959 | ;; We cannot use "/bin/true" and "/bin/false"; those paths do not | ||
| 960 | ;; exist on hydra. | ||
| 924 | (should (zerop (process-file "true"))) | 961 | (should (zerop (process-file "true"))) |
| 925 | (should-not (zerop (process-file "false"))) | 962 | (should-not (zerop (process-file "false"))) |
| 963 | (should-not (zerop (process-file "binary-does-not-exist"))) | ||
| 926 | (with-temp-buffer | 964 | (with-temp-buffer |
| 927 | (should (zerop (process-file "ls" nil t))) | 965 | (should (zerop (process-file "ls" nil t))) |
| 928 | (should (> (point-max) (point-min)))))) | 966 | (should (> (point-max) (point-min)))))) |