aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBastien2017-07-03 09:06:29 +0200
committerBastien2017-07-03 09:06:29 +0200
commit5ca1888fe670aee7febd4d42665d7372ab2ffebc (patch)
tree1f7f8d8a7580e556fc83cf3a6aaeec567b33a090 /test
parent20e006ffee41062f1b551a92c24d9edc53cd0f56 (diff)
parent1b4f0a92ff3505ef9a465b9b391756e3a73a6443 (diff)
downloademacs-5ca1888fe670aee7febd4d42665d7372ab2ffebc.tar.gz
emacs-5ca1888fe670aee7febd4d42665d7372ab2ffebc.zip
Merge branch 'master' into scratch/org-mode-merge
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.in3
-rw-r--r--test/lisp/electric-tests.el116
-rw-r--r--test/lisp/emacs-lisp/cl-print-tests.el2
-rw-r--r--test/lisp/emacs-lisp/ert-tests.el8
-rw-r--r--test/lisp/net/tramp-tests.el255
5 files changed, 285 insertions, 99 deletions
diff --git a/test/Makefile.in b/test/Makefile.in
index 414eca90564..11373db8ca9 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -147,7 +147,8 @@ endif
147%.log: %.elc 147%.log: %.elc
148 $(AM_V_at)${MKDIR_P} $(dir $@) 148 $(AM_V_at)${MKDIR_P} $(dir $@)
149 $(AM_V_GEN)HOME=/nonexistent $(emacs) -l ert -l $(testloadfile) \ 149 $(AM_V_GEN)HOME=/nonexistent $(emacs) -l ert -l $(testloadfile) \
150 --eval "(ert-run-tests-batch-and-exit ${SELECTOR_ACTUAL})" ${WRITE_LOG} 150 --eval "(ert-run-tests-batch-and-exit ${SELECTOR_ACTUAL})" \
151 $(if $(and ${NIX_STORE}, $(findstring tramp, $(testloadfile))), , ${WRITE_LOG})
151 152
152ifeq (@HAVE_MODULES@, yes) 153ifeq (@HAVE_MODULES@, yes)
153maybe_exclude_module_tests := 154maybe_exclude_module_tests :=
diff --git a/test/lisp/electric-tests.el b/test/lisp/electric-tests.el
index 78a37650619..6f63d30e755 100644
--- a/test/lisp/electric-tests.el
+++ b/test/lisp/electric-tests.el
@@ -593,5 +593,121 @@ baz\"\""
593 :bindings '((electric-quote-string . t)) 593 :bindings '((electric-quote-string . t))
594 :test-in-comments nil :test-in-strings nil) 594 :test-in-comments nil :test-in-strings nil)
595 595
596(define-electric-pair-test electric-quote-opening-single
597 "" "`" :expected-string "‘" :expected-point 2
598 :modes '(text-mode)
599 :fixture-fn #'electric-quote-local-mode
600 :test-in-comments nil :test-in-strings nil)
601
602(define-electric-pair-test electric-quote-closing-single
603 "" "'" :expected-string "’" :expected-point 2
604 :modes '(text-mode)
605 :fixture-fn #'electric-quote-local-mode
606 :test-in-comments nil :test-in-strings nil)
607
608(define-electric-pair-test electric-quote-opening-double
609 "‘" "-`" :expected-string "“" :expected-point 2
610 :modes '(text-mode)
611 :fixture-fn #'electric-quote-local-mode
612 :test-in-comments nil :test-in-strings nil)
613
614(define-electric-pair-test electric-quote-closing-double
615 "’" "-'" :expected-string "”" :expected-point 2
616 :modes '(text-mode)
617 :fixture-fn #'electric-quote-local-mode
618 :test-in-comments nil :test-in-strings nil)
619
620(define-electric-pair-test electric-quote-context-sensitive-backtick
621 "" "`" :expected-string "`" :expected-point 2
622 :modes '(text-mode)
623 :fixture-fn #'electric-quote-local-mode
624 :bindings '((electric-quote-context-sensitive . t))
625 :test-in-comments nil :test-in-strings nil)
626
627(define-electric-pair-test electric-quote-context-sensitive-bob-single
628 "" "'" :expected-string "‘" :expected-point 2
629 :modes '(text-mode)
630 :fixture-fn #'electric-quote-local-mode
631 :bindings '((electric-quote-context-sensitive . t))
632 :test-in-comments nil :test-in-strings nil)
633
634(define-electric-pair-test electric-quote-context-sensitive-bob-double
635 "‘" "-'" :expected-string "“" :expected-point 2
636 :modes '(text-mode)
637 :fixture-fn #'electric-quote-local-mode
638 :bindings '((electric-quote-context-sensitive . t))
639 :test-in-comments nil :test-in-strings nil)
640
641(define-electric-pair-test electric-quote-context-sensitive-bol-single
642 "a\n" "--'" :expected-string "a\n‘" :expected-point 4
643 :modes '(text-mode)
644 :fixture-fn #'electric-quote-local-mode
645 :bindings '((electric-quote-context-sensitive . t))
646 :test-in-comments nil :test-in-strings nil)
647
648(define-electric-pair-test electric-quote-context-sensitive-bol-double
649 "a\n‘" "---'" :expected-string "a\n“" :expected-point 4
650 :modes '(text-mode)
651 :fixture-fn #'electric-quote-local-mode
652 :bindings '((electric-quote-context-sensitive . t))
653 :test-in-comments nil :test-in-strings nil)
654
655(define-electric-pair-test electric-quote-context-sensitive-after-space-single
656 " " "-'" :expected-string " ‘" :expected-point 3
657 :modes '(text-mode)
658 :fixture-fn #'electric-quote-local-mode
659 :bindings '((electric-quote-context-sensitive . t))
660 :test-in-comments nil :test-in-strings nil)
661
662(define-electric-pair-test electric-quote-context-sensitive-after-space-double
663 " ‘" "--'" :expected-string " “" :expected-point 3
664 :modes '(text-mode)
665 :fixture-fn #'electric-quote-local-mode
666 :bindings '((electric-quote-context-sensitive . t))
667 :test-in-comments nil :test-in-strings nil)
668
669(define-electric-pair-test electric-quote-context-sensitive-after-letter-single
670 "a" "-'" :expected-string "a’" :expected-point 3
671 :modes '(text-mode)
672 :fixture-fn #'electric-quote-local-mode
673 :bindings '((electric-quote-context-sensitive . t))
674 :test-in-comments nil :test-in-strings nil)
675
676(define-electric-pair-test electric-quote-context-sensitive-after-letter-double
677 "a’" "--'" :expected-string "a”" :expected-point 3
678 :modes '(text-mode)
679 :fixture-fn #'electric-quote-local-mode
680 :bindings '((electric-quote-context-sensitive . t))
681 :test-in-comments nil :test-in-strings nil)
682
683(define-electric-pair-test electric-quote-context-sensitive-after-paren-single
684 "(" "-'" :expected-string "(‘" :expected-point 3
685 :modes '(text-mode)
686 :fixture-fn #'electric-quote-local-mode
687 :bindings '((electric-quote-context-sensitive . t))
688 :test-in-comments nil :test-in-strings nil)
689
690(define-electric-pair-test electric-quote-context-sensitive-after-paren-double
691 "(‘" "--'" :expected-string "(“" :expected-point 3
692 :modes '(text-mode)
693 :fixture-fn #'electric-quote-local-mode
694 :bindings '((electric-quote-context-sensitive . t))
695 :test-in-comments nil :test-in-strings nil)
696
697(define-electric-pair-test electric-quote-markdown-in-text
698 "" "'" :expected-string "’" :expected-point 2
699 :modes '(text-mode)
700 :fixture-fn #'electric-quote-local-mode
701 :bindings '((electric-quote-code-faces font-lock-constant-face))
702 :test-in-comments nil :test-in-strings nil)
703
704(define-electric-pair-test electric-quote-markdown-in-code
705 #("`a`" 1 2 (face font-lock-constant-face)) "-'"
706 :expected-string "`'a`" :expected-point 3
707 :modes '(text-mode)
708 :fixture-fn #'electric-quote-local-mode
709 :bindings '((electric-quote-code-faces font-lock-constant-face))
710 :test-in-comments nil :test-in-strings nil)
711
596(provide 'electric-tests) 712(provide 'electric-tests)
597;;; electric-tests.el ends here 713;;; electric-tests.el ends here
diff --git a/test/lisp/emacs-lisp/cl-print-tests.el b/test/lisp/emacs-lisp/cl-print-tests.el
index dfbe18d7844..6448a1b37f7 100644
--- a/test/lisp/emacs-lisp/cl-print-tests.el
+++ b/test/lisp/emacs-lisp/cl-print-tests.el
@@ -34,7 +34,7 @@
34 (let ((print-circle t)) 34 (let ((print-circle t))
35 (should (equal (cl-prin1-to-string `((x . ,x) (y . ,x))) 35 (should (equal (cl-prin1-to-string `((x . ,x) (y . ,x)))
36 "((x . #1=#s(cl-print--test :a 1 :b 2)) (y . #1#))"))) 36 "((x . #1=#s(cl-print--test :a 1 :b 2)) (y . #1#))")))
37 (should (string-match "\\`#f(compiled-function (x) .*\n\n.*)\\'" 37 (should (string-match "\\`#f(compiled-function (x) \"[^\"]+\" [^\)]*)\\'"
38 (cl-prin1-to-string (symbol-function #'caar)))))) 38 (cl-prin1-to-string (symbol-function #'caar))))))
39 39
40(ert-deftest cl-print-tests-2 () 40(ert-deftest cl-print-tests-2 ()
diff --git a/test/lisp/emacs-lisp/ert-tests.el b/test/lisp/emacs-lisp/ert-tests.el
index fc5790c3659..317838b250f 100644
--- a/test/lisp/emacs-lisp/ert-tests.el
+++ b/test/lisp/emacs-lisp/ert-tests.el
@@ -367,12 +367,8 @@ This macro is used to test if macroexpansion in `should' works."
367 (test (make-ert-test :body test-body)) 367 (test (make-ert-test :body test-body))
368 (result (ert-run-test test))) 368 (result (ert-run-test test)))
369 (should (ert-test-failed-p result)) 369 (should (ert-test-failed-p result))
370 (with-temp-buffer 370 (should (eq (nth 1 (car (ert-test-failed-backtrace result)))
371 (ert--print-backtrace (ert-test-failed-backtrace result)) 371 'signal))))
372 (goto-char (point-min))
373 (end-of-line)
374 (let ((first-line (buffer-substring-no-properties (point-min) (point))))
375 (should (equal first-line (format " %S()" test-body)))))))
376 372
377(ert-deftest ert-test-messages () 373(ert-deftest ert-test-messages ()
378 :tags '(:causes-redisplay) 374 :tags '(:causes-redisplay)
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index a90e3fff355..85990a848f5 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -53,6 +53,8 @@
53(defvar tramp-copy-size-limit) 53(defvar tramp-copy-size-limit)
54(defvar tramp-persistency-file-name) 54(defvar tramp-persistency-file-name)
55(defvar tramp-remote-process-environment) 55(defvar tramp-remote-process-environment)
56;; Suppress nasty messages.
57(fset 'shell-command-sentinel 'ignore)
56 58
57;; There is no default value on w32 systems, which could work out of the box. 59;; There is no default value on w32 systems, which could work out of the box.
58(defconst tramp-test-temporary-file-directory 60(defconst tramp-test-temporary-file-directory
@@ -70,6 +72,10 @@
70 (add-to-list 72 (add-to-list
71 'tramp-default-host-alist 73 'tramp-default-host-alist
72 `("\\`mock\\'" nil ,(system-name))) 74 `("\\`mock\\'" nil ,(system-name)))
75 ;; Emacs' Makefile sets $HOME to a nonexistent value. Needed in
76 ;; batch mode only, therefore.
77 (unless (and (null noninteractive) (file-directory-p "~/"))
78 (setenv "HOME" temporary-file-directory))
73 (format "/mock::%s" temporary-file-directory))) 79 (format "/mock::%s" temporary-file-directory)))
74 "Temporary directory for Tramp tests.") 80 "Temporary directory for Tramp tests.")
75 81
@@ -126,29 +132,52 @@ If QUOTED is non-nil, the local part of the file is quoted."
126 (make-temp-name "tramp-test") 132 (make-temp-name "tramp-test")
127 (if local temporary-file-directory tramp-test-temporary-file-directory)))) 133 (if local temporary-file-directory tramp-test-temporary-file-directory))))
128 134
135;; Don't print messages in nested `tramp--instrument-test-case' calls.
136(defvar tramp--instrument-test-case-p nil
137 "Whether `tramp--instrument-test-case' run.
138This shall used dynamically bound only.")
139
129(defmacro tramp--instrument-test-case (verbose &rest body) 140(defmacro tramp--instrument-test-case (verbose &rest body)
130 "Run BODY with `tramp-verbose' equal VERBOSE. 141 "Run BODY with `tramp-verbose' equal VERBOSE.
131Print the the content of the Tramp debug buffer, if BODY does not 142Print the the content of the Tramp debug buffer, if BODY does not
132eval properly in `should' or `should-not'. `should-error' is not 143eval properly in `should' or `should-not'. `should-error' is not
133handled properly. BODY shall not contain a timeout." 144handled properly. BODY shall not contain a timeout."
134 (declare (indent 1) (debug (natnump body))) 145 (declare (indent 1) (debug (natnump body)))
135 `(let ((tramp-verbose ,verbose) 146 `(let ((tramp-verbose (max (or ,verbose 0) (or tramp-verbose 0)))
147 (tramp-message-show-message t)
136 (tramp-debug-on-error t) 148 (tramp-debug-on-error t)
137 (debug-ignored-errors 149 (debug-ignored-errors
138 (cons "^make-symbolic-link not supported$" debug-ignored-errors))) 150 (cons "^make-symbolic-link not supported$" debug-ignored-errors))
151 inhibit-message)
139 (unwind-protect 152 (unwind-protect
140 (progn ,@body) 153 (let ((tramp--instrument-test-case-p t)) ,@body)
141 (when (> tramp-verbose 3) 154 ;; Unwind forms.
155 (when (and (null tramp--instrument-test-case-p) (> tramp-verbose 3))
142 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil 156 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
143 (with-current-buffer (tramp-get-connection-buffer v) 157 (with-current-buffer (tramp-get-connection-buffer v)
144 (message "%s" (buffer-string))) 158 (message "%s" (buffer-string)))
145 (with-current-buffer (tramp-get-debug-buffer v) 159 (with-current-buffer (tramp-get-debug-buffer v)
146 (message "%s" (buffer-string)))))))) 160 (message "%s" (buffer-string))))))))
147 161
162(defsubst tramp--test-message (fmt-string &rest arguments)
163 "Emit a message into ERT *Messages*."
164 (tramp--instrument-test-case 0
165 (apply
166 'tramp-message
167 (tramp-dissect-file-name tramp-test-temporary-file-directory) 0
168 fmt-string arguments)))
169
170(defsubst tramp--test-backtrace ()
171 "Dump a backtrace into ERT *Messages*."
172 (tramp--instrument-test-case 10
173 (tramp-backtrace
174 (tramp-dissect-file-name tramp-test-temporary-file-directory))))
175
148(ert-deftest tramp-test00-availability () 176(ert-deftest tramp-test00-availability ()
149 "Test availability of Tramp functions." 177 "Test availability of Tramp functions."
150 :expected-result (if (tramp--test-enabled) :passed :failed) 178 :expected-result (if (tramp--test-enabled) :passed :failed)
151 (message "Remote directory: `%s'" tramp-test-temporary-file-directory) 179 (tramp--test-message
180 "Remote directory: `%s'" tramp-test-temporary-file-directory)
152 (should (ignore-errors 181 (should (ignore-errors
153 (and 182 (and
154 (file-remote-p tramp-test-temporary-file-directory) 183 (file-remote-p tramp-test-temporary-file-directory)
@@ -2759,6 +2788,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
2759 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 2788 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil)))
2760 (let ((tmp-name (tramp--test-make-temp-name nil quoted)) 2789 (let ((tmp-name (tramp--test-make-temp-name nil quoted))
2761 (default-directory tramp-test-temporary-file-directory) 2790 (default-directory tramp-test-temporary-file-directory)
2791 ;; Suppress nasty messages.
2792 (inhibit-message t)
2762 kill-buffer-query-functions) 2793 kill-buffer-query-functions)
2763 (unwind-protect 2794 (unwind-protect
2764 (with-temp-buffer 2795 (with-temp-buffer
@@ -2787,7 +2818,6 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
2787 (async-shell-command 2818 (async-shell-command
2788 (format "ls %s" (file-name-nondirectory tmp-name)) 2819 (format "ls %s" (file-name-nondirectory tmp-name))
2789 (current-buffer)) 2820 (current-buffer))
2790 (set-process-sentinel (get-buffer-process (current-buffer)) nil)
2791 ;; Read output. 2821 ;; Read output.
2792 (with-timeout (10 (ert-fail "`async-shell-command' timed out")) 2822 (with-timeout (10 (ert-fail "`async-shell-command' timed out"))
2793 (while (< (- (point-max) (point-min)) 2823 (while (< (- (point-max) (point-min))
@@ -2816,7 +2846,6 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
2816 (write-region "foo" nil tmp-name) 2846 (write-region "foo" nil tmp-name)
2817 (should (file-exists-p tmp-name)) 2847 (should (file-exists-p tmp-name))
2818 (async-shell-command "read line; ls $line" (current-buffer)) 2848 (async-shell-command "read line; ls $line" (current-buffer))
2819 (set-process-sentinel (get-buffer-process (current-buffer)) nil)
2820 (process-send-string 2849 (process-send-string
2821 (get-buffer-process (current-buffer)) 2850 (get-buffer-process (current-buffer))
2822 (format "%s\n" (file-name-nondirectory tmp-name))) 2851 (format "%s\n" (file-name-nondirectory tmp-name)))
@@ -2847,8 +2876,6 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
2847 "Like `shell-command-to-string', but for asynchronous processes." 2876 "Like `shell-command-to-string', but for asynchronous processes."
2848 (with-temp-buffer 2877 (with-temp-buffer
2849 (async-shell-command command (current-buffer)) 2878 (async-shell-command command (current-buffer))
2850 ;; Suppress nasty messages.
2851 (set-process-sentinel (get-buffer-process (current-buffer)) nil)
2852 (with-timeout (10) 2879 (with-timeout (10)
2853 (while (get-buffer-process (current-buffer)) 2880 (while (get-buffer-process (current-buffer))
2854 (accept-process-output (get-buffer-process (current-buffer)) 0.1))) 2881 (accept-process-output (get-buffer-process (current-buffer)) 0.1)))
@@ -3046,11 +3073,13 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3046 ;; We must force a reconnect, in order to activate $BZR_HOME. 3073 ;; We must force a reconnect, in order to activate $BZR_HOME.
3047 (tramp-cleanup-connection 3074 (tramp-cleanup-connection
3048 (tramp-dissect-file-name tramp-test-temporary-file-directory) 3075 (tramp-dissect-file-name tramp-test-temporary-file-directory)
3049 nil 'keep-password) 3076 'keep-debug 'keep-password)
3050 '(Bzr)) 3077 '(Bzr))
3051 (t nil))))) 3078 (t nil))))
3079 ;; Suppress nasty messages.
3080 (inhibit-message t))
3052 (skip-unless vc-handled-backends) 3081 (skip-unless vc-handled-backends)
3053 (message "%s" vc-handled-backends) 3082 (unless quoted (tramp--test-message "%s" vc-handled-backends))
3054 3083
3055 (unwind-protect 3084 (unwind-protect
3056 (progn 3085 (progn
@@ -3656,90 +3685,134 @@ Use the `ls' command."
3656 "Check parallel asynchronous requests. 3685 "Check parallel asynchronous requests.
3657Such requests could arrive from timers, process filters and 3686Such requests could arrive from timers, process filters and
3658process sentinels. They shall not disturb each other." 3687process sentinels. They shall not disturb each other."
3659 ;; Mark as failed until bug has been fixed.
3660 :expected-result :failed
3661 :tags '(:expensive-test) 3688 :tags '(:expensive-test)
3662 (skip-unless (tramp--test-enabled)) 3689 (skip-unless (tramp--test-enabled))
3663 (skip-unless (tramp--test-sh-p)) 3690 (skip-unless (tramp--test-sh-p))
3664 3691
3665 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 3692 ;; This test times out on hydra.
3666 ;; Keep instrumentation verbosity 0 until Tramp bug is fixed. 3693 (with-timeout
3667 ;; This has the side effect, that this test fails instead to 3694 (300 (ert-fail "`tramp-test36-asynchronous-requests' timed out"))
3668 ;; abort. Good for hydra. 3695 (let* ((tmp-name (tramp--test-make-temp-name))
3669 (tramp--instrument-test-case 0 3696 (default-directory tmp-name)
3670 (let* ((tmp-name (tramp--test-make-temp-name nil quoted)) 3697 ;; Do not cache Tramp properties.
3671 (default-directory tmp-name) 3698 (remote-file-name-inhibit-cache t)
3672 (remote-file-name-inhibit-cache t) 3699 (process-file-side-effects t)
3673 timer buffers kill-buffer-query-functions) 3700 ;; Suppress nasty messages.
3701 (inhibit-message t)
3702 (number-proc 10)
3703 ;; On hydra, timings are bad.
3704 (timer-repeat
3705 (cond
3706 ((getenv "NIX_STORE") 10
3707 (t 1))))
3708 ;; We must distinguish due to performance reasons.
3709 (timer-operation
3710 (cond
3711 ((string-equal "mock" (file-remote-p tmp-name 'method))
3712 'vc-registered)
3713 (t 'file-attributes)))
3714 timer buffers kill-buffer-query-functions)
3674 3715
3675 (unwind-protect 3716 (unwind-protect
3676 (progn 3717 (progn
3677 (make-directory tmp-name) 3718 (make-directory tmp-name)
3678 3719
3679 ;; Setup a timer in order to raise an ordinary command 3720 ;; Setup a timer in order to raise an ordinary command again
3680 ;; again and again. `vc-registered' is well suited, 3721 ;; and again. `vc-registered' is well suited, because there
3681 ;; because there are many checks. 3722 ;; are many checks.
3682 (setq 3723 (setq
3683 timer 3724 timer
3684 (run-at-time 3725 (run-at-time
3685 0 1 3726 0 timer-repeat
3686 (lambda () 3727 (lambda ()
3687 (when buffers 3728 (when buffers
3688 (vc-registered 3729 (let ((default-directory tmp-name)
3689 (buffer-name (nth (random (length buffers)) buffers))))))) 3730 (file
3690 3731 (buffer-name (nth (random (length buffers)) buffers))))
3691 ;; Create temporary buffers. The number of buffers 3732 (tramp--test-message
3692 ;; corresponds to the number of processes; it could be 3733 "Start timer %s %s %s"
3693 ;; increased in order to make pressure on Tramp. 3734 timer-operation file (current-time-string))
3694 (dotimes (_i 5) 3735 (funcall timer-operation file)
3695 (add-to-list 'buffers (generate-new-buffer "*temp*"))) 3736 (tramp--test-message
3696 3737 "Stop timer %s %s %s"
3697 ;; Open asynchronous processes. Set process sentinel. 3738 timer-operation file (current-time-string)))))))
3698 (dolist (buf buffers) 3739
3699 (async-shell-command "read line; touch $line; echo $line" buf) 3740 ;; Create temporary buffers. The number of buffers
3741 ;; corresponds to the number of processes; it could be
3742 ;; increased in order to make pressure on Tramp.
3743 (dotimes (_i number-proc)
3744 (add-to-list 'buffers (generate-new-buffer "foo")))
3745
3746 ;; Open asynchronous processes. Set process sentinel.
3747 (dolist (buf buffers)
3748 (tramp--test-message "Start process %s" buf)
3749 (let ((proc
3750 (start-file-process-shell-command
3751 (buffer-name buf) buf
3752 (concat
3753 "(read line && echo $line >$line);"
3754 "(read line && cat $line);"
3755 "(read line && rm $line)")))
3756 (file (expand-file-name (buffer-name buf))))
3757 ;; Remember the file name. Add counter.
3758 (process-put proc 'foo file)
3759 (process-put proc 'bar 0)
3760 ;; Add process filter.
3761 (set-process-filter
3762 proc
3763 (lambda (proc string)
3764 (tramp--test-message "Process filter %s" proc)
3765 (with-current-buffer (process-buffer proc)
3766 (insert string))
3767 (unless (zerop (length string))
3768 (should (file-attributes (process-get proc 'foo))))))
3769 ;; Add process sentinel.
3700 (set-process-sentinel 3770 (set-process-sentinel
3701 (get-buffer-process buf) 3771 proc
3702 (lambda (proc _state) 3772 (lambda (proc _state)
3703 (delete-file (buffer-name (process-buffer proc)))))) 3773 (tramp--test-message "Process sentinel %s" proc)
3704 3774 (should-not (file-attributes (process-get proc 'foo)))))))
3705 ;; Send a string. Use a random order of the buffers. Mix 3775
3706 ;; with regular operation. 3776 ;; Send a string. Use a random order of the buffers. Mix
3707 (let ((buffers (copy-sequence buffers)) 3777 ;; with regular operation.
3708 buf) 3778 (let ((buffers (copy-sequence buffers)))
3709 (while buffers 3779 (while buffers
3710 (setq buf (nth (random (length buffers)) buffers)) 3780 (let* ((buf (nth (random (length buffers)) buffers))
3711 (process-send-string 3781 (proc (get-buffer-process buf))
3712 (get-buffer-process buf) (format "'%s'\n" buf)) 3782 (file (process-get proc 'foo))
3713 (file-attributes (buffer-name buf)) 3783 (count (process-get proc 'bar)))
3714 (setq buffers (delq buf buffers)))) 3784 ;; Regular operation.
3715 3785 (if (= count 0)
3716 ;; Wait until the whole output has been read. 3786 (should-not (file-attributes file))
3717 (with-timeout ((* 10 (length buffers)) 3787 (should (file-attributes file)))
3718 (ert-fail "`async-shell-command' timed out")) 3788 ;; Send string to process.
3719 (let ((buffers (copy-sequence buffers)) 3789 (tramp--test-message "Send string %s" proc)
3720 buf) 3790 (process-send-string proc (format "%s\n" (buffer-name buf)))
3721 (while buffers 3791 (accept-process-output proc 0.1 nil 0)
3722 (setq buf (nth (random (length buffers)) buffers)) 3792 ;; Regular operation.
3723 (if (ignore-errors 3793 (if (= count 2)
3724 (memq (process-status (get-buffer-process buf)) 3794 (should-not (file-attributes file))
3725 '(run open))) 3795 (should (file-attributes file)))
3726 (accept-process-output (get-buffer-process buf) 0.1) 3796 (process-put proc 'bar (1+ count))
3727 (setq buffers (delq buf buffers)))))) 3797 (unless (process-live-p proc)
3728 3798 (tramp--test-message "Buffer delete %s" buf)
3729 ;; Check. 3799 (setq buffers (delq buf buffers))))))
3730 (dolist (buf buffers) 3800
3731 (with-current-buffer buf 3801 ;; Checks. All process output shall exists in the
3732 (should 3802 ;; respective buffers. All created files shall be deleted.
3733 (string-equal (format "'%s'\n" buf) (buffer-string))))) 3803 (tramp--test-message "Checks %s" buffers)
3734 (should-not 3804 (dolist (buf buffers)
3735 (directory-files 3805 (with-current-buffer buf
3736 tmp-name nil directory-files-no-dot-files-regexp))) 3806 (should (string-equal (format "%s\n" buf) (buffer-string)))))
3737 3807 (should-not
3738 ;; Cleanup. 3808 (directory-files tmp-name nil directory-files-no-dot-files-regexp)))
3739 (ignore-errors (cancel-timer timer)) 3809
3740 (ignore-errors (delete-directory tmp-name 'recursive)) 3810 ;; Cleanup.
3741 (dolist (buf buffers) 3811 (dolist (buf buffers)
3742 (ignore-errors (kill-buffer buf)))))))) 3812 (ignore-errors (delete-process (get-buffer-process buf)))
3813 (ignore-errors (kill-buffer buf)))
3814 (ignore-errors (cancel-timer timer))
3815 (ignore-errors (delete-directory tmp-name 'recursive))))))
3743 3816
3744(ert-deftest tramp-test37-recursive-load () 3817(ert-deftest tramp-test37-recursive-load ()
3745 "Check that Tramp does not fail due to recursive load." 3818 "Check that Tramp does not fail due to recursive load."
@@ -3836,8 +3909,8 @@ Since it unloads Tramp, it shall be the last test to run."
3836;; * Fix `tramp-test27-start-file-process' on MS Windows (`process-send-eof'?). 3909;; * Fix `tramp-test27-start-file-process' on MS Windows (`process-send-eof'?).
3837;; * Fix Bug#27009. Set expected error of 3910;; * Fix Bug#27009. Set expected error of
3838;; `tramp-test29-environment-variables-and-port-numbers'. 3911;; `tramp-test29-environment-variables-and-port-numbers'.
3839;; * Fix Bug#16928. Set expected error of `tramp-test36-asynchronous-requests'. 3912;; * Fix Bug#16928 in `tramp-test36-asynchronous-requests'.
3840;; * Fix `tramp-test38-unload' (Not all symbols are unbound). Set 3913;; * Fix `tramp-test39-unload' (Not all symbols are unbound). Set
3841;; expected error. 3914;; expected error.
3842 3915
3843(defun tramp-test-all (&optional interactive) 3916(defun tramp-test-all (&optional interactive)