[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion 0c4557a5ed 193/313: Integration test for d
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion 0c4557a5ed 193/313: Integration test for default completion (-D). |
Date: |
Sat, 3 Dec 2022 10:59:30 -0500 (EST) |
branch: elpa/bash-completion
commit 0c4557a5ed817ab37e505d9ce988b2334d47c33b
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
Integration test for default completion (-D).
---
test/bash-completion-integration-test.el | 53 +++++++++++++++++++++++---------
1 file changed, 38 insertions(+), 15 deletions(-)
diff --git a/test/bash-completion-integration-test.el
b/test/bash-completion-integration-test.el
index ee59c6fa02..26f7029836 100644
--- a/test/bash-completion-integration-test.el
+++ b/test/bash-completion-integration-test.el
@@ -33,9 +33,9 @@
(require 'dired)
(require 'ert)
-(defmacro bash-completion_test-harness (&rest body)
+(defmacro bash-completion_test-harness (bashrc &rest body)
`(if (file-executable-p bash-completion-prog)
- (let ((test-env-dir (bash-completion_test-setup-env)))
+ (let ((test-env-dir (bash-completion_test-setup-env ,bashrc)))
(let ((bash-completion-processes nil)
(bash-completion-nospace nil)
(bash-completion-start-files nil)
@@ -54,8 +54,9 @@
(bash-completion_test-teardown-env test-env-dir)
(bash-completion-reset-all)))))))
-(defmacro bash-completion_test-with-shell-harness (&rest body)
+(defmacro bash-completion_test-with-shell-harness (bashrc &rest body)
`(bash-completion_test-harness
+ ,bashrc
(let ((shell-buffer))
(unwind-protect
(progn
@@ -65,7 +66,9 @@
(while (accept-process-output nil 0.6))
;; do a completion and return the result
(with-current-buffer shell-buffer
- (let ((comint-dynamic-complete-functions
'(bash-completion-dynamic-complete)))
+ (let ((comint-dynamic-complete-functions
'(bash-completion-dynamic-complete))
+ (bash-major-version (process-get
(bash-completion-require-process)
+ 'bash-major-version)))
(progn ,@body))))
(progn ;; finally
(when (and shell-buffer (buffer-live-p shell-buffer))
@@ -81,7 +84,7 @@
(buffer-substring-no-properties
(comint-line-beginning-position) (point)))
-(defun bash-completion_test-setup-env ()
+(defun bash-completion_test-setup-env (bashrc)
"Sets up a directory that contains a bashrc file other files
for testing completion."
(let ((test-env-dir (make-temp-file
@@ -93,13 +96,7 @@ for testing completion."
test-env-dir
(with-temp-file (expand-file-name "bashrc" test-env-dir)
(insert (format "cd '%s'\n" test-env-dir))
- (insert "function somefunction { echo ok; }\n")
- (insert "function someotherfunction { echo ok; }\n")
- (insert "function _dummy_complete {\n")
- (insert " if [[ ${COMP_WORDS[COMP_CWORD]} == du ]]; then
COMPREPLY=(dummy); fi\n")
- (insert "}\n")
- (insert "complete -F _dummy_complete -o filenames somefunction\n")
- (insert "complete -F _dummy_complete -o default -o filenames
someotherfunction\n"))
+ (insert bashrc))
(let ((default-directory test-env-dir))
(make-directory "some/directory" 'parents)
(make-directory "some/other/directory" 'parents)))))
@@ -113,15 +110,22 @@ for testing completion."
(ert-deftest bash-completion-integration-setenv-test ()
(bash-completion_test-harness
+ ""
(bash-completion-send "echo $EMACS_BASH_COMPLETE")
(with-current-buffer (bash-completion-buffer)
(should (equal "t\n" (buffer-string))))))
(ert-deftest bash-completion-integration-completion-test ()
(bash-completion_test-with-shell-harness
- (bash-completion-integration-test-complete)))
+ (concat ; .bashrc
+ "function somefunction { echo ok; }\n"
+ "function someotherfunction { echo ok; }\n"
+ "function _dummy_complete {\n"
+ " if [[ ${COMP_WORDS[COMP_CWORD]} == du ]]; then COMPREPLY=(dummy); fi\n"
+ "}\n"
+ "complete -F _dummy_complete -o filenames somefunction\n"
+ "complete -F _dummy_complete -o default -o filenames someotherfunction\n")
-(defun bash-completion-integration-test-complete ()
;; complete bash builtin
(should (equal "readonly "
(bash-completion_test-complete "reado")))
@@ -140,6 +144,25 @@ for testing completion."
;; wordbreak completion
(should (equal "export SOMEPATH=some/directory:some/other/"
(bash-completion_test-complete
- "export SOMEPATH=some/directory:some/oth"))))
+ "export SOMEPATH=some/directory:some/oth")))))
+
+(ert-deftest bash-completion-integration-bash-4-default-completion ()
+ (bash-completion_test-with-shell-harness
+ (concat ; .bashrc
+ "function _default {\n"
+ " if [[ ${COMP_WORDS[0]} == dosomething ]]; then\n"
+ " complete -F _dummy_complete ${COMP_WORDS[0]}\n"
+ " return 124\n"
+ " fi\n"
+ "}\n"
+ "function _dummy_complete {\n"
+ " if [[ ${COMP_WORDS[COMP_CWORD]} == du ]]; then COMPREPLY=(dummy); fi\n"
+ "}\n"
+ "complete -D -F _default\n")
+ (when (>= bash-major-version 4)
+ (should (equal "dosomething dummy "
+ (bash-completion_test-complete "dosomething du")))
+ (should (equal "dosomethingelse du"
+ (bash-completion_test-complete "dosomethingelse du"))))))
;;; bash-completion-integration-test.el ends here
- [nongnu] elpa/bash-completion 5171866b65 180/313: Simplify options a bit, since the only useful option is nospace., (continued)
- [nongnu] elpa/bash-completion 5171866b65 180/313: Simplify options a bit, since the only useful option is nospace., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion a223260f2d 181/313: Get rid of bash-completion-alist completely., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 4f13e00702 183/313: Execute wordbreak completion "properly", as part of the normal, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 34221c1fdd 185/313: Make bash-completion-enable-caching the default, remove the, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 8c3995aa98 187/313: run_tests.sh displays the bash command to test against., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 3eba6922e6 190/313: Use executable-find instead of hardcoding /bin/bash., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 1d41c58bd5 192/313: Send initialization command as one string, as long as possible., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c5d4f92e6d 195/313: Still EMACS_BASH_COMPLETE using setenv for local processes., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 24088ede85 196/313: Explicitly mention compatibility with Bash 3 and 4., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 0f6466eeb4 197/313: Tell minibuffer not to delay after displaying a message while, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 0c4557a5ed 193/313: Integration test for default completion (-D).,
ELPA Syncer <=
- [nongnu] elpa/bash-completion e7869dd68d 200/313: Fix a bug when no process is associated with the current buffer, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 80be2f37a9 205/313: Check the buffer uses comint-mode before using the same process, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 28ec870dd1 019/313: only one -complete method, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 6a0ada6278 038/313: completed test cases, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 7d6236e6e7 100/313: ignore .elc files, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 1aff6d8806 084/313: comment about shell-command, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion f5384c6176 051/313: A little refactoring, test case for wordbreak completion, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 6f7c2b8b4f 080/313: removed initial version, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion a2cf41d7fc 102/313: put in accidentally removed blank line from README, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion a8b652d00a 058/313: commented all functions, ELPA Syncer, 2022/12/03