[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 22675a60f794c2c76155b956eea2fb549de35da4

Freddy Vulto fvulto at gmail.com
Fri Jul 17 21:16:17 UTC 2009


The following commit has been merged in the master branch:
commit 22675a60f794c2c76155b956eea2fb549de35da4
Author: Freddy Vulto <fvulto at gmail.com>
Date:   Fri Jul 17 23:15:15 2009 +0200

    Reviewed tests f*

diff --git a/test/_completion_to_review/filesnarf.exp b/test/_completion_to_review/filesnarf.exp
deleted file mode 100644
index 74dd80a..0000000
--- a/test/_completion_to_review/filesnarf.exp
+++ /dev/null
@@ -1 +0,0 @@
-source "lib/completions/filesnarf.exp"
diff --git a/test/_completion_to_review/find.exp b/test/_completion_to_review/find.exp
deleted file mode 100644
index 0733f47..0000000
--- a/test/_completion_to_review/find.exp
+++ /dev/null
@@ -1 +0,0 @@
-source "lib/completions/find.exp"
diff --git a/test/_completion_to_review/find_member.exp b/test/_completion_to_review/find_member.exp
deleted file mode 100644
index dd0ee8b..0000000
--- a/test/_completion_to_review/find_member.exp
+++ /dev/null
@@ -1 +0,0 @@
-source "lib/completions/find_member.exp"
diff --git a/test/_completion_to_review/fmt.exp b/test/_completion_to_review/fmt.exp
deleted file mode 100644
index c81bb3c..0000000
--- a/test/_completion_to_review/fmt.exp
+++ /dev/null
@@ -1 +0,0 @@
-source "lib/completions/fmt.exp"
diff --git a/test/_completion_to_review/fold.exp b/test/_completion_to_review/fold.exp
deleted file mode 100644
index 82d0f9d..0000000
--- a/test/_completion_to_review/fold.exp
+++ /dev/null
@@ -1 +0,0 @@
-source "lib/completions/fold.exp"
diff --git a/test/completion/filesnarf.exp b/test/completion/filesnarf.exp
new file mode 100644
index 0000000..d4ca737
--- /dev/null
+++ b/test/completion/filesnarf.exp
@@ -0,0 +1,3 @@
+if {[assert_bash_type {filesnarf}]} {
+    source "lib/completions/filesnarf.exp"
+}; # if
diff --git a/test/completion/find.exp b/test/completion/find.exp
new file mode 100644
index 0000000..b82e132
--- /dev/null
+++ b/test/completion/find.exp
@@ -0,0 +1,3 @@
+if {[assert_bash_type {find}]} {
+    source "lib/completions/find.exp"
+}; # if
diff --git a/test/completion/find_member.exp b/test/completion/find_member.exp
new file mode 100644
index 0000000..6bd3280
--- /dev/null
+++ b/test/completion/find_member.exp
@@ -0,0 +1,3 @@
+if {[assert_bash_type {find_member}]} {
+    source "lib/completions/find_member.exp"
+}; # if
diff --git a/test/completion/fmt.exp b/test/completion/fmt.exp
new file mode 100644
index 0000000..abb52c1
--- /dev/null
+++ b/test/completion/fmt.exp
@@ -0,0 +1,3 @@
+if {[assert_bash_type {fmt}]} {
+    source "lib/completions/fmt.exp"
+}; # if
diff --git a/test/completion/fold.exp b/test/completion/fold.exp
new file mode 100644
index 0000000..5e8d376
--- /dev/null
+++ b/test/completion/fold.exp
@@ -0,0 +1,3 @@
+if {[assert_bash_type {fold}]} {
+    source "lib/completions/fold.exp"
+}; # if
diff --git a/test/lib/completions/evince.exp b/test/lib/completions/evince.exp
index 67dc807..527a995 100644
--- a/test/lib/completions/evince.exp
+++ b/test/lib/completions/evince.exp
@@ -11,6 +11,9 @@ proc teardown {} {
 setup
 
 
+# NOTE: The directory `fixtures/evince' contains an additional subdir `foo'
+#       (should be visible as completion) and an additional file `.txt'
+#       (shouldn't be visible as completion)
 set files {
     foo/
     .bmp .BMP .cbr .CBR .cbz .CBZ .djv .DJV .djvu .DJVU
@@ -27,7 +30,7 @@ set prompt "/fixtures/evince/@"
 assert_bash_exec "cd fixtures/evince" "" $prompt
 assert_complete $files "evince " "" $prompt
 sync_after_int $prompt
-assert_bash_exec "cd ../.."
+assert_bash_exec "cd \$TESTDIR"
 
 
 teardown
diff --git a/test/lib/completions/animate.exp b/test/lib/completions/filesnarf.exp
similarity index 80%
copy from test/lib/completions/animate.exp
copy to test/lib/completions/filesnarf.exp
index 26065d2..53cf01e 100644
--- a/test/lib/completions/animate.exp
+++ b/test/lib/completions/filesnarf.exp
@@ -11,7 +11,7 @@ proc teardown {} {
 setup
 
 
-assert_complete_any "animate "
+assert_complete_any "filesnarf -"
 
 
 sync_after_int
diff --git a/test/lib/completions_to_review/find.exp b/test/lib/completions/find.exp
similarity index 57%
rename from test/lib/completions_to_review/find.exp
rename to test/lib/completions/find.exp
index e39d038..63f5018 100644
--- a/test/lib/completions_to_review/find.exp
+++ b/test/lib/completions/find.exp
@@ -1,23 +1,17 @@
 proc setup {} {
+    save_env
 }; # setup()
 
 
 proc teardown {} {
+    assert_env_unmodified {/OLDPWD=/d}
 }; # teardown()
 
 
 setup
 
 
-set test "Tab should show completions"
-    # Try completion
-set cmd "find "
-send "$cmd\t"
-expect {
-    -re "$cmd\r\n.*$cmd$" { pass "$test" }
-    -re /@ { unresolved "$test at prompt" }
-    -re eof { unresolved "eof" }
-}; # expect
+assert_complete_any "find "
 
 
 sync_after_int
@@ -35,29 +29,16 @@ sync_after_int
 
 
 set test "-wholename should complete files/dirs"
-    # Change directory
-set cmd "cd fixture1"
-send "$cmd\r"
-expect -ex "$cmd\r\n/fixture1/@"
-    # Complete
-set cmd "find -wholename "
-send "$cmd\t"
-expect {
-    -re "$cmd\r\n(\.svn/ +|)bar +bar bar.d/ +foo +foo.d/ *(\.svn/ *|)\r\n/fixture1/@$cmd$" { 
-	pass "$test" 
-    }
-    -re /@ { unresolved "$test at prompt" }
-    -re eof { unresolved "eof" }
-}; # expect
-
-
-sync_after_int
-
+    # Change directory to `fixture1'
+set dir fixture1
+set prompt "/$dir/@"
+assert_bash_exec "cd $dir" "" $prompt
+    # NOTE: `-p' adds a slash to directories
+set files [split [exec bash -c "cd $dir && ls -p"] "\n"]
+assert_complete $files "find -wholename " "" $prompt
+sync_after_int $prompt
+assert_bash_exec "cd \$TESTDIR"
 
-    # Restore directory
-set cmd "cd .."
-send "$cmd\r"
-expect -ex "$cmd\r\n/@"
 
 
 set test "-uid should complete uids"
@@ -65,9 +46,7 @@ set test "-uid should complete uids"
 set cmd "find -uid "
 send "$cmd\t"
 expect {
-    -re "$cmd\r\n\\d+.*/@$cmd$" { 
-	pass "$test" 
-    }
+    -re "$cmd\r\n\\d+.*/@$cmd$" { pass "$test" }
     -re /@ { unresolved "$test at prompt" }
     -re eof { unresolved "eof" }
 }; # expect
@@ -81,9 +60,7 @@ set test "-gid should complete gids"
 set cmd "find -gid "
 send "$cmd\t"
 expect {
-    -re "$cmd\r\n\\d+.*/@$cmd$" { 
-	pass "$test" 
-    }
+    -re "$cmd\r\n\\d+.*/@$cmd$" { pass "$test" }
     -re /@ { unresolved "$test at prompt" }
     -re eof { unresolved "eof" }
 }; # expect
diff --git a/test/lib/completions/animate.exp b/test/lib/completions/find_member.exp
similarity index 79%
copy from test/lib/completions/animate.exp
copy to test/lib/completions/find_member.exp
index 26065d2..58fac7d 100644
--- a/test/lib/completions/animate.exp
+++ b/test/lib/completions/find_member.exp
@@ -11,7 +11,7 @@ proc teardown {} {
 setup
 
 
-assert_complete_any "animate "
+assert_complete_any "find_member -"
 
 
 sync_after_int
diff --git a/test/lib/completions/bc.exp b/test/lib/completions/fmt.exp
similarity index 83%
copy from test/lib/completions/bc.exp
copy to test/lib/completions/fmt.exp
index c437d03..fcf8a92 100644
--- a/test/lib/completions/bc.exp
+++ b/test/lib/completions/fmt.exp
@@ -11,7 +11,7 @@ proc teardown {} {
 setup
 
 
-assert_complete_any "bc --"
+assert_complete_any "fmt -"
 
 
 sync_after_int
diff --git a/test/lib/completions/bash.exp b/test/lib/completions/fold.exp
similarity index 82%
copy from test/lib/completions/bash.exp
copy to test/lib/completions/fold.exp
index 4caf58f..673fe21 100644
--- a/test/lib/completions/bash.exp
+++ b/test/lib/completions/fold.exp
@@ -11,7 +11,7 @@ proc teardown {} {
 setup
 
 
-assert_complete_any "bash --"
+assert_complete_any "fold --"
 
 
 sync_after_int
diff --git a/test/lib/completions_to_review/filesnarf.exp b/test/lib/completions_to_review/filesnarf.exp
deleted file mode 100644
index 1f2aaa1..0000000
--- a/test/lib/completions_to_review/filesnarf.exp
+++ /dev/null
@@ -1,26 +0,0 @@
-proc setup {} {
-}; # setup()
-
-
-proc teardown {} {
-}; # teardown()
-
-
-setup
-
-
-set test "Tab should complete"
-    # Try completion
-set cmd "filesnarf -"
-send "$cmd\t"
-expect {
-    -re "^$cmd\r\n.*$cmd$" { pass "$test" }
-    -re /@ { unresolved "$test at prompt" }
-    -re eof { unresolved "eof" }
-}; # expect
-
-
-sync_after_int
-
-
-teardown
diff --git a/test/lib/completions_to_review/find_member.exp b/test/lib/completions_to_review/find_member.exp
deleted file mode 100644
index e6dccb6..0000000
--- a/test/lib/completions_to_review/find_member.exp
+++ /dev/null
@@ -1,26 +0,0 @@
-proc setup {} {
-}; # setup()
-
-
-proc teardown {} {
-}; # teardown()
-
-
-setup
-
-
-set test "Tab should complete"
-    # Try completion
-set cmd "find_member -"
-send "$cmd\t"
-expect {
-    -re "^$cmd\r\n.*$cmd$" { pass "$test" }
-    -re /@ { unresolved "$test at prompt" }
-    -re eof { unresolved "eof" }
-}; # expect
-
-
-sync_after_int
-
-
-teardown
diff --git a/test/lib/completions_to_review/fmt.exp b/test/lib/completions_to_review/fmt.exp
deleted file mode 100644
index 9ba81c6..0000000
--- a/test/lib/completions_to_review/fmt.exp
+++ /dev/null
@@ -1,26 +0,0 @@
-proc setup {} {
-}; # setup()
-
-
-proc teardown {} {
-}; # teardown()
-
-
-setup
-
-
-set test "Tab should complete"
-    # Try completion
-set cmd "fmt "
-send "$cmd\t"
-expect {
-    -re "^$cmd\r\n.*$cmd$" { pass "$test" }
-    -re /@ { unresolved "$test at prompt" }
-    -re eof { unresolved "eof" }
-}; # expect
-
-
-sync_after_int
-
-
-teardown
diff --git a/test/lib/completions_to_review/fold.exp b/test/lib/completions_to_review/fold.exp
deleted file mode 100644
index 8e3d0db..0000000
--- a/test/lib/completions_to_review/fold.exp
+++ /dev/null
@@ -1,26 +0,0 @@
-proc setup {} {
-}; # setup()
-
-
-proc teardown {} {
-}; # teardown()
-
-
-setup
-
-
-set test "Tab should complete"
-    # Try completion
-set cmd "fold "
-send "$cmd\t"
-expect {
-    -re "^$cmd\r\n.*$cmd$" { pass "$test" }
-    -re /@ { unresolved "$test at prompt" }
-    -re eof { unresolved "eof" }
-}; # expect
-
-
-sync_after_int
-
-
-teardown
diff --git a/test/lib/library.exp b/test/lib/library.exp
index 8f6c18b..f5043ff 100644
--- a/test/lib/library.exp
+++ b/test/lib/library.exp
@@ -134,7 +134,11 @@ proc assert_complete_any {cmd {test ""} {prompt /@}} {
         # Escape special regexp characters
     regsub -all {([\[\]\(\)\.\\\+])} $cmd {\\\1} cmd
     expect {
-        -re "^\r\n.*$prompt$cmd$" { pass "$test" }
+        # NOTE: The `\S*' (zero or more non-whitespace characters) matches a
+        #       possible enlargement of a command's partial completion if the
+        #       list of completions have a larger common prefix.
+        #       E.g. `fmt -' becomes `fmt --' (two dashes) when completing
+        -re "^\r\n.*$prompt$cmd\\S*$" { pass "$test" }
         -re $prompt { unresolved "$test at prompt" }
         -re eof { unresolved "eof" }
     }; # expect
@@ -238,10 +242,16 @@ proc assert_exec {cmd {stdout ''} {test ''}} {
 # @return list  Hostnames
 proc get_hosts {} {
     set hosts [exec bash -c "compgen -A hostname"]
-    lappend hosts [exec bash -c {
-        type avahi-browse >&/dev/null && 
-            avahi-browse -kcpr _workstation._tcp | grep ^= | cut -d\; -f7 | sort -u
+    # NOTE: Circumenventing `avahi_host' and appending directly to `hosts'
+    #       causes an empty element to be inserted in `hosts'.
+    #       -- FVu, Fri Jul 17 23:11:46 CEST 2009
+    set avahi_hosts [exec bash -c {
+        type avahi-browse >&/dev/null && [ -n "$(pidof avahi-daemon)" ]
+            avahi-browse -cpr _workstation._tcp | grep ^= | cut -d\; -f7 | sort -u
     }]
+    if {[llength $avahi_hosts] > 1} {
+        lappend hosts $avahi_hosts
+    }; # if
     return $hosts
 }; # get_hosts()
 

-- 
bash-completion



More information about the Bash-completion-commits mailing list