[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 55bc44b03514c6450ee8eea2de6369249e6846e0

Freddy Vulto (none) freddy at rebase.
Fri Jul 17 14:17:34 UTC 2009


The following commit has been merged in the master branch:
commit 55bc44b03514c6450ee8eea2de6369249e6846e0
Author: Freddy Vulto <freddy at rebase.(none)>
Date:   Fri Jul 17 16:15:02 2009 +0200

    Reviewed tests e*
    Fixed `assert_complete()' to remove an optional (partial) argument from
    `cmd' when expecting `cmd + longestCommonPrefix'.
    Added `prompt' argument to procs `assert_bash_exec()' &
    `sync_after_int()'

diff --git a/test/_completion_to_review/enscript.exp b/test/_completion_to_review/enscript.exp
deleted file mode 100644
index b10236b..0000000
--- a/test/_completion_to_review/enscript.exp
+++ /dev/null
@@ -1 +0,0 @@
-source "lib/completions/enscript.exp"
diff --git a/test/_completion_to_review/env.exp b/test/_completion_to_review/env.exp
deleted file mode 100644
index cc47ea1..0000000
--- a/test/_completion_to_review/env.exp
+++ /dev/null
@@ -1 +0,0 @@
-source "lib/completions/env.exp"
diff --git a/test/_completion_to_review/evince.exp b/test/_completion_to_review/evince.exp
deleted file mode 100644
index 3df860e..0000000
--- a/test/_completion_to_review/evince.exp
+++ /dev/null
@@ -1,12 +0,0 @@
-set test "Completion via _filedir_xspec() should be installed"
-set cmd "complete -p evince"
-send "$cmd\r"
-
-set expected "^$cmd\r\ncomplete -o filenames -F _filedir_xspec evince\r\n/@$"
-expect {
-    -re $expected  { pass "$test" }
-    -re /@ { fail "$test at prompt" }
-}; # expect
-
-
-source "lib/completions/evince.exp"
diff --git a/test/_completion_to_review/expand.exp b/test/_completion_to_review/expand.exp
deleted file mode 100644
index 55eec5a..0000000
--- a/test/_completion_to_review/expand.exp
+++ /dev/null
@@ -1 +0,0 @@
-source "lib/completions/expand.exp"
diff --git a/test/completion/enscript.exp b/test/completion/enscript.exp
new file mode 100644
index 0000000..ec6d75c
--- /dev/null
+++ b/test/completion/enscript.exp
@@ -0,0 +1,3 @@
+if {[assert_bash_type {enscript}]} {
+    source "lib/completions/enscript.exp"
+}; # if
diff --git a/test/completion/env.exp b/test/completion/env.exp
new file mode 100644
index 0000000..a96c053
--- /dev/null
+++ b/test/completion/env.exp
@@ -0,0 +1,3 @@
+if {[assert_bash_type {env}]} {
+    source "lib/completions/env.exp"
+}; # if
diff --git a/test/completion/evince.exp b/test/completion/evince.exp
new file mode 100644
index 0000000..24815d5
--- /dev/null
+++ b/test/completion/evince.exp
@@ -0,0 +1 @@
+source "lib/completions/evince.exp"
diff --git a/test/completion/expand.exp b/test/completion/expand.exp
new file mode 100644
index 0000000..783069d
--- /dev/null
+++ b/test/completion/expand.exp
@@ -0,0 +1,3 @@
+if {[assert_bash_type {expand}]} {
+    source "lib/completions/expand.exp"
+}; # if
diff --git a/test/fixture1/bar b/test/fixtures/evince/.BMP
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.BMP
diff --git a/test/fixture1/bar b/test/fixtures/evince/.CBR
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.CBR
diff --git a/test/fixture1/bar b/test/fixtures/evince/.CBZ
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.CBZ
diff --git a/test/fixture1/bar b/test/fixtures/evince/.DJV
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.DJV
diff --git a/test/fixture1/bar b/test/fixtures/evince/.DJVU
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.DJVU
diff --git a/test/fixture1/bar b/test/fixtures/evince/.DVI
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.DVI
diff --git a/test/fixture1/bar b/test/fixtures/evince/.DVI.BZ2
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.DVI.BZ2
diff --git a/test/fixture1/bar b/test/fixtures/evince/.DVI.GZ
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.DVI.GZ
diff --git a/test/fixture1/bar b/test/fixtures/evince/.DVI.bz2
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.DVI.bz2
diff --git a/test/fixture1/bar b/test/fixtures/evince/.DVI.gz
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.DVI.gz
diff --git a/test/fixture1/bar b/test/fixtures/evince/.EPS
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.EPS
diff --git a/test/fixture1/bar b/test/fixtures/evince/.EPS.BZ2
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.EPS.BZ2
diff --git a/test/fixture1/bar b/test/fixtures/evince/.EPS.GZ
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.EPS.GZ
diff --git a/test/fixture1/bar b/test/fixtures/evince/.EPS.bz2
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.EPS.bz2
diff --git a/test/fixture1/bar b/test/fixtures/evince/.EPS.gz
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.EPS.gz
diff --git a/test/fixture1/bar b/test/fixtures/evince/.GIF
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.GIF
diff --git a/test/fixture1/bar b/test/fixtures/evince/.ICO
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.ICO
diff --git a/test/fixture1/bar b/test/fixtures/evince/.JPEG
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.JPEG
diff --git a/test/fixture1/bar b/test/fixtures/evince/.JPG
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.JPG
diff --git a/test/fixture1/bar b/test/fixtures/evince/.MIFF
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.MIFF
diff --git a/test/fixture1/bar b/test/fixtures/evince/.PBM
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.PBM
diff --git a/test/fixture1/bar b/test/fixtures/evince/.PCX
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.PCX
diff --git a/test/fixture1/bar b/test/fixtures/evince/.PDF
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.PDF
diff --git a/test/fixture1/bar b/test/fixtures/evince/.PDF.BZ2
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.PDF.BZ2
diff --git a/test/fixture1/bar b/test/fixtures/evince/.PDF.GZ
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.PDF.GZ
diff --git a/test/fixture1/bar b/test/fixtures/evince/.PDF.bz2
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.PDF.bz2
diff --git a/test/fixture1/bar b/test/fixtures/evince/.PDF.gz
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.PDF.gz
diff --git a/test/fixture1/bar b/test/fixtures/evince/.PGM
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.PGM
diff --git a/test/fixture1/bar b/test/fixtures/evince/.PNG
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.PNG
diff --git a/test/fixture1/bar b/test/fixtures/evince/.PNM
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.PNM
diff --git a/test/fixture1/bar b/test/fixtures/evince/.PPM
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.PPM
diff --git a/test/fixture1/bar b/test/fixtures/evince/.PS
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.PS
diff --git a/test/fixture1/bar b/test/fixtures/evince/.PS.BZ2
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.PS.BZ2
diff --git a/test/fixture1/bar b/test/fixtures/evince/.PS.GZ
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.PS.GZ
diff --git a/test/fixture1/bar b/test/fixtures/evince/.PS.bz2
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.PS.bz2
diff --git a/test/fixture1/bar b/test/fixtures/evince/.PS.gz
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.PS.gz
diff --git a/test/fixture1/bar b/test/fixtures/evince/.TGA
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.TGA
diff --git a/test/fixture1/bar b/test/fixtures/evince/.TIF
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.TIF
diff --git a/test/fixture1/bar b/test/fixtures/evince/.TIFF
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.TIFF
diff --git a/test/fixture1/bar b/test/fixtures/evince/.XPM
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.XPM
diff --git a/test/fixture1/bar b/test/fixtures/evince/.XWD
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.XWD
diff --git a/test/fixture1/bar b/test/fixtures/evince/.bmp
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.bmp
diff --git a/test/fixture1/bar b/test/fixtures/evince/.cbr
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.cbr
diff --git a/test/fixture1/bar b/test/fixtures/evince/.cbz
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.cbz
diff --git a/test/fixture1/bar b/test/fixtures/evince/.djv
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.djv
diff --git a/test/fixture1/bar b/test/fixtures/evince/.djvu
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.djvu
diff --git a/test/fixture1/bar b/test/fixtures/evince/.dvi
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.dvi
diff --git a/test/fixture1/bar b/test/fixtures/evince/.dvi.BZ2
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.dvi.BZ2
diff --git a/test/fixture1/bar b/test/fixtures/evince/.dvi.GZ
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.dvi.GZ
diff --git a/test/fixture1/bar b/test/fixtures/evince/.dvi.bz2
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.dvi.bz2
diff --git a/test/fixture1/bar b/test/fixtures/evince/.dvi.gz
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.dvi.gz
diff --git a/test/fixture1/bar b/test/fixtures/evince/.eps
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.eps
diff --git a/test/fixture1/bar b/test/fixtures/evince/.eps.BZ2
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.eps.BZ2
diff --git a/test/fixture1/bar b/test/fixtures/evince/.eps.GZ
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.eps.GZ
diff --git a/test/fixture1/bar b/test/fixtures/evince/.eps.bz2
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.eps.bz2
diff --git a/test/fixture1/bar b/test/fixtures/evince/.eps.gz
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.eps.gz
diff --git a/test/fixture1/bar b/test/fixtures/evince/.gif
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.gif
diff --git a/test/fixture1/bar b/test/fixtures/evince/.ico
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.ico
diff --git a/test/fixture1/bar b/test/fixtures/evince/.jpeg
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.jpeg
diff --git a/test/fixture1/bar b/test/fixtures/evince/.jpg
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.jpg
diff --git a/test/fixture1/bar b/test/fixtures/evince/.miff
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.miff
diff --git a/test/fixture1/bar b/test/fixtures/evince/.pbm
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.pbm
diff --git a/test/fixture1/bar b/test/fixtures/evince/.pcx
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.pcx
diff --git a/test/fixture1/bar b/test/fixtures/evince/.pdf
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.pdf
diff --git a/test/fixture1/bar b/test/fixtures/evince/.pdf.BZ2
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.pdf.BZ2
diff --git a/test/fixture1/bar b/test/fixtures/evince/.pdf.GZ
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.pdf.GZ
diff --git a/test/fixture1/bar b/test/fixtures/evince/.pdf.bz2
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.pdf.bz2
diff --git a/test/fixture1/bar b/test/fixtures/evince/.pdf.gz
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.pdf.gz
diff --git a/test/fixture1/bar b/test/fixtures/evince/.pgm
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.pgm
diff --git a/test/fixture1/bar b/test/fixtures/evince/.png
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.png
diff --git a/test/fixture1/bar b/test/fixtures/evince/.pnm
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.pnm
diff --git a/test/fixture1/bar b/test/fixtures/evince/.ppm
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.ppm
diff --git a/test/fixture1/bar b/test/fixtures/evince/.ps
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.ps
diff --git a/test/fixture1/bar b/test/fixtures/evince/.ps.BZ2
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.ps.BZ2
diff --git a/test/fixture1/bar b/test/fixtures/evince/.ps.GZ
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.ps.GZ
diff --git a/test/fixture1/bar b/test/fixtures/evince/.ps.bz2
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.ps.bz2
diff --git a/test/fixture1/bar b/test/fixtures/evince/.ps.gz
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.ps.gz
diff --git a/test/fixture1/bar b/test/fixtures/evince/.tga
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.tga
diff --git a/test/fixture1/bar b/test/fixtures/evince/.tif
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.tif
diff --git a/test/fixture1/bar b/test/fixtures/evince/.tiff
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.tiff
diff --git a/test/fixture1/bar b/test/fixtures/evince/.txt
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.txt
diff --git a/test/fixture1/bar b/test/fixtures/evince/.xpm
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.xpm
diff --git a/test/fixture1/bar b/test/fixtures/evince/.xwd
similarity index 100%
copy from test/fixture1/bar
copy to test/fixtures/evince/.xwd
diff --git a/test/lib/completions/animate.exp b/test/lib/completions/enscript.exp
similarity index 80%
copy from test/lib/completions/animate.exp
copy to test/lib/completions/enscript.exp
index 26065d2..7fefabd 100644
--- a/test/lib/completions/animate.exp
+++ b/test/lib/completions/enscript.exp
@@ -11,7 +11,7 @@ proc teardown {} {
 setup
 
 
-assert_complete_any "animate "
+assert_complete_any "enscript --"
 
 
 sync_after_int
diff --git a/test/lib/completions/bc.exp b/test/lib/completions/env.exp
similarity index 83%
copy from test/lib/completions/bc.exp
copy to test/lib/completions/env.exp
index c437d03..0f523cb 100644
--- a/test/lib/completions/bc.exp
+++ b/test/lib/completions/env.exp
@@ -11,7 +11,7 @@ proc teardown {} {
 setup
 
 
-assert_complete_any "bc --"
+assert_complete_any "env --"
 
 
 sync_after_int
diff --git a/test/lib/completions/evince.exp b/test/lib/completions/evince.exp
new file mode 100644
index 0000000..67dc807
--- /dev/null
+++ b/test/lib/completions/evince.exp
@@ -0,0 +1,33 @@
+proc setup {} {
+    save_env
+}; # setup()
+
+
+proc teardown {} {
+    assert_env_unmodified {/OLDPWD=/d}
+}; # teardown()
+
+
+setup
+
+
+set files {
+    foo/
+    .bmp .BMP .cbr .CBR .cbz .CBZ .djv .DJV .djvu .DJVU
+    .dvi .DVI .dvi.bz2 .dvi.BZ2 .DVI.bz2 .DVI.BZ2 .dvi.gz .dvi.GZ .DVI.gz .DVI.GZ
+    .eps .EPS .eps.bz2 .eps.BZ2 .EPS.bz2 .EPS.BZ2 .eps.gz .eps.GZ .EPS.gz .EPS.GZ
+    .gif .GIF .ico .ICO .jpeg .JPEG .jpg .JPG .miff .MIFF .pbm .PBM .pcx .PCX 
+    .pdf .PDF .pdf.bz2 .pdf.BZ2 .PDF.bz2 .PDF.BZ2 .pdf.gz .pdf.GZ .PDF.gz .PDF.GZ
+    .pgm .PGM .png .PNG .pnm .PNM .ppm .PPM
+    .ps .PS .ps.bz2 .ps.BZ2 .PS.bz2 .PS.BZ2 .ps.gz .ps.GZ .PS.gz .PS.GZ
+    .tga .TGA .tif .TIF .tiff .TIFF
+    .xpm .XPM .xwd .XWD
+}
+set prompt "/fixtures/evince/@"
+assert_bash_exec "cd fixtures/evince" "" $prompt
+assert_complete $files "evince " "" $prompt
+sync_after_int $prompt
+assert_bash_exec "cd ../.."
+
+
+teardown
diff --git a/test/lib/completions/animate.exp b/test/lib/completions/expand.exp
similarity index 81%
copy from test/lib/completions/animate.exp
copy to test/lib/completions/expand.exp
index 26065d2..de1b7f6 100644
--- a/test/lib/completions/animate.exp
+++ b/test/lib/completions/expand.exp
@@ -11,7 +11,7 @@ proc teardown {} {
 setup
 
 
-assert_complete_any "animate "
+assert_complete_any "expand --"
 
 
 sync_after_int
diff --git a/test/lib/completions/finger.exp b/test/lib/completions/finger.exp
index 935c9b2..136f1c6 100644
--- a/test/lib/completions/finger.exp
+++ b/test/lib/completions/finger.exp
@@ -33,11 +33,11 @@ sync_after_int
 set test "Tab should complete hostnames"
 # Build string list of hostnames
 set hosts {}
-foreach h [exec bash -c "compgen -A hostname"] {
+foreach h [get_hosts] {
     # Prefix hosts with username 'test@'
     lappend hosts "test@$h"
 }; # foreach
-assert_complete $hosts "finger test@" $test
+assert_complete_partial $hosts finger test@ $test
 
 
 sync_after_int
@@ -48,7 +48,7 @@ set test "Tab should complete partial hostname"
 # host.
 set hosts {}
 set char ""
-foreach h [exec bash -c "compgen -A hostname"] {
+foreach h [get_hosts] {
     if {$char == ""} {set char [string range $h 0 0]}
         # Only append hostname if starting with $char
     if {[string range $h 0 0] == "$char"} {
diff --git a/test/lib/completions_to_review/enscript.exp b/test/lib/completions_to_review/enscript.exp
deleted file mode 100644
index e261618..0000000
--- a/test/lib/completions_to_review/enscript.exp
+++ /dev/null
@@ -1,26 +0,0 @@
-proc setup {} {
-}; # setup()
-
-
-proc teardown {} {
-}; # teardown()
-
-
-setup
-
-
-set test "Tab should complete"
-    # Try completion
-set cmd "enscript "
-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/env.exp b/test/lib/completions_to_review/env.exp
deleted file mode 100644
index 35d6fef..0000000
--- a/test/lib/completions_to_review/env.exp
+++ /dev/null
@@ -1,31 +0,0 @@
-proc setup {} {
-}; # setup()
-
-
-proc teardown {} {
-}; # teardown()
-
-
-setup
-
-
-set test "Tab should complete"
-    # Try completion
-set cmd "env "
-send "$cmd\t"
-expect {
-    -re "^$cmd\r\n.*$cmd$" { pass "$test" }
-    -re /@ { unresolved "$test at prompt" }
-    -re eof { unresolved "eof" }
-}; # expect
-
-
-# Interrupt command
-
-set test "Sync after INT"
-sleep 0.01
-send \031\003;  # QUIT/INT
-expect -ex /@
-
-
-teardown
diff --git a/test/lib/completions_to_review/evince.exp b/test/lib/completions_to_review/evince.exp
deleted file mode 100644
index 1d62aea..0000000
--- a/test/lib/completions_to_review/evince.exp
+++ /dev/null
@@ -1,32 +0,0 @@
-proc setup {} {
-    set cmd "touch fixture1/t.{CB{R,Z},DJV{,U},cb{r,z},djv{,u}}";  # Create temporary files
-    send "$cmd\r"
-    expect -ex "$cmd\r\n/@"
-}; # setup()
-
-
-proc teardown {} {
-    set cmd "rm fixture1/t.{CB{R,Z},DJV{,U},cb{r,z},djv{,u}}";  # Remove temporary files
-    send "$cmd\r"
-    expect -ex "$cmd\r\n/@"
-}; # teardown()
-
-
-setup
-
-
-set test "Tab should complete evince"
-    # Try completion
-set cmd "evince fixture1/"
-send "$cmd\t"
-expect {
-    -re "^${cmd}\r\n(\.svn/ +|)bar bar.d/ +foo.d/ +(\.svn/ +|)t.cbr +t.CBR +t.cbz +t.CBZ +t.djv +t.DJV +t.djvu +t.DJVU *\r\n/@$cmd$"  { pass "$test" }
-    -re /@ { unresolved "$test at prompt" }
-    default { unresolved "$test" }
-}; # expect
-
-
-sync_after_int
-
-
-teardown
diff --git a/test/lib/completions_to_review/expand.exp b/test/lib/completions_to_review/expand.exp
deleted file mode 100644
index 7c2ecb0..0000000
--- a/test/lib/completions_to_review/expand.exp
+++ /dev/null
@@ -1,26 +0,0 @@
-proc setup {} {
-}; # setup()
-
-
-proc teardown {} {
-}; # teardown()
-
-
-setup
-
-
-set test "Tab should complete"
-    # Try completion
-set cmd "expand "
-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 f6f5636..8f6c18b 100644
--- a/test/lib/library.exp
+++ b/test/lib/library.exp
@@ -12,19 +12,20 @@ package require textutil::string
 #                     exit status of the previously executed bash command will be 
 #                     checked; specify `title' to adorn the error message.
 # @param string $title  (optional) Command title.  If empty, `cmd' is used.
-proc assert_bash_exec {{aCmd ""} {title ""}} {
+# @param string $prompt  (optional) Bash prompt.  Default is "/@"
+proc assert_bash_exec {{aCmd ""} {title ""} {prompt /@}} {
     if {[string length $aCmd] != 0} {
         send "$aCmd\r"
         expect -ex "$aCmd\r\n"
     }; # if
     if {[string length $title] == 0} {set title $aCmd}
-    expect -ex "/@"
+    expect -ex $prompt
     set out $expect_out(buffer);  # Catch (non-expected) output
     set cmd "echo $?"
     send "$cmd\r"
     expect {
-        -ex "$cmd\r\n0\r\n/@" {}
-        /@ {
+        -ex "$cmd\r\n0\r\n$prompt" {}
+        $prompt {
             if {[info exists multipass_name]} {
                 fail "ERROR executing bash command \"$title\""
             }; # if
@@ -51,12 +52,13 @@ proc assert_bash_type {command} {
 }; # assert_bash_type()
 
 
-# Make sure the expected items are also returned by TAB-completing the
-# specified command.
+# Make sure the expected items are returned by TAB-completing the specified
+# command.
 # Break items into chunks because `expect' seems to have a limited buffer size
 # @param list $expected
 # @param string $cmd  Command given to generate items
 # @param string $test  (optional) Test titel.  Default is "$cmd<TAB> should show completions"
+# @param string $prompt  (optional) Bash prompt.  Default is "/@"
 # @param integer $size  (optional) Chunk size.  Default is 20.
 # @result boolean  True if successful, False if not
 proc assert_complete {expected cmd {test ""} {prompt /@} {size 20}} {
@@ -78,9 +80,14 @@ proc assert_complete {expected cmd {test ""} {prompt /@} {size 20}} {
         if {[llength $expected] == 1} {
             pass "$test"
         } else {
+            # Remove optional (partial) argument from `cmd'.
+            # E.g. "finger test@" becomes "finger"
+            set cmd2 [lindex [split $cmd] 0]
+            # Determine common prefix of completions
             set common [::textutil::string::longestCommonPrefixList $expected]
+            if {[string length $common] > 0} {set common " $common"}
             expect {
-                -ex "$prompt$cmd$common" { pass "$test" }
+                -ex "$prompt$cmd2$common" { pass "$test" }
                 -re $prompt { unresolved "$test at prompt" }
                 -re eof { unresolved "eof" }
             }; # expect
@@ -98,6 +105,7 @@ proc assert_complete {expected cmd {test ""} {prompt /@} {size 20}} {
 # @param list $expected  List of all completions.
 # @param string $cmd  Command given to generate items
 # @param string $test  (optional) Test titel.  Default is "$cmd<TAB> should show completions"
+# @param string $prompt  (optional) Bash prompt.  Default is "/@"
 # @param integer $size  (optional) Chunk size.  Default is 20.
 # @result boolean  True if successful, False if not
 proc assert_complete_partial {expected cmd {partial ""} {test ""} {prompt /@} {size 20}} {
@@ -127,7 +135,7 @@ proc assert_complete_any {cmd {test ""} {prompt /@}} {
     regsub -all {([\[\]\(\)\.\\\+])} $cmd {\\\1} cmd
     expect {
         -re "^\r\n.*$prompt$cmd$" { pass "$test" }
-        -re /@ { unresolved "$test at prompt" }
+        -re $prompt { unresolved "$test at prompt" }
         -re eof { unresolved "eof" }
     }; # expect
 }; # assert_complete_any()
@@ -136,7 +144,14 @@ proc assert_complete_any {cmd {test ""} {prompt /@}} {
 # Make sure the bash environment hasn't changed between now and the last call
 # to `save_env()'.
 # @param string $sed  Sed commands to preprocess diff output.
-#                     E.g.: s/COMP_PATH=.*/COMP_PATH=PATH/
+#                     Example calls:
+#                  
+#                         # Replace `COMP_PATH=.*' with `COMP_PATH=PATH'
+#                         assert_env_unmodified {s/COMP_PATH=.*/COMP_PATH=PATH/}
+#                  
+#                         # Remove lines containing with `OLDPWD='
+#                         assert_env_unmodified {/OLDPWD=/d}
+# 
 # @param string $file  Filename to generate environment save file from.  See
 #                      `gen_env_filename()'.
 # @param string $diff  Expected diff output (after being processed by $sed)
@@ -328,11 +343,12 @@ proc _save_env {{file ""}} {
 
 # Interrupt completion and sync with prompt.
 # Send signals QUIT & INT.
-proc sync_after_int {} {
+# @param string $prompt  (optional) Bash prompt.  Default is "/@"
+proc sync_after_int {{prompt /@}} {
     set test "Sync after INT"
     sleep .1
     send \031\003;  # QUIT/INT
-    expect /@
+    expect $prompt
 }; # sync_after_int()
 
 

-- 
bash-completion



More information about the Bash-completion-commits mailing list