[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion 0ffaad3ef0 035/313: wordbreak-split
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion 0ffaad3ef0 035/313: wordbreak-split |
Date: |
Sat, 3 Dec 2022 10:59:13 -0500 (EST) |
branch: elpa/bash-completion
commit 0ffaad3ef055c2a622bd78900f1046bec43c39f9
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
wordbreak-split
---
bash-completion.el | 15 ++++---
bash-completion_test.el | 113 ++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 118 insertions(+), 10 deletions(-)
diff --git a/bash-completion.el b/bash-completion.el
index 4c2f2a6742..bae4f7f446 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -29,7 +29,8 @@ the following entry is added to `bash-completion-alist':
See `bash-completion-add-to-alist'.
")
-(defvar bash-completion-wordbreaks (append "\"'@><=;|&(:" nil))
+(defvar bash-completion-wordbreaks-str "\"'@><=;|&(:")
+(defvar bash-completion-wordbreaks (append bash-completion-wordbreaks-str nil))
(defun bash-completion-setup ()
(add-hook 'shell-dynamic-complete-functions
@@ -229,10 +230,12 @@ The result is a list of candidates, which might be empty."
(defun bash-completion-ends-with (str suffix)
(let ((suffix-len (length suffix))
(str-len (length str)))
- (and
- (>= str-len suffix-len)
- (equal (substring str (- suffix-len)) suffix))))
-
+ (or
+ (= 0 suffix-len)
+ (and
+ (>= str-len suffix-len)
+ (equal (substring str (- suffix-len)) suffix)))))
+
(defun bash-completion-starts-with (str prefix)
(let ((prefix-len (length prefix))
(str-len (length str)))
@@ -241,7 +244,7 @@ The result is a list of candidates, which might be empty."
(equal (substring str 0 prefix-len) prefix))))
(defun bash-completion-addsuffix (str)
- (if (and (null (string-match "[/: ]$" str))
+ (if (and (null (string-match (concat "[" (regexp-quote
bash-completion-wordbreaks-str) "/ ]$") str))
(file-accessible-directory-p (expand-file-name str
default-directory)))
(progn
(concat str "/"))
diff --git a/bash-completion_test.el b/bash-completion_test.el
index 6063af32cf..81d0b71c46 100644
--- a/bash-completion_test.el
+++ b/bash-completion_test.el
@@ -18,7 +18,11 @@
(require 'sz-testutils)
(require 'cl)
+ (defvar bash-completion-run-integration-tests t
+ "Run integration tests. Set to nil to disable them.")
;; This code will not appear in the compiled (.elc) file
+
+ ;; ---------- unit tests
(put 'bash-completion-regress 'regression-suite t)
(setq bash-completion-regress
'("bash-completion-regress"
@@ -290,15 +294,116 @@ garbage
(bash-completion-send "cmd" 'process 3.14))))
"line1\nline2\n")
- )))
-
+ ("bash-completion-cd-command-prefix no current dir"
+ (let ((default-directory nil))
+ (bash-completion-cd-command-prefix))
+ "")
+
+ ("bash-completion-cd-command-prefix current dir"
+ (let ((default-directory "/tmp/x"))
+ (bash-completion-cd-command-prefix))
+ "cd 2>/dev/null /tmp/x ; ")
+
+ ("bash-completion-cd-command-prefix expand tilde"
+ (let ((default-directory "~/x"))
+ (bash-completion-cd-command-prefix))
+ (concat "cd 2>/dev/null " (expand-file-name "~/x") " ; "))
+
+ ("bash-completion-addsuffix ends with /"
+ (flet ((file-accessible-directory-p (a) (error "unexpected")))
+ (bash-completion-addsuffix "hello/"))
+ "hello/")
+
+ ("bash-completion-addsuffix ends with space"
+ (flet ((file-accessible-directory-p (a) (error "unexpected")))
+ (bash-completion-addsuffix "hello "))
+ "hello ")
+
+ ("bash-completion-addsuffix ends with separator"
+ (flet ((file-accessible-directory-p (a) (error "unexpected")))
+ (bash-completion-addsuffix "hello:"))
+ "hello:")
+
+ ("bash-completion-addsuffix check directory"
+ (flet ((file-accessible-directory-p (a) (equal a "/tmp/hello")))
+ (let ((default-directory "/tmp"))
+ (bash-completion-addsuffix "hello")))
+ "hello/")
+
+ ("bash-completion-addsuffix check directory, expand tilde"
+ (flet ((file-accessible-directory-p (a) (equal a (concat
(expand-file-name "y" "~/x")))))
+ (let ((default-directory "~/x"))
+ (bash-completion-addsuffix "y")))
+ "y/")
+
+ ("bash-completion-starts-with"
+ (list
+ (bash-completion-starts-with "" "hello ")
+ (bash-completion-starts-with "hello world" "hello ")
+ (bash-completion-starts-with "hello world" "hullo ")
+ (bash-completion-starts-with "hello" ""))
+ '(nil t nil t))
+
+ ("bash-completion-ends-with"
+ (list
+ (bash-completion-ends-with "" "world")
+ (bash-completion-ends-with "hello world" "world")
+ (bash-completion-ends-with "hello world" "wurld")
+ (bash-completion-ends-with "hello" ""))
+ '(nil t nil t))
+
+ ("bash-completion-last-wordbreak-split"
+ (list
+ (bash-completion-last-wordbreak-split "a:b:c:d:e")
+ (bash-completion-last-wordbreak-split "hello=world")
+ (bash-completion-last-wordbreak-split "hello>world")
+ (bash-completion-last-wordbreak-split "hello"))
+ '(("a:b:c:d:" . "e")
+ ("hello=" . "world")
+ ("hello>" . "world")
+ ("" . "hello")))
+
+ ))
+
+ ;; ---------- integration tests
+ (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)))
+ '(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)))
+ "t\n")
+ )))
;; Run diagnostics when this module is evaluated or compiled
;; if and only if the "regress" package is already loaded.
;; This code will not appear in the compiled (.elc) file
(eval-when-compile
(autoload 'regress "regress" "run regression test suites" t)
- (if (featurep 'regress)
- (regress bash-completion-regress)))
+ (when (featurep 'regress)
+ (regress bash-completion-regress)
+ (when bash-completion-run-integration-tests
+ (regress bash-completion-regress-integration))))
;;; bash-completion_test.el ends here
- [nongnu] elpa/bash-completion 208cb5ab76 007/313: Join, (continued)
- [nongnu] elpa/bash-completion 208cb5ab76 007/313: Join, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 47a890dd72 010/313: launch process, send commands, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 53f2c5d30e 009/313: parse complete -p output, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 11e52fce6f 018/313: Fixed initialization, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c10cfef5b8 015/313: complex line split, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion b5c2fbf4a2 014/313: add hooks, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 9eb026ae0b 025/313: fixed current directory for adding slash, workaround for bash ~ expansion, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 02d1acf260 030/313: wordbreaks, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 5931a2ba43 037/313: completion-fix, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion a78fd6b587 044/313: turn off mailwarn and checkjobs, continue if this failed, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 0ffaad3ef0 035/313: wordbreak-split,
ELPA Syncer <=
- [nongnu] elpa/bash-completion 80cd654c35 043/313: turn off mailwarn and checkjobs, continue if this failed, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 1c6b2efb67 040/313: enormous test, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion fc96b621e2 034/313: pass all tests in bash-completion, new test for -send, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion e77c841dac 107/313: Merge pull request #3 from seanmcl/master, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 062acfab3e 052/313: updated documentation, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 75e5de1494 066/313: fix initial completion, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion ffe8bc46a2 097/313: Ignore 'cd' stdout, in case someone (like me) is crazy enough to override the builtin command, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion b1ff763566 104/313: Clear PROMPT_COMMAND when creating bash process, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 6b1be0da4c 048/313: from split to tokenize and parse, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 679d6f7765 075/313: bugfix at try afterbreak, ELPA Syncer, 2022/12/03