diff options
| author | Michael Albinus | 2014-04-18 20:58:13 +0200 |
|---|---|---|
| committer | Michael Albinus | 2014-04-18 20:58:13 +0200 |
| commit | 2a2e6726d1f7031d89fd6740e5b167476267f778 (patch) | |
| tree | 1c0c9392aeb32a96a0d67778d89ac84fff7b7851 /test | |
| parent | ce8c5107906ef282a1858c401c4400d2b54700b8 (diff) | |
| download | emacs-2a2e6726d1f7031d89fd6740e5b167476267f778.tar.gz emacs-2a2e6726d1f7031d89fd6740e5b167476267f778.zip | |
* automated/tramp-tests.el (tramp-copy-size-limit): Set to nil.
(tramp--test-make-temp-name): Optional argument LOCAL.
(tramp--instrument-test-case): Show messages. Catch also `quit'.
(tramp-test10-write-region): No special test for out-of-band copy
needed anymore.
(tramp-test11-copy-file, tramp-test12-rename-file)
(tramp-test21-file-links): Extend tests.
(tramp-test20-file-modes): More robust check for user "root".
(tramp--test-check-files): New defun.
(tramp-test30-special-characters, tramp-test33-recursive-load)
(tramp-test34-unload): New tests.
(tramp-test31-utf8, tramp-test32-asynchronous-requests): Rename.
Diffstat (limited to 'test')
| -rw-r--r-- | test/ChangeLog | 15 | ||||
| -rw-r--r-- | test/automated/tramp-tests.el | 298 |
2 files changed, 267 insertions, 46 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 8f203f68d5c..0d8dd76ff91 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | 2014-04-18 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * automated/tramp-tests.el (tramp-copy-size-limit): Set to nil. | ||
| 4 | (tramp--test-make-temp-name): Optional argument LOCAL. | ||
| 5 | (tramp--instrument-test-case): Show messages. Catch also `quit'. | ||
| 6 | (tramp-test10-write-region): No special test for out-of-band copy | ||
| 7 | needed anymore. | ||
| 8 | (tramp-test11-copy-file, tramp-test12-rename-file) | ||
| 9 | (tramp-test21-file-links): Extend tests. | ||
| 10 | (tramp-test20-file-modes): More robust check for user "root". | ||
| 11 | (tramp--test-check-files): New defun. | ||
| 12 | (tramp-test30-special-characters, tramp-test33-recursive-load) | ||
| 13 | (tramp-test34-unload): New tests. | ||
| 14 | (tramp-test31-utf8, tramp-test32-asynchronous-requests): Rename. | ||
| 15 | |||
| 1 | 2014-04-10 Paul Eggert <eggert@cs.ucla.edu> | 16 | 2014-04-10 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 17 | ||
| 3 | * automated/electric-tests.el: Fix spelling error in test name. | 18 | * automated/electric-tests.el: Fix spelling error in test name. |
diff --git a/test/automated/tramp-tests.el b/test/automated/tramp-tests.el index 7bf0ab4e9c8..dff9103c4a7 100644 --- a/test/automated/tramp-tests.el +++ b/test/automated/tramp-tests.el | |||
| @@ -56,6 +56,7 @@ | |||
| 56 | 56 | ||
| 57 | (setq password-cache-expiry nil | 57 | (setq password-cache-expiry nil |
| 58 | tramp-verbose 0 | 58 | tramp-verbose 0 |
| 59 | tramp-copy-size-limit nil | ||
| 59 | tramp-message-show-message nil) | 60 | tramp-message-show-message nil) |
| 60 | 61 | ||
| 61 | ;; Disable interactive passwords in batch mode. | 62 | ;; Disable interactive passwords in batch mode. |
| @@ -92,10 +93,11 @@ being the result.") | |||
| 92 | ;; Return result. | 93 | ;; Return result. |
| 93 | (cdr tramp--test-enabled-checked)) | 94 | (cdr tramp--test-enabled-checked)) |
| 94 | 95 | ||
| 95 | (defun tramp--test-make-temp-name () | 96 | (defun tramp--test-make-temp-name (&optional local) |
| 96 | "Create a temporary file name for test." | 97 | "Create a temporary file name for test." |
| 97 | (expand-file-name | 98 | (expand-file-name |
| 98 | (make-temp-name "tramp-test") tramp-test-temporary-file-directory)) | 99 | (make-temp-name "tramp-test") |
| 100 | (if local temporary-file-directory tramp-test-temporary-file-directory))) | ||
| 99 | 101 | ||
| 100 | (defmacro tramp--instrument-test-case (verbose &rest body) | 102 | (defmacro tramp--instrument-test-case (verbose &rest body) |
| 101 | "Run BODY with `tramp-verbose' equal VERBOSE. | 103 | "Run BODY with `tramp-verbose' equal VERBOSE. |
| @@ -103,12 +105,17 @@ Print the the content of the Tramp debug buffer, if BODY does not | |||
| 103 | eval properly in `should', `should-not' or `should-error'." | 105 | eval properly in `should', `should-not' or `should-error'." |
| 104 | (declare (indent 1) (debug (natnump body))) | 106 | (declare (indent 1) (debug (natnump body))) |
| 105 | `(let ((tramp-verbose ,verbose) | 107 | `(let ((tramp-verbose ,verbose) |
| 108 | (tramp-message-show-message t) | ||
| 106 | (tramp-debug-on-error t)) | 109 | (tramp-debug-on-error t)) |
| 107 | (condition-case err | 110 | (condition-case err |
| 108 | (progn ,@body) | 111 | ;; In general, we cannot use a timeout here: this would |
| 112 | ;; prevent traces when the test runs into an error. | ||
| 113 | ; (with-timeout (10 (ert-fail "`tramp--instrument-test-case' timed out")) | ||
| 114 | (progn | ||
| 115 | ,@body) | ||
| 109 | (ert-test-skipped | 116 | (ert-test-skipped |
| 110 | (signal (car err) (cdr err))) | 117 | (signal (car err) (cdr err))) |
| 111 | (error | 118 | ((error quit) |
| 112 | (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil | 119 | (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil |
| 113 | (with-current-buffer (tramp-get-connection-buffer v) | 120 | (with-current-buffer (tramp-get-connection-buffer v) |
| 114 | (message "%s" (buffer-string))) | 121 | (message "%s" (buffer-string))) |
| @@ -662,15 +669,7 @@ and `file-name-nondirectory'." | |||
| 662 | (write-region 3 5 tmp-name)) | 669 | (write-region 3 5 tmp-name)) |
| 663 | (with-temp-buffer | 670 | (with-temp-buffer |
| 664 | (insert-file-contents tmp-name) | 671 | (insert-file-contents tmp-name) |
| 665 | (should (string-equal (buffer-string) "34"))) | 672 | (should (string-equal (buffer-string) "34")))) |
| 666 | ;; Trigger out-of-band copy. | ||
| 667 | (let ((string "")) | ||
| 668 | (while (<= (length string) tramp-copy-size-limit) | ||
| 669 | (setq string (concat string (md5 string)))) | ||
| 670 | (write-region string nil tmp-name) | ||
| 671 | (with-temp-buffer | ||
| 672 | (insert-file-contents tmp-name) | ||
| 673 | (should (string-equal (buffer-string) string))))) | ||
| 674 | (ignore-errors (delete-file tmp-name))))) | 673 | (ignore-errors (delete-file tmp-name))))) |
| 675 | 674 | ||
| 676 | (ert-deftest tramp-test11-copy-file () | 675 | (ert-deftest tramp-test11-copy-file () |
| @@ -678,7 +677,12 @@ and `file-name-nondirectory'." | |||
| 678 | (skip-unless (tramp--test-enabled)) | 677 | (skip-unless (tramp--test-enabled)) |
| 679 | 678 | ||
| 680 | (let ((tmp-name1 (tramp--test-make-temp-name)) | 679 | (let ((tmp-name1 (tramp--test-make-temp-name)) |
| 681 | (tmp-name2 (tramp--test-make-temp-name))) | 680 | (tmp-name2 (tramp--test-make-temp-name)) |
| 681 | (tmp-name3 (tramp--test-make-temp-name)) | ||
| 682 | (tmp-name4 (tramp--test-make-temp-name 'local)) | ||
| 683 | (tmp-name5 (tramp--test-make-temp-name 'local))) | ||
| 684 | |||
| 685 | ;; Copy on remote side. | ||
| 682 | (unwind-protect | 686 | (unwind-protect |
| 683 | (progn | 687 | (progn |
| 684 | (write-region "foo" nil tmp-name1) | 688 | (write-region "foo" nil tmp-name1) |
| @@ -686,17 +690,69 @@ and `file-name-nondirectory'." | |||
| 686 | (should (file-exists-p tmp-name2)) | 690 | (should (file-exists-p tmp-name2)) |
| 687 | (with-temp-buffer | 691 | (with-temp-buffer |
| 688 | (insert-file-contents tmp-name2) | 692 | (insert-file-contents tmp-name2) |
| 689 | (should (string-equal (buffer-string) "foo")))) | 693 | (should (string-equal (buffer-string) "foo"))) |
| 690 | (ignore-errors | 694 | (should-error (copy-file tmp-name1 tmp-name2)) |
| 691 | (delete-file tmp-name1) | 695 | (copy-file tmp-name1 tmp-name2 'ok) |
| 692 | (delete-file tmp-name2))))) | 696 | (make-directory tmp-name3) |
| 697 | (copy-file tmp-name1 tmp-name3) | ||
| 698 | (should | ||
| 699 | (file-exists-p | ||
| 700 | (expand-file-name (file-name-nondirectory tmp-name1) tmp-name3)))) | ||
| 701 | (ignore-errors (delete-file tmp-name1)) | ||
| 702 | (ignore-errors (delete-file tmp-name2)) | ||
| 703 | (ignore-errors (delete-directory tmp-name3 'recursive))) | ||
| 704 | |||
| 705 | ;; Copy from remote side to local side. | ||
| 706 | (unwind-protect | ||
| 707 | (progn | ||
| 708 | (write-region "foo" nil tmp-name1) | ||
| 709 | (copy-file tmp-name1 tmp-name4) | ||
| 710 | (should (file-exists-p tmp-name4)) | ||
| 711 | (with-temp-buffer | ||
| 712 | (insert-file-contents tmp-name4) | ||
| 713 | (should (string-equal (buffer-string) "foo"))) | ||
| 714 | (should-error (copy-file tmp-name1 tmp-name4)) | ||
| 715 | (copy-file tmp-name1 tmp-name4 'ok) | ||
| 716 | (make-directory tmp-name5) | ||
| 717 | (copy-file tmp-name1 tmp-name5) | ||
| 718 | (should | ||
| 719 | (file-exists-p | ||
| 720 | (expand-file-name (file-name-nondirectory tmp-name1) tmp-name5)))) | ||
| 721 | (ignore-errors (delete-file tmp-name1)) | ||
| 722 | (ignore-errors (delete-file tmp-name4)) | ||
| 723 | (ignore-errors (delete-directory tmp-name5 'recursive))) | ||
| 724 | |||
| 725 | ;; Copy from local side to remote side. | ||
| 726 | (unwind-protect | ||
| 727 | (progn | ||
| 728 | (write-region "foo" nil tmp-name4 nil 'nomessage) | ||
| 729 | (copy-file tmp-name4 tmp-name1) | ||
| 730 | (should (file-exists-p tmp-name1)) | ||
| 731 | (with-temp-buffer | ||
| 732 | (insert-file-contents tmp-name1) | ||
| 733 | (should (string-equal (buffer-string) "foo"))) | ||
| 734 | (should-error (copy-file tmp-name4 tmp-name1)) | ||
| 735 | (copy-file tmp-name4 tmp-name1 'ok) | ||
| 736 | (make-directory tmp-name3) | ||
| 737 | (copy-file tmp-name4 tmp-name3) | ||
| 738 | (should | ||
| 739 | (file-exists-p | ||
| 740 | (expand-file-name (file-name-nondirectory tmp-name4) tmp-name3)))) | ||
| 741 | (ignore-errors (delete-file tmp-name1)) | ||
| 742 | (ignore-errors (delete-file tmp-name4)) | ||
| 743 | (ignore-errors (delete-directory tmp-name3 'recursive))))) | ||
| 693 | 744 | ||
| 694 | (ert-deftest tramp-test12-rename-file () | 745 | (ert-deftest tramp-test12-rename-file () |
| 695 | "Check `rename-file'." | 746 | "Check `rename-file'." |
| 696 | (skip-unless (tramp--test-enabled)) | 747 | (skip-unless (tramp--test-enabled)) |
| 697 | 748 | ||
| 698 | (let ((tmp-name1 (tramp--test-make-temp-name)) | 749 | (let ((tmp-name1 (tramp--test-make-temp-name)) |
| 699 | (tmp-name2 (tramp--test-make-temp-name))) | 750 | (tmp-name2 (tramp--test-make-temp-name)) |
| 751 | (tmp-name3 (tramp--test-make-temp-name)) | ||
| 752 | (tmp-name4 (tramp--test-make-temp-name 'local)) | ||
| 753 | (tmp-name5 (tramp--test-make-temp-name 'local))) | ||
| 754 | |||
| 755 | ;; Rename on remote side. | ||
| 700 | (unwind-protect | 756 | (unwind-protect |
| 701 | (progn | 757 | (progn |
| 702 | (write-region "foo" nil tmp-name1) | 758 | (write-region "foo" nil tmp-name1) |
| @@ -705,8 +761,71 @@ and `file-name-nondirectory'." | |||
| 705 | (should (file-exists-p tmp-name2)) | 761 | (should (file-exists-p tmp-name2)) |
| 706 | (with-temp-buffer | 762 | (with-temp-buffer |
| 707 | (insert-file-contents tmp-name2) | 763 | (insert-file-contents tmp-name2) |
| 708 | (should (string-equal (buffer-string) "foo")))) | 764 | (should (string-equal (buffer-string) "foo"))) |
| 709 | (ignore-errors (delete-file tmp-name2))))) | 765 | (write-region "foo" nil tmp-name1) |
| 766 | (should-error (rename-file tmp-name1 tmp-name2)) | ||
| 767 | (rename-file tmp-name1 tmp-name2 'ok) | ||
| 768 | (should-not (file-exists-p tmp-name1)) | ||
| 769 | (write-region "foo" nil tmp-name1) | ||
| 770 | (make-directory tmp-name3) | ||
| 771 | (rename-file tmp-name1 tmp-name3) | ||
| 772 | (should-not (file-exists-p tmp-name1)) | ||
| 773 | (should | ||
| 774 | (file-exists-p | ||
| 775 | (expand-file-name (file-name-nondirectory tmp-name1) tmp-name3)))) | ||
| 776 | (ignore-errors (delete-file tmp-name1)) | ||
| 777 | (ignore-errors (delete-file tmp-name2)) | ||
| 778 | (ignore-errors (delete-directory tmp-name3 'recursive))) | ||
| 779 | |||
| 780 | ;; Rename from remote side to local side. | ||
| 781 | (unwind-protect | ||
| 782 | (progn | ||
| 783 | (write-region "foo" nil tmp-name1) | ||
| 784 | (rename-file tmp-name1 tmp-name4) | ||
| 785 | (should-not (file-exists-p tmp-name1)) | ||
| 786 | (should (file-exists-p tmp-name4)) | ||
| 787 | (with-temp-buffer | ||
| 788 | (insert-file-contents tmp-name4) | ||
| 789 | (should (string-equal (buffer-string) "foo"))) | ||
| 790 | (write-region "foo" nil tmp-name1) | ||
| 791 | (should-error (rename-file tmp-name1 tmp-name4)) | ||
| 792 | (rename-file tmp-name1 tmp-name4 'ok) | ||
| 793 | (should-not (file-exists-p tmp-name1)) | ||
| 794 | (write-region "foo" nil tmp-name1) | ||
| 795 | (make-directory tmp-name5) | ||
| 796 | (rename-file tmp-name1 tmp-name5) | ||
| 797 | (should-not (file-exists-p tmp-name1)) | ||
| 798 | (should | ||
| 799 | (file-exists-p | ||
| 800 | (expand-file-name (file-name-nondirectory tmp-name1) tmp-name5)))) | ||
| 801 | (ignore-errors (delete-file tmp-name1)) | ||
| 802 | (ignore-errors (delete-file tmp-name4)) | ||
| 803 | (ignore-errors (delete-directory tmp-name5 'recursive))) | ||
| 804 | |||
| 805 | ;; Rename from local side to remote side. | ||
| 806 | (unwind-protect | ||
| 807 | (progn | ||
| 808 | (write-region "foo" nil tmp-name4 nil 'nomessage) | ||
| 809 | (rename-file tmp-name4 tmp-name1) | ||
| 810 | (should-not (file-exists-p tmp-name4)) | ||
| 811 | (should (file-exists-p tmp-name1)) | ||
| 812 | (with-temp-buffer | ||
| 813 | (insert-file-contents tmp-name1) | ||
| 814 | (should (string-equal (buffer-string) "foo"))) | ||
| 815 | (write-region "foo" nil tmp-name4 nil 'nomessage) | ||
| 816 | (should-error (rename-file tmp-name4 tmp-name1)) | ||
| 817 | (rename-file tmp-name4 tmp-name1 'ok) | ||
| 818 | (should-not (file-exists-p tmp-name4)) | ||
| 819 | (write-region "foo" nil tmp-name4 nil 'nomessage) | ||
| 820 | (make-directory tmp-name3) | ||
| 821 | (rename-file tmp-name4 tmp-name3) | ||
| 822 | (should-not (file-exists-p tmp-name4)) | ||
| 823 | (should | ||
| 824 | (file-exists-p | ||
| 825 | (expand-file-name (file-name-nondirectory tmp-name4) tmp-name3)))) | ||
| 826 | (ignore-errors (delete-file tmp-name1)) | ||
| 827 | (ignore-errors (delete-file tmp-name4)) | ||
| 828 | (ignore-errors (delete-directory tmp-name3 'recursive))))) | ||
| 710 | 829 | ||
| 711 | (ert-deftest tramp-test13-make-directory () | 830 | (ert-deftest tramp-test13-make-directory () |
| 712 | "Check `make-directory'. | 831 | "Check `make-directory'. |
| @@ -930,7 +1049,7 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'." | |||
| 930 | (should (= (file-modes tmp-name) #o444)) | 1049 | (should (= (file-modes tmp-name) #o444)) |
| 931 | (should-not (file-executable-p tmp-name)) | 1050 | (should-not (file-executable-p tmp-name)) |
| 932 | ;; A file is always writable for user "root". | 1051 | ;; A file is always writable for user "root". |
| 933 | (when (not (string-equal (file-remote-p tmp-name 'user) "root")) | 1052 | (unless (zerop (nth 2 (file-attributes tmp-name))) |
| 934 | (should-not (file-writable-p tmp-name)))) | 1053 | (should-not (file-writable-p tmp-name)))) |
| 935 | (ignore-errors (delete-file tmp-name))))) | 1054 | (ignore-errors (delete-file tmp-name))))) |
| 936 | 1055 | ||
| @@ -941,7 +1060,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 941 | 1060 | ||
| 942 | (let ((tmp-name1 (tramp--test-make-temp-name)) | 1061 | (let ((tmp-name1 (tramp--test-make-temp-name)) |
| 943 | (tmp-name2 (tramp--test-make-temp-name)) | 1062 | (tmp-name2 (tramp--test-make-temp-name)) |
| 944 | (tmp-name3 (make-temp-name "tramp-"))) | 1063 | (tmp-name3 (tramp--test-make-temp-name 'local))) |
| 945 | (unwind-protect | 1064 | (unwind-protect |
| 946 | (progn | 1065 | (progn |
| 947 | (write-region "foo" nil tmp-name1) | 1066 | (write-region "foo" nil tmp-name1) |
| @@ -988,16 +1107,18 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 988 | (should (file-symlink-p tmp-name2)) | 1107 | (should (file-symlink-p tmp-name2)) |
| 989 | (should-not (string-equal tmp-name2 (file-truename tmp-name2))) | 1108 | (should-not (string-equal tmp-name2 (file-truename tmp-name2))) |
| 990 | (should | 1109 | (should |
| 991 | (string-equal (file-truename tmp-name1) (file-truename tmp-name2)))) | 1110 | (string-equal (file-truename tmp-name1) (file-truename tmp-name2))) |
| 1111 | (should (file-equal-p tmp-name1 tmp-name2))) | ||
| 992 | (ignore-errors | 1112 | (ignore-errors |
| 993 | (delete-file tmp-name1) | 1113 | (delete-file tmp-name1) |
| 994 | (delete-file tmp-name2))) | 1114 | (delete-file tmp-name2))) |
| 995 | 1115 | ||
| 996 | ;; `file-truename' shall preserve trailing link of directories. | 1116 | ;; `file-truename' shall preserve trailing link of directories. |
| 997 | (let* ((dir1 (directory-file-name tramp-test-temporary-file-directory)) | 1117 | (unless (file-symlink-p tramp-test-temporary-file-directory) |
| 998 | (dir2 (file-name-as-directory dir1))) | 1118 | (let* ((dir1 (directory-file-name tramp-test-temporary-file-directory)) |
| 999 | (should (string-equal (file-truename dir1) (expand-file-name dir1))) | 1119 | (dir2 (file-name-as-directory dir1))) |
| 1000 | (should (string-equal (file-truename dir2) (expand-file-name dir2)))))) | 1120 | (should (string-equal (file-truename dir1) (expand-file-name dir1))) |
| 1121 | (should (string-equal (file-truename dir2) (expand-file-name dir2))))))) | ||
| 1001 | 1122 | ||
| 1002 | (ert-deftest tramp-test22-file-times () | 1123 | (ert-deftest tramp-test22-file-times () |
| 1003 | "Check `set-file-times' and `file-newer-than-file-p'." | 1124 | "Check `set-file-times' and `file-newer-than-file-p'." |
| @@ -1295,35 +1416,61 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 1295 | 1416 | ||
| 1296 | (ignore-errors (delete-directory tmp-name1 'recursive))))) | 1417 | (ignore-errors (delete-directory tmp-name1 'recursive))))) |
| 1297 | 1418 | ||
| 1298 | (ert-deftest tramp-test30-utf8 () | 1419 | (defun tramp--test-check-files (&rest files) |
| 1299 | "Check UTF8 encoding in file names and file contents." | 1420 | "Runs a simple but comprehensive test over every file in FILES." |
| 1300 | (skip-unless (tramp--test-enabled)) | 1421 | (let ((tmp-name (tramp--test-make-temp-name))) |
| 1301 | |||
| 1302 | (let ((tmp-name (tramp--test-make-temp-name)) | ||
| 1303 | (coding-system-for-read 'utf-8) | ||
| 1304 | (coding-system-for-write 'utf-8) | ||
| 1305 | (arabic "أصبح بوسعك الآن تنزيل نسخة كاملة من موسوعة ويكيبيديا العربية لتصفحها بلا اتصال بالإنترنت") | ||
| 1306 | (chinese "银河系漫游指南系列") | ||
| 1307 | (russian "Автостопом по гала́ктике")) | ||
| 1308 | (unwind-protect | 1422 | (unwind-protect |
| 1309 | (progn | 1423 | (progn |
| 1310 | (make-directory tmp-name) | 1424 | (make-directory tmp-name) |
| 1311 | (dolist (lang `(,arabic ,chinese ,russian)) | 1425 | (dolist (elt files) |
| 1312 | (let ((file (expand-file-name lang tmp-name))) | 1426 | (let ((file (expand-file-name elt tmp-name))) |
| 1313 | (write-region lang nil file) | 1427 | (write-region elt nil file) |
| 1314 | (should (file-exists-p file)) | 1428 | (should (file-exists-p file)) |
| 1315 | ;; Check file contents. | 1429 | ;; Check file contents. |
| 1316 | (with-temp-buffer | 1430 | (with-temp-buffer |
| 1317 | (insert-file-contents file) | 1431 | (insert-file-contents file) |
| 1318 | (should (string-equal (buffer-string) lang))))) | 1432 | (should (string-equal (buffer-string) elt))))) |
| 1319 | ;; Check file names. | 1433 | ;; Check file names. |
| 1320 | (should (equal (directory-files | 1434 | (should (equal (directory-files |
| 1321 | tmp-name nil directory-files-no-dot-files-regexp) | 1435 | tmp-name nil directory-files-no-dot-files-regexp) |
| 1322 | (sort `(,arabic ,chinese ,russian) 'string-lessp)))) | 1436 | (sort files 'string-lessp)))) |
| 1323 | (ignore-errors (delete-directory tmp-name 'recursive))))) | 1437 | (ignore-errors (delete-directory tmp-name 'recursive))))) |
| 1324 | 1438 | ||
| 1439 | ;; This test is inspired by Bug#17238. | ||
| 1440 | (ert-deftest tramp-test30-special-characters () | ||
| 1441 | "Check special characters in file names." | ||
| 1442 | (skip-unless (tramp--test-enabled)) | ||
| 1443 | |||
| 1444 | ;; Newlines and slashes in file names are not supported. So we don't test. | ||
| 1445 | (tramp--test-check-files | ||
| 1446 | " foo bar\tbaz " | ||
| 1447 | "$foo$bar$$baz$" | ||
| 1448 | "-foo-bar-baz-" | ||
| 1449 | "%foo%bar%baz%" | ||
| 1450 | "&foo&bar&baz&" | ||
| 1451 | "?foo?bar?baz?" | ||
| 1452 | "*foo*bar*baz*" | ||
| 1453 | "'foo\"bar'baz\"" | ||
| 1454 | "\\foo\\bar\\baz\\" | ||
| 1455 | "#foo#bar#baz#" | ||
| 1456 | "!foo|bar!baz|" | ||
| 1457 | ":foo;bar:baz;" | ||
| 1458 | "<foo>bar<baz>" | ||
| 1459 | "(foo)bar(baz)")) | ||
| 1460 | |||
| 1461 | (ert-deftest tramp-test31-utf8 () | ||
| 1462 | "Check UTF8 encoding in file names and file contents." | ||
| 1463 | (skip-unless (tramp--test-enabled)) | ||
| 1464 | |||
| 1465 | (let ((coding-system-for-read 'utf-8) | ||
| 1466 | (coding-system-for-write 'utf-8)) | ||
| 1467 | (tramp--test-check-files | ||
| 1468 | "أصبح بوسعك الآن تنزيل نسخة كاملة من موسوعة ويكيبيديا العربية لتصفحها بلا اتصال بالإنترنت" | ||
| 1469 | "银河系漫游指南系列" | ||
| 1470 | "Автостопом по гала́ктике"))) | ||
| 1471 | |||
| 1325 | ;; This test is inspired by Bug#16928. | 1472 | ;; This test is inspired by Bug#16928. |
| 1326 | (ert-deftest tramp-test31-asynchronous-requests () | 1473 | (ert-deftest tramp-test32-asynchronous-requests () |
| 1327 | "Check parallel asynchronous requests. | 1474 | "Check parallel asynchronous requests. |
| 1328 | Such requests could arrive from timers, process filters and | 1475 | Such requests could arrive from timers, process filters and |
| 1329 | process sentinels. They shall not disturb each other." | 1476 | process sentinels. They shall not disturb each other." |
| @@ -1412,6 +1559,62 @@ process sentinels. They shall not disturb each other." | |||
| 1412 | (dolist (buf buffers) | 1559 | (dolist (buf buffers) |
| 1413 | (ignore-errors (kill-buffer buf))))))) | 1560 | (ignore-errors (kill-buffer buf))))))) |
| 1414 | 1561 | ||
| 1562 | (ert-deftest tramp-test33-recursive-load () | ||
| 1563 | "Check that Tramp does not fail due to recursive load." | ||
| 1564 | (skip-unless (tramp--test-enabled)) | ||
| 1565 | |||
| 1566 | (dolist (code | ||
| 1567 | (list | ||
| 1568 | (format | ||
| 1569 | "(expand-file-name %S))" | ||
| 1570 | tramp-test-temporary-file-directory) | ||
| 1571 | (format | ||
| 1572 | "(let ((default-directory %S)) (expand-file-name %S))" | ||
| 1573 | tramp-test-temporary-file-directory | ||
| 1574 | temporary-file-directory))) | ||
| 1575 | (should-not | ||
| 1576 | (string-match | ||
| 1577 | "Recursive load" | ||
| 1578 | (shell-command-to-string | ||
| 1579 | (format | ||
| 1580 | "%s -batch -Q -L %s --eval %s" | ||
| 1581 | (expand-file-name invocation-name invocation-directory) | ||
| 1582 | (mapconcat 'shell-quote-argument load-path " -L ") | ||
| 1583 | (shell-quote-argument code))))))) | ||
| 1584 | |||
| 1585 | (ert-deftest tramp-test34-unload () | ||
| 1586 | "Check that Tramp and its subpackages unload completely. | ||
| 1587 | Since it unloads Tramp, it shall be the last test to run." | ||
| 1588 | ;; Mark as failed until all symbols are unbound. | ||
| 1589 | :expected-result (if (featurep 'tramp) :failed :passed) | ||
| 1590 | (when (featurep 'tramp) | ||
| 1591 | (unload-feature 'tramp 'force) | ||
| 1592 | ;; No Tramp feature must be left. | ||
| 1593 | (should-not (featurep 'tramp)) | ||
| 1594 | (should-not (all-completions "tramp" (delq 'tramp-tests features))) | ||
| 1595 | ;; `file-name-handler-alist' must be clean. | ||
| 1596 | (should-not (all-completions "tramp" (mapcar 'cdr file-name-handler-alist))) | ||
| 1597 | ;; There shouldn't be left a bound symbol. We do not regard our | ||
| 1598 | ;; test symbols, and the Tramp unload hooks. | ||
| 1599 | (mapatoms | ||
| 1600 | (lambda (x) | ||
| 1601 | (and (or (boundp x) (functionp x)) | ||
| 1602 | (string-match "^tramp" (symbol-name x)) | ||
| 1603 | (not (string-match "^tramp--?test" (symbol-name x))) | ||
| 1604 | (not (string-match "unload-hook$" (symbol-name x))) | ||
| 1605 | (ert-fail (format "`%s' still bound" x))))) | ||
| 1606 | ; (progn (message "`%s' still bound" x))))) | ||
| 1607 | ;; There shouldn't be left a hook function containing a Tramp | ||
| 1608 | ;; function. We do not regard the Tramp unload hooks. | ||
| 1609 | (mapatoms | ||
| 1610 | (lambda (x) | ||
| 1611 | (and (boundp x) | ||
| 1612 | (string-match "-hooks?$" (symbol-name x)) | ||
| 1613 | (not (string-match "unload-hook$" (symbol-name x))) | ||
| 1614 | (consp (symbol-value x)) | ||
| 1615 | (ignore-errors (all-completions "tramp" (symbol-value x))) | ||
| 1616 | (ert-fail (format "Hook `%s' still contains Tramp function" x))))))) | ||
| 1617 | |||
| 1415 | ;; TODO: | 1618 | ;; TODO: |
| 1416 | 1619 | ||
| 1417 | ;; * dired-compress-file | 1620 | ;; * dired-compress-file |
| @@ -1426,8 +1629,11 @@ process sentinels. They shall not disturb each other." | |||
| 1426 | 1629 | ||
| 1427 | ;; * Fix `tramp-test27-start-file-process' on MS Windows (`process-send-eof'?). | 1630 | ;; * Fix `tramp-test27-start-file-process' on MS Windows (`process-send-eof'?). |
| 1428 | ;; * Fix `tramp-test28-shell-command' on MS Windows (nasty plink message). | 1631 | ;; * Fix `tramp-test28-shell-command' on MS Windows (nasty plink message). |
| 1429 | ;; * Fix `tramp-test30-utf8' on MS Windows. Seems to be in `directory-files'. | 1632 | ;; * Fix `tramp-test31-utf8' for MS Windows and `nc'/`telnet' (when |
| 1430 | ;; * Fix Bug#16928. Set expected error of `tramp-test31-asynchronous-requests'. | 1633 | ;; target is a dumb busybox). Seems to be in `directory-files'. |
| 1634 | ;; * Fix Bug#16928. Set expected error of `tramp-test32-asynchronous-requests'. | ||
| 1635 | ;; * Fix `tramp-test34-unload' (Not all symbols are unbound). Set | ||
| 1636 | ;; expected error. | ||
| 1431 | 1637 | ||
| 1432 | (defun tramp-test-all (&optional interactive) | 1638 | (defun tramp-test-all (&optional interactive) |
| 1433 | "Run all tests for \\[tramp]." | 1639 | "Run all tests for \\[tramp]." |