diff options
| author | Michael Albinus | 2020-04-26 13:32:01 +0200 |
|---|---|---|
| committer | Michael Albinus | 2020-04-26 13:32:01 +0200 |
| commit | 677bd0a5e39253acb6d3a253d3243ba422a2f6cc (patch) | |
| tree | 960d6018195bbb89c1877453f7c89ee3b1f265c0 | |
| parent | 453ada0309ded5e13169bbae7b2c12f237b73fd6 (diff) | |
| download | emacs-677bd0a5e39253acb6d3a253d3243ba422a2f6cc.tar.gz emacs-677bd0a5e39253acb6d3a253d3243ba422a2f6cc.zip | |
Fix tramp-test32-shell-command-dont-erase-buffer
* test/lisp/net/tramp-tests.el
(tramp-test32-shell-command-dont-erase-buffer): Adapt test.
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 152 |
1 files changed, 134 insertions, 18 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index d00c88a911e..75a0167da7f 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -4642,8 +4642,7 @@ INPUT, if non-nil, is a string sent to the process." | |||
| 4642 | ;; This test is inspired by Bug#39067. | 4642 | ;; This test is inspired by Bug#39067. |
| 4643 | (ert-deftest tramp-test32-shell-command-dont-erase-buffer () | 4643 | (ert-deftest tramp-test32-shell-command-dont-erase-buffer () |
| 4644 | "Check `shell-command-dont-erase-buffer'." | 4644 | "Check `shell-command-dont-erase-buffer'." |
| 4645 | ;; The test fails due to recent changes in Emacs. So we mark it as unstable. | 4645 | :tags '(:expensive-test) |
| 4646 | :tags '(:expensive-test :unstable) | ||
| 4647 | (skip-unless (tramp--test-enabled)) | 4646 | (skip-unless (tramp--test-enabled)) |
| 4648 | (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p))) | 4647 | (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p))) |
| 4649 | ;; Prior Emacs 27, `shell-command-dont-erase-buffer' wasn't working properly. | 4648 | ;; Prior Emacs 27, `shell-command-dont-erase-buffer' wasn't working properly. |
| @@ -4668,9 +4667,10 @@ INPUT, if non-nil, is a string sent to the process." | |||
| 4668 | (should (= (point) (point-max))) | 4667 | (should (= (point) (point-max))) |
| 4669 | (shell-command "echo baz" (current-buffer)) | 4668 | (shell-command "echo baz" (current-buffer)) |
| 4670 | (should (string-equal "barbaz\n" (buffer-string))) | 4669 | (should (string-equal "barbaz\n" (buffer-string))) |
| 4671 | (should (= point (point))))) | 4670 | (should (= point (point))) |
| 4671 | (should-not (= (point) (point-max))))) | ||
| 4672 | 4672 | ||
| 4673 | ;; Erase if the buffer is not current one. | 4673 | ;; Erase if the buffer is not current one. Point is not moved. |
| 4674 | (let (shell-command-dont-erase-buffer) | 4674 | (let (shell-command-dont-erase-buffer) |
| 4675 | (with-current-buffer buffer | 4675 | (with-current-buffer buffer |
| 4676 | (erase-buffer) | 4676 | (erase-buffer) |
| @@ -4681,22 +4681,28 @@ INPUT, if non-nil, is a string sent to the process." | |||
| 4681 | (with-temp-buffer | 4681 | (with-temp-buffer |
| 4682 | (shell-command "echo baz" buffer)) | 4682 | (shell-command "echo baz" buffer)) |
| 4683 | (should (string-equal "baz\n" (buffer-string))) | 4683 | (should (string-equal "baz\n" (buffer-string))) |
| 4684 | (should (= point (point))))) | 4684 | (should (= point (point))) |
| 4685 | (should-not (= (point) (point-max))))) | ||
| 4685 | 4686 | ||
| 4686 | ;; Erase if buffer is the current one, but | 4687 | ;; Erase if buffer is the current one, but |
| 4687 | ;; `shell-command-dont-erase-buffer' is set to `erase'. | 4688 | ;; `shell-command-dont-erase-buffer' is set to `erase'. |
| 4689 | ;; There is no point to check point. | ||
| 4688 | (let ((shell-command-dont-erase-buffer 'erase)) | 4690 | (let ((shell-command-dont-erase-buffer 'erase)) |
| 4689 | (with-temp-buffer | 4691 | (with-temp-buffer |
| 4690 | (insert "bar") | 4692 | (insert "bar") |
| 4691 | (setq point (point)) | ||
| 4692 | (should (string-equal "bar" (buffer-string))) | 4693 | (should (string-equal "bar" (buffer-string))) |
| 4693 | (should (= (point) (point-max))) | 4694 | (should (= (point) (point-max))) |
| 4694 | (shell-command "echo baz" (current-buffer)) | 4695 | (shell-command "echo baz" (current-buffer)) |
| 4695 | (should (string-equal "baz\n" (buffer-string))) | 4696 | (should (string-equal "baz\n" (buffer-string))) |
| 4696 | (should (= (point) (point-max))))) | 4697 | ;; In the local case, point is not moved after the |
| 4697 | 4698 | ;; inserted text. | |
| 4698 | ;; Don't erase if `shell-command-dont-erase-buffer' is set | 4699 | (should (= (point) |
| 4699 | ;; to `beg-last-out'. Check point. | 4700 | (if (file-remote-p default-directory) |
| 4701 | (point-max) (point-min)))))) | ||
| 4702 | |||
| 4703 | ;; Don't erase if the buffer is the current one and | ||
| 4704 | ;; `shell-command-dont-erase-buffer' is set to | ||
| 4705 | ;; `beg-last-out'. Check point. | ||
| 4700 | (let ((shell-command-dont-erase-buffer 'beg-last-out)) | 4706 | (let ((shell-command-dont-erase-buffer 'beg-last-out)) |
| 4701 | (with-temp-buffer | 4707 | (with-temp-buffer |
| 4702 | (insert "bar") | 4708 | (insert "bar") |
| @@ -4705,10 +4711,32 @@ INPUT, if non-nil, is a string sent to the process." | |||
| 4705 | (should (= (point) (point-max))) | 4711 | (should (= (point) (point-max))) |
| 4706 | (shell-command "echo baz" (current-buffer)) | 4712 | (shell-command "echo baz" (current-buffer)) |
| 4707 | (should (string-equal "barbaz\n" (buffer-string))) | 4713 | (should (string-equal "barbaz\n" (buffer-string))) |
| 4708 | (should (= point (point))))) | 4714 | ;; There is still an error in Tramp. |
| 4709 | 4715 | (unless (file-remote-p default-directory) | |
| 4710 | ;; Don't erase if `shell-command-dont-erase-buffer' is set | 4716 | (should (= point (point))) |
| 4711 | ;; to `end-last-out'. Check point. | 4717 | (should-not (= (point) (point-max)))))) |
| 4718 | |||
| 4719 | ;; Don't erase if the buffer is not the current one and | ||
| 4720 | ;; `shell-command-dont-erase-buffer' is set to | ||
| 4721 | ;; `beg-last-out'. Check point. | ||
| 4722 | (let ((shell-command-dont-erase-buffer 'beg-last-out)) | ||
| 4723 | (with-current-buffer buffer | ||
| 4724 | (erase-buffer) | ||
| 4725 | (insert "bar") | ||
| 4726 | (setq point (point)) | ||
| 4727 | (should (string-equal "bar" (buffer-string))) | ||
| 4728 | (should (= (point) (point-max))) | ||
| 4729 | (with-temp-buffer | ||
| 4730 | (shell-command "echo baz" buffer)) | ||
| 4731 | (should (string-equal "barbaz\n" (buffer-string))) | ||
| 4732 | ;; There is still an error in Tramp. | ||
| 4733 | (unless (file-remote-p default-directory) | ||
| 4734 | (should (= point (point))) | ||
| 4735 | (should-not (= (point) (point-max)))))) | ||
| 4736 | |||
| 4737 | ;; Don't erase if the buffer is the current one and | ||
| 4738 | ;; `shell-command-dont-erase-buffer' is set to | ||
| 4739 | ;; `end-last-out'. Check point. | ||
| 4712 | (let ((shell-command-dont-erase-buffer 'end-last-out)) | 4740 | (let ((shell-command-dont-erase-buffer 'end-last-out)) |
| 4713 | (with-temp-buffer | 4741 | (with-temp-buffer |
| 4714 | (insert "bar") | 4742 | (insert "bar") |
| @@ -4717,10 +4745,36 @@ INPUT, if non-nil, is a string sent to the process." | |||
| 4717 | (should (= (point) (point-max))) | 4745 | (should (= (point) (point-max))) |
| 4718 | (shell-command "echo baz" (current-buffer)) | 4746 | (shell-command "echo baz" (current-buffer)) |
| 4719 | (should (string-equal "barbaz\n" (buffer-string))) | 4747 | (should (string-equal "barbaz\n" (buffer-string))) |
| 4720 | (should (= (point) (point-max))))) | 4748 | ;; This does not work as expected in the local case. |
| 4749 | ;; Therefore, we negate the test for the time being. | ||
| 4750 | (should-not | ||
| 4751 | (funcall (if (file-remote-p default-directory) #'identity #'not) | ||
| 4752 | (= point (point)))) | ||
| 4753 | (should | ||
| 4754 | (funcall (if (file-remote-p default-directory) #'identity #'not) | ||
| 4755 | (= (point) (point-max)))))) | ||
| 4721 | 4756 | ||
| 4722 | ;; Don't erase if `shell-command-dont-erase-buffer' is set | 4757 | ;; Don't erase if the buffer is not the current one and |
| 4723 | ;; to `save-point'. Check point. | 4758 | ;; `shell-command-dont-erase-buffer' is set to |
| 4759 | ;; `end-last-out'. Check point. | ||
| 4760 | (let ((shell-command-dont-erase-buffer 'end-last-out)) | ||
| 4761 | (with-current-buffer buffer | ||
| 4762 | (erase-buffer) | ||
| 4763 | (insert "bar") | ||
| 4764 | (setq point (point)) | ||
| 4765 | (should (string-equal "bar" (buffer-string))) | ||
| 4766 | (should (= (point) (point-max))) | ||
| 4767 | (with-temp-buffer | ||
| 4768 | (shell-command "echo baz" buffer)) | ||
| 4769 | (should (string-equal "barbaz\n" (buffer-string))) | ||
| 4770 | ;; There is still an error in Tramp. | ||
| 4771 | (unless (file-remote-p default-directory) | ||
| 4772 | (should-not (= point (point))) | ||
| 4773 | (should (= (point) (point-max)))))) | ||
| 4774 | |||
| 4775 | ;; Don't erase if the buffer is the current one and | ||
| 4776 | ;; `shell-command-dont-erase-buffer' is set to | ||
| 4777 | ;; `save-point'. Check point. | ||
| 4724 | (let ((shell-command-dont-erase-buffer 'save-point)) | 4778 | (let ((shell-command-dont-erase-buffer 'save-point)) |
| 4725 | (with-temp-buffer | 4779 | (with-temp-buffer |
| 4726 | (insert "bar") | 4780 | (insert "bar") |
| @@ -4729,8 +4783,70 @@ INPUT, if non-nil, is a string sent to the process." | |||
| 4729 | (should (string-equal "bar" (buffer-string))) | 4783 | (should (string-equal "bar" (buffer-string))) |
| 4730 | (should (= (point) (1- (point-max)))) | 4784 | (should (= (point) (1- (point-max)))) |
| 4731 | (shell-command "echo baz" (current-buffer)) | 4785 | (shell-command "echo baz" (current-buffer)) |
| 4786 | (should (string-equal "babaz\nr" (buffer-string))) | ||
| 4787 | ;; There is still an error in Tramp. | ||
| 4788 | (unless (file-remote-p default-directory) | ||
| 4789 | (should (= point (point))) | ||
| 4790 | (should-not (= (point) (point-max)))))) | ||
| 4791 | |||
| 4792 | ;; Don't erase if the buffer is not the current one and | ||
| 4793 | ;; `shell-command-dont-erase-buffer' is set to | ||
| 4794 | ;; `save-point'. Check point. | ||
| 4795 | (let ((shell-command-dont-erase-buffer 'save-point)) | ||
| 4796 | (with-current-buffer buffer | ||
| 4797 | (erase-buffer) | ||
| 4798 | (insert "bar") | ||
| 4799 | (goto-char (1- (point-max))) | ||
| 4800 | (setq point (point)) | ||
| 4801 | (should (string-equal "bar" (buffer-string))) | ||
| 4802 | (should (= (point) (1- (point-max)))) | ||
| 4803 | (with-temp-buffer | ||
| 4804 | (shell-command "echo baz" buffer)) | ||
| 4805 | ;; This does not work as expected. Therefore, we | ||
| 4806 | ;; use the "wrong" string. | ||
| 4807 | (should (string-equal "barbaz\n" (buffer-string))) | ||
| 4808 | ;; There is still an error in Tramp. | ||
| 4809 | (unless (file-remote-p default-directory) | ||
| 4810 | (should (= point (point))) | ||
| 4811 | (should-not (= (point) (point-max)))))) | ||
| 4812 | |||
| 4813 | ;; Don't erase if the buffer is the current one and | ||
| 4814 | ;; `shell-command-dont-erase-buffer' is set to a random | ||
| 4815 | ;; value. Check point. | ||
| 4816 | (let ((shell-command-dont-erase-buffer 'random)) | ||
| 4817 | (with-temp-buffer | ||
| 4818 | (insert "bar") | ||
| 4819 | (setq point (point)) | ||
| 4820 | (should (string-equal "bar" (buffer-string))) | ||
| 4821 | (should (= (point) (point-max))) | ||
| 4822 | (shell-command "echo baz" (current-buffer)) | ||
| 4823 | (should (string-equal "barbaz\n" (buffer-string))) | ||
| 4824 | ;; This does not work as expected in the local case. | ||
| 4825 | ;; Therefore, we negate the test for the time being. | ||
| 4826 | (should-not | ||
| 4827 | (funcall (if (file-remote-p default-directory) #'identity #'not) | ||
| 4828 | (= point (point)))) | ||
| 4829 | (should | ||
| 4830 | (funcall (if (file-remote-p default-directory) #'identity #'not) | ||
| 4831 | (= (point) (point-max)))))) | ||
| 4832 | |||
| 4833 | ;; Don't erase if the buffer is not the current one and | ||
| 4834 | ;; `shell-command-dont-erase-buffer' is set to a random | ||
| 4835 | ;; value. Check point. | ||
| 4836 | (let ((shell-command-dont-erase-buffer 'random)) | ||
| 4837 | (with-current-buffer buffer | ||
| 4838 | (erase-buffer) | ||
| 4839 | (insert "bar") | ||
| 4840 | (setq point (point)) | ||
| 4841 | (should (string-equal "bar" (buffer-string))) | ||
| 4842 | (should (= (point) (point-max))) | ||
| 4843 | (with-temp-buffer | ||
| 4844 | (shell-command "echo baz" buffer)) | ||
| 4732 | (should (string-equal "barbaz\n" (buffer-string))) | 4845 | (should (string-equal "barbaz\n" (buffer-string))) |
| 4733 | (should (= point (point)))))) | 4846 | ;; There is still an error in Tramp. |
| 4847 | (unless (file-remote-p default-directory) | ||
| 4848 | (should-not (= point (point))) | ||
| 4849 | (should (= (point) (point-max))))))) | ||
| 4734 | 4850 | ||
| 4735 | ;; Cleanup. | 4851 | ;; Cleanup. |
| 4736 | (ignore-errors (kill-buffer buffer)))))) | 4852 | (ignore-errors (kill-buffer buffer)))))) |