[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 67c3ea26e7e455826561949abb476b25645e4e46
Freddy Vulto
fvulto at gmail.com
Fri Jun 12 09:48:46 UTC 2009
The following commit has been merged in the master branch:
commit 67c3ea26e7e455826561949abb476b25645e4e46
Author: Freddy Vulto <fvulto at gmail.com>
Date: Fri Jun 12 11:47:28 2009 +0200
Added xhost test
To run the test:
$ cd test
$ ./runCompletion xhost.exp
diff --git a/test/completion/ssh.exp b/test/completion/xhost.exp
similarity index 84%
copy from test/completion/ssh.exp
copy to test/completion/xhost.exp
index 5b14ce2..e79abf5 100644
--- a/test/completion/ssh.exp
+++ b/test/completion/xhost.exp
@@ -1,4 +1,4 @@
-source "lib/completions/ssh.exp"
+source "lib/completions/xhost.exp"
# TODO: Dynamic loading of completions. After the tests have the first time and
# real completion is installed, the tests can be run a second time.
diff --git a/test/lib/completions/xhost.exp b/test/lib/completions/xhost.exp
new file mode 100644
index 0000000..c6e8284
--- /dev/null
+++ b/test/lib/completions/xhost.exp
@@ -0,0 +1,99 @@
+proc setup {} {
+ save_env
+}; # setup()
+
+
+proc teardown {} {
+ assert_env_unmodified
+}; # teardown()
+
+
+setup
+
+
+set test "Tab should complete hostnames"
+
+ # Build string list of hostnames, separated by regexp whitespace (\s+)
+ # Example string: host1\s+host2\s+host3
+
+set hosts {}
+foreach h [exec bash -c "compgen -A hostname"] {
+ # Escape special regexp characters (+) in hostname
+ regsub -all {([\+])} $h {\\\1} h
+ lappend hosts $h
+}; # foreach
+set hosts [lsort -ascii $hosts]
+set hosts [join $hosts "\\s+"]
+ # Try completion
+set cmd "xhost "
+send "$cmd\t"
+set expected "^$cmd\r\n$hosts\r\n/@$cmd$"
+expect {
+ -re $expected { pass "$test" }
+ -re /@ { unresolved "$test at prompt" }
+ default { unresolved "$test" }
+}; # expect
+
+
+sync_after_int
+
+
+set test "Tab should complete hostnames prefixed with +"
+
+ # Build string list of hostnames, separated by regexp whitespace (\s+) and
+ # 'plus' (+) prefix
+ # Example string: \+host1\s+\+host2\s+\+host3
+
+set hosts {}
+foreach h [exec bash -c "compgen -A hostname"] {
+ # Escape special regexp characters (+) in hostname
+ regsub -all {([\+])} $h {\\\1} h
+ lappend hosts $h
+}; # foreach
+set hosts [lsort -ascii $hosts]
+set hosts "\\+[join $hosts "\\s+\\+"]"
+ # Try completion
+set cmd "xhost +"
+send "$cmd\t"
+ # Escape special regexp characters (+) in cmd
+regsub -all {([\+])} $cmd {\\\1} cmd
+set expected "^$cmd\r\n$hosts\r\n/@$cmd$"
+expect {
+ -re $expected { pass "$test" }
+ -re /@ { unresolved "$test at prompt" }
+ default { unresolved "$test" }
+}; # expect
+
+
+sync_after_int
+
+
+set test "Tab should complete hostnames prefixed with -"
+
+ # Build string list of hostnames, separated by regexp whitespace (\s+) and
+ # 'minus' (-) prefix
+ # Example string: -host1\s+-host2\s+-host3
+
+set hosts {}
+foreach h [exec bash -c "compgen -A hostname"] {
+ # Escape special regexp characters (+) in hostname
+ regsub -all {([\+])} $h {\\\1} h
+ lappend hosts $h
+}; # foreach
+set hosts [lsort -ascii $hosts]
+set hosts "-[join $hosts "\\s+-"]"
+ # Try completion
+set cmd "xhost -"
+send "$cmd\t"
+set expected "^$cmd\r\n$hosts\r\n/@$cmd$"
+expect {
+ -re $expected { pass "$test" }
+ -re /@ { unresolved "$test at prompt" }
+ default { unresolved "$test" }
+}; # expect
+
+
+sync_after_int
+
+
+teardown
--
bash-completion
More information about the Bash-completion-commits
mailing list