branch: elpa/bash-completion
commit 581864111ee4434715d225a7b9cd82b0d9450a05
Author: Stephane Zermatten <[email protected]>
Commit: Stephane Zermatten <[email protected]>
integration test harness, process buffer cleanup, hidden buffer
---
bash-completion.el | 15 +++++++++++----
bash-completion_test.el | 51 +++++++++++++++++++++++++++++--------------------
2 files changed, 41 insertions(+), 25 deletions(-)
diff --git a/bash-completion.el b/bash-completion.el
index 379057e45a..35d0fcaa69 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -260,7 +260,7 @@ The result is a list of candidates, which might be empty."
(setq process
(start-process
"*bash-completion*"
- "*bash-completion*"
+ (generate-new-buffer-name " bash-completion")
bash-completion-prog
"--noediting"))
(set-process-query-on-exit-flag process nil)
@@ -289,7 +289,7 @@ The result is a list of candidates, which might be empty."
(setenv "EMACS_BASH_COMPLETE" nil)
(when process
(condition-case err
- (kill-process process)
+ (bash-completion-kill process)
(error nil))))))))
(defun bash-completion-cd-command-prefix ()
@@ -326,10 +326,17 @@ The result is a list of candidates, which might be empty."
(defun bash-completion-reset ()
(interactive)
- (when (bash-completion-is-running)
- (kill-process bash-completion-process))
+ (bash-completion-kill bash-completion-process)
(setq bash-completion-process nil))
+(defun bash-completion-kill (process)
+ (when process
+ (when (eq 'run (process-status process))
+ (kill-process process))
+ (let ((buffer (process-buffer process)))
+ (when (buffer-live-p buffer)
+ (kill-buffer buffer)))))
+
(defun bash-completion-buffer ()
(process-buffer (bash-completion-require-process)))
diff --git a/bash-completion_test.el b/bash-completion_test.el
index 09cb8bada8..1239869ea2 100644
--- a/bash-completion_test.el
+++ b/bash-completion_test.el
@@ -446,34 +446,43 @@ garbage
))
;; ---------- integration tests
+
+ (defmacro bash-completion_test-harness (&rest body)
+ `(let ((bash-completion-process nil) (bash-completion-alist nil))
+ (unwind-protect
+ (progn ,@body)
+ ;; tearDown
+ (condition-case err
+ (when bash-completion-process
+ (let ((buffer (process-buffer bash-completion-process)))
+ (kill-process bash-completion-process)
+ (kill-buffer buffer)))
+ (error (message "error in bash-completion_test tearDown: %s" err))))))
+
(put 'bash-completion-regress-integration 'regression-suite t)
(setq bash-completion-regress-integration '(
("bash-completion interaction"
- (let ((bash-completion-process nil)
- (bash-completion-alist nil))
- (list
- (bash-completion-is-running)
- (buffer-live-p (bash-completion-buffer))
- (bash-completion-is-running)
- (bash-completion-comm "hel" 4 '("hel") 0)
- (progn
- (bash-completion-send "echo $EMACS_BASH_COMPLETE")
- (with-current-buffer (bash-completion-buffer)
- (buffer-string)))
- (bash-completion-reset)
- (bash-completion-is-running)))
+ (bash-completion_test-harness
+ (list
+ (bash-completion-is-running)
+ (buffer-live-p (bash-completion-buffer))
+ (bash-completion-is-running)
+ (bash-completion-comm "hel" 4 '("hel") 0)
+ (progn
+ (bash-completion-send "echo $EMACS_BASH_COMPLETE")
+ (with-current-buffer (bash-completion-buffer)
+ (buffer-string)))
+ (bash-completion-reset)
+ (bash-completion-is-running)))
'(nil t t ("help ") "t\n" nil nil))
("bash-completion setenv"
- (let ((bash-completion-process nil)
- (bash-completion-alist nil))
- (prog1
- (progn
- (bash-completion-send "echo $EMACS_BASH_COMPLETE")
- (with-current-buffer (bash-completion-buffer)
- (buffer-string)))
- (bash-completion-reset)))
+ (bash-completion_test-harness
+ (bash-completion-send "echo $EMACS_BASH_COMPLETE")
+ (with-current-buffer (bash-completion-buffer)
+ (buffer-string)))
"t\n")
+
)))
;; Run diagnostics when this module is evaluated or compiled