diff options
| author | Michael Albinus | 2017-05-08 17:27:50 +0200 |
|---|---|---|
| committer | Michael Albinus | 2017-05-08 17:27:50 +0200 |
| commit | 73e3ed48e21287d48fda8d04e55f8b79b526ca50 (patch) | |
| tree | 0469f5c6bc24befa0e6651ad970a12cb31c46e8e /test | |
| parent | 52f7440b8ea8e18f7e83f8d107bd5e4df1bda7b1 (diff) | |
| download | emacs-73e3ed48e21287d48fda8d04e55f8b79b526ca50.tar.gz emacs-73e3ed48e21287d48fda8d04e55f8b79b526ca50.zip | |
Handle `write-region' messages in Tramp properly
* lisp/net/tramp.el (tramp-handle-write-region-message): New defsubst.
* lisp/net/tramp-adb.el (tramp-adb-handle-write-region):
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-write-region):
* lisp/net/tramp-sh.el (tramp-sh-handle-write-region):
* lisp/net/tramp-smb.el (tramp-smb-handle-write-region): Use it.
* lisp/net/tramp.el (tramp-password-prompt-regexp)
(tramp-completion-mode-p):
* lisp/net/tramp-cmds.el (tramp-reporter-dump-variable)
(tramp-append-tramp-buffers):
* lisp/net/tramp-smb.el (tramp-smb-maybe-open-connection):
Use `bound-and-true-p'.
* lisp/net/tramp-compat.el (tramp-compat-delete-file):
Don't check for `boundp' anymore.
* test/lisp/net/tramp-tests.el (ert-x): Require it.
(tramp--test-messages): New defvar.
(tramp-test10-write-region): Extend test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 8db54979b6d..742bdfd9348 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -39,6 +39,7 @@ | |||
| 39 | 39 | ||
| 40 | (require 'dired) | 40 | (require 'dired) |
| 41 | (require 'ert) | 41 | (require 'ert) |
| 42 | (require 'ert-x) | ||
| 42 | (require 'tramp) | 43 | (require 'tramp) |
| 43 | (require 'vc) | 44 | (require 'vc) |
| 44 | (require 'vc-bzr) | 45 | (require 'vc-bzr) |
| @@ -80,6 +81,9 @@ | |||
| 80 | (when (getenv "NIX_STORE") | 81 | (when (getenv "NIX_STORE") |
| 81 | (add-to-list 'tramp-remote-path 'tramp-own-remote-path)) | 82 | (add-to-list 'tramp-remote-path 'tramp-own-remote-path)) |
| 82 | 83 | ||
| 84 | (defvar tramp--test-messages nil | ||
| 85 | "Captured messages from *Messages* buffer.") | ||
| 86 | |||
| 83 | (defvar tramp--test-expensive-test | 87 | (defvar tramp--test-expensive-test |
| 84 | (null | 88 | (null |
| 85 | (string-equal (getenv "SELECTOR") "(quote (not (tag :expensive-test)))")) | 89 | (string-equal (getenv "SELECTOR") "(quote (not (tag :expensive-test)))")) |
| @@ -1741,31 +1745,77 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 1741 | (skip-unless (tramp--test-enabled)) | 1745 | (skip-unless (tramp--test-enabled)) |
| 1742 | 1746 | ||
| 1743 | (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) | 1747 | (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) |
| 1744 | (let ((tmp-name (tramp--test-make-temp-name nil quoted))) | 1748 | (let* ((tmp-name (tramp--test-make-temp-name nil quoted)) |
| 1749 | (text-quoting-style 'grave) | ||
| 1750 | (write-region-verbose | ||
| 1751 | (and (null noninteractive) (boundp 'write-region-verbose))) | ||
| 1752 | (tramp-message-show-message | ||
| 1753 | (or tramp-message-show-message write-region-verbose))) | ||
| 1745 | (unwind-protect | 1754 | (unwind-protect |
| 1746 | (progn | 1755 | (ert-with-message-capture tramp--test-messages |
| 1756 | ;; Write buffer. | ||
| 1757 | (setq tramp--test-messages "") | ||
| 1747 | (with-temp-buffer | 1758 | (with-temp-buffer |
| 1748 | (insert "foo") | 1759 | (insert "foo") |
| 1749 | (write-region nil nil tmp-name)) | 1760 | (write-region nil nil tmp-name)) |
| 1761 | (when write-region-verbose | ||
| 1762 | (should | ||
| 1763 | (string-match | ||
| 1764 | (format "Wrote `%s' (3 characters)" tmp-name) | ||
| 1765 | tramp--test-messages))) | ||
| 1750 | (with-temp-buffer | 1766 | (with-temp-buffer |
| 1751 | (insert-file-contents tmp-name) | 1767 | (insert-file-contents tmp-name) |
| 1752 | (should (string-equal (buffer-string) "foo"))) | 1768 | (should (string-equal (buffer-string) "foo"))) |
| 1769 | |||
| 1753 | ;; Append. | 1770 | ;; Append. |
| 1771 | (setq tramp--test-messages "") | ||
| 1754 | (with-temp-buffer | 1772 | (with-temp-buffer |
| 1755 | (insert "bla") | 1773 | (insert "bla") |
| 1756 | (write-region nil nil tmp-name 'append)) | 1774 | (write-region nil nil tmp-name 'append)) |
| 1775 | (when write-region-verbose | ||
| 1776 | (should | ||
| 1777 | (string-match | ||
| 1778 | (format "Added to `%s' (3 characters)" tmp-name) | ||
| 1779 | tramp--test-messages))) | ||
| 1757 | (with-temp-buffer | 1780 | (with-temp-buffer |
| 1758 | (insert-file-contents tmp-name) | 1781 | (insert-file-contents tmp-name) |
| 1759 | (should (string-equal (buffer-string) "foobla"))) | 1782 | (should (string-equal (buffer-string) "foobla"))) |
| 1783 | |||
| 1784 | (setq tramp--test-messages "") | ||
| 1785 | (with-temp-buffer | ||
| 1786 | (insert "baz") | ||
| 1787 | (write-region nil nil tmp-name 3)) | ||
| 1788 | (when write-region-verbose | ||
| 1789 | (should | ||
| 1790 | (string-match | ||
| 1791 | (format "Updated `%s' (3 characters)" tmp-name) | ||
| 1792 | tramp--test-messages))) | ||
| 1793 | (with-temp-buffer | ||
| 1794 | (insert-file-contents tmp-name) | ||
| 1795 | (should (string-equal (buffer-string) "foobaz"))) | ||
| 1796 | |||
| 1760 | ;; Write string. | 1797 | ;; Write string. |
| 1798 | (setq tramp--test-messages "") | ||
| 1761 | (write-region "foo" nil tmp-name) | 1799 | (write-region "foo" nil tmp-name) |
| 1800 | (when write-region-verbose | ||
| 1801 | (should | ||
| 1802 | (string-match | ||
| 1803 | (format "Wrote `%s' (3 characters)" tmp-name) | ||
| 1804 | tramp--test-messages))) | ||
| 1762 | (with-temp-buffer | 1805 | (with-temp-buffer |
| 1763 | (insert-file-contents tmp-name) | 1806 | (insert-file-contents tmp-name) |
| 1764 | (should (string-equal (buffer-string) "foo"))) | 1807 | (should (string-equal (buffer-string) "foo"))) |
| 1808 | |||
| 1765 | ;; Write partly. | 1809 | ;; Write partly. |
| 1810 | (setq tramp--test-messages "") | ||
| 1766 | (with-temp-buffer | 1811 | (with-temp-buffer |
| 1767 | (insert "123456789") | 1812 | (insert "123456789") |
| 1768 | (write-region 3 5 tmp-name)) | 1813 | (write-region 3 5 tmp-name)) |
| 1814 | (when write-region-verbose | ||
| 1815 | (should | ||
| 1816 | (string-match | ||
| 1817 | (format "Wrote `%s' (2 characters)" tmp-name) | ||
| 1818 | tramp--test-messages))) | ||
| 1769 | (with-temp-buffer | 1819 | (with-temp-buffer |
| 1770 | (insert-file-contents tmp-name) | 1820 | (insert-file-contents tmp-name) |
| 1771 | (should (string-equal (buffer-string) "34")))) | 1821 | (should (string-equal (buffer-string) "34")))) |