Reviewed tests j* & k*

This commit is contained in:
Freddy Vulto 2009-07-19 14:48:55 +02:00
parent 11302d4038
commit f1f61ace51
54 changed files with 320 additions and 352 deletions

View File

@ -1 +0,0 @@
source "lib/completions/javac.exp"

View File

@ -1 +0,0 @@
source "lib/completions/javadoc.exp"

View File

@ -1 +0,0 @@
source "lib/completions/killall.exp"

View File

@ -1 +0,0 @@
source "lib/completions/kldload.exp"

View File

@ -1 +0,0 @@
source "lib/completions/kldunload.exp"

View File

@ -1 +0,0 @@
source "lib/completions/kplayer.exp"

View File

@ -0,0 +1,3 @@
if {[assert_bash_type {javac}]} {
source "lib/completions/javac.exp"
}; # if

View File

@ -0,0 +1,3 @@
if {[assert_bash_type {javadoc}]} {
source "lib/completions/javadoc.exp"
}; # if

1
test/completion/kdvi.exp Normal file
View File

@ -0,0 +1 @@
source "lib/completions/kdvi.exp"

View File

@ -0,0 +1,3 @@
if {[assert_bash_type {killall}]} {
source "lib/completions/killall.exp"
}; # if

View File

@ -0,0 +1,3 @@
if {[assert_bash_type {kldload}]} {
source "lib/completions/kldload.exp"
}; # if

View File

@ -0,0 +1,3 @@
if {[assert_bash_type {kldunload}]} {
source "lib/completions/kldunload.exp"
}; # if

1
test/completion/kpdf.exp Normal file
View File

@ -0,0 +1 @@
source "lib/completions/kpdf.exp"

View File

@ -0,0 +1,3 @@
if {[assert_bash_type {mplayer}]} {
source "lib/completions/kplayer.exp"
}; # if

0
test/fixtures/kdvi/.DVI vendored Normal file
View File

0
test/fixtures/kdvi/.DVI.Z vendored Normal file
View File

0
test/fixtures/kdvi/.DVI.bz2 vendored Normal file
View File

0
test/fixtures/kdvi/.DVI.gz vendored Normal file
View File

0
test/fixtures/kdvi/.dvi vendored Normal file
View File

0
test/fixtures/kdvi/.dvi.Z vendored Normal file
View File

0
test/fixtures/kdvi/.dvi.bz2 vendored Normal file
View File

0
test/fixtures/kdvi/.dvi.gz vendored Normal file
View File

0
test/fixtures/kdvi/.txt vendored Normal file
View File

0
test/fixtures/kpdf/.EPS vendored Normal file
View File

0
test/fixtures/kpdf/.PDF vendored Normal file
View File

0
test/fixtures/kpdf/.PS vendored Normal file
View File

0
test/fixtures/kpdf/.eps vendored Normal file
View File

0
test/fixtures/kpdf/.pdf vendored Normal file
View File

0
test/fixtures/kpdf/.ps vendored Normal file
View File

0
test/fixtures/kpdf/.txt vendored Normal file
View File

View File

@ -26,11 +26,10 @@ set files {
.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 \$TESTDIR"
assert_complete_dir $files "evince " "fixtures/evince"
sync_after_int
teardown

View File

@ -0,0 +1,20 @@
proc setup {} {
save_env
}; # setup()
proc teardown {} {
assert_env_unmodified
}; # teardown()
setup
assert_complete_any "java -"
sync_after_int
teardown

View File

@ -0,0 +1,20 @@
proc setup {} {
save_env
}; # setup()
proc teardown {} {
assert_env_unmodified
}; # teardown()
setup
assert_complete_any "javac "
sync_after_int
teardown

View File

@ -0,0 +1,20 @@
proc setup {} {
save_env
}; # setup()
proc teardown {} {
assert_env_unmodified
}; # teardown()
setup
assert_complete_any "javadoc "
sync_after_int
teardown

View File

@ -0,0 +1,27 @@
proc setup {} {
save_env
}; # setup()
proc teardown {} {
assert_env_unmodified {/OLDPWD=/d}
}; # teardown()
setup
# NOTE: The directory `fixtures/kdvi' contains an additional subdir `foo'
# (should be visible as completion) and an additional file `.txt'
# (shouldn't be visible as completion)
set files {
foo/
.dvi .DVI .dvi.bz2 .DVI.bz2 .dvi.gz .DVI.gz .dvi.Z .DVI.Z
}
assert_complete_dir $files "kdvi " "fixtures/kdvi"
sync_after_int
teardown

View File

@ -0,0 +1,24 @@
proc setup {} {
}; # setup()
proc teardown {} {
}; # teardown()
setup
assert_complete_any "kill 1"
sync_after_int
assert_complete [get_signals] "kill -"
sync_after_int
teardown

View File

@ -0,0 +1,26 @@
proc setup {} {
save_env
}; # setup()
proc teardown {} {
assert_env_unmodified
}; # teardown()
setup
assert_complete_any "killall "
sync_after_int
assert_complete [get_signals] "killall -"
sync_after_int
teardown

View File

@ -0,0 +1,20 @@
proc setup {} {
save_env
}; # setup()
proc teardown {} {
assert_env_unmodified
}; # teardown()
setup
assert_complete_any "kldload "
sync_after_int
teardown

View File

@ -0,0 +1,20 @@
proc setup {} {
save_env
}; # setup()
proc teardown {} {
assert_env_unmodified
}; # teardown()
setup
assert_complete_any "kldunload "
sync_after_int
teardown

View File

@ -0,0 +1,26 @@
proc setup {} {
save_env
}; # setup()
proc teardown {} {
assert_env_unmodified {/OLDPWD=/d}
}; # teardown()
setup
# NOTE: The directory `fixtures/kpdf' contains an additional subdir `foo'
# (should be visible as completion) and an additional file `.txt'
# (shouldn't be visible as completion)
set files {
foo/ .eps .ps .EPS .PS .pdf .PDF
}
assert_complete_dir $files "kpdf " "fixtures/kpdf"
sync_after_int
teardown

View File

@ -0,0 +1,20 @@
proc setup {} {
save_env
}; # setup()
proc teardown {} {
assert_env_unmodified
}; # teardown()
setup
assert_complete_any "kplayer "
sync_after_int
teardown

View File

@ -1,26 +0,0 @@
proc setup {} {
}; # setup()
proc teardown {} {
}; # teardown()
setup
set test "Tab should complete"
# Try completion
set cmd "java -"
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

View File

@ -1,26 +0,0 @@
proc setup {} {
}; # setup()
proc teardown {} {
}; # teardown()
setup
set test "Tab should complete"
# Try completion
set cmd "javac "
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

View File

@ -1,26 +0,0 @@
proc setup {} {
}; # setup()
proc teardown {} {
}; # teardown()
setup
set test "Tab should complete"
# Try completion
set cmd "javadoc "
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

View File

@ -1,35 +0,0 @@
proc setup {} {
set test setup
set cmd "touch fixture1/t.{dvi{,.gz,.bz2},DVI{,.gz,.bz2}}"; # Create temporary files
send "$cmd\r"
expect -ex "$cmd\r\n/@"
}; # setup()
proc teardown {} {
set test teardown
set cmd "rm fixture1/t.{dvi{,.gz,.bz2},DVI{,.gz,.bz2}}"; # Remove temporary files
send "$cmd\r"
expect -ex "$cmd\r\n/@"
}; # teardown()
setup
set test "Tab should complete kdvi"
# Try completion
set cmd "kdvi fixture1/"
send "$cmd\t"
expect {
-re "^${cmd}\r\n(\.svn/ +|)bar bar.d/ +foo.d/ +(\.svn/ +|)t.dvi +t.DVI +t.dvi.bz2 +t.DVI.bz2 +t.dvi.gz +t.DVI.gz *\r\n/@$cmd$" { pass "$test" }
-re /@ { unresolved "$test at prompt" }
default { unresolved "$test" }
}; # expect
#sleep .5
sync_after_int
teardown

View File

@ -1,40 +0,0 @@
proc setup {} {
}; # setup()
proc teardown {} {
}; # teardown()
setup
set test "Tab should show completions"
# Try completion
set cmd "kill 1"
send "$cmd\t"
expect {
-re "$cmd\r\n.*$cmd$" { pass "$test" }
-re /@ { unresolved "$test at prompt" }
-re eof { unresolved "eof" }
}; # expect
sync_after_int
set test "Tab should show signals"
# Try completion
set cmd "kill -"
send "$cmd\t"
expect {
-re "$cmd\r\n.*-KILL.*$cmd$" { pass "$test" }
-re /@ { unresolved "$test at prompt" }
-re eof { unresolved "eof" }
}; # expect
sync_after_int
teardown

View File

@ -1,40 +0,0 @@
proc setup {} {
}; # setup()
proc teardown {} {
}; # teardown()
setup
set test "Tab should show completions"
# Try completion
set cmd "killall "
send "$cmd\t"
expect {
-re "$cmd\r\n.*/@$cmd$" { pass "$test" }
-re /@ { unresolved "$test at prompt" }
-re eof { unresolved "eof" }
}; # expect
sync_after_int
set test "Tab should complete signals"
# Try completion
set cmd "killall -"
send "$cmd\t"
expect {
-re "$cmd\r\n.*-KILL.*/@$cmd$" { pass "$test" }
-re /@ { unresolved "$test at prompt" }
-re eof { unresolved "eof" }
}; # expect
sync_after_int
teardown

View File

@ -1,28 +0,0 @@
proc setup {} {
}; # setup()
proc teardown {} {
}; # teardown()
setup
set test "Tab should complete"
# Try completion
set cmd "kldload "
send "$cmd\t"
sync_after_tab
expect {
-re "^$cmd.*$" { pass "$test" }
-re /@ { unresolved "$test at prompt" }
-re eof { unresolved "eof" }
}; # expect
sleep .4
sync_after_int
teardown

View File

@ -1,28 +0,0 @@
proc setup {} {
}; # setup()
proc teardown {} {
}; # teardown()
setup
set test "Tab should complete"
# Try completion
set cmd "kldunload "
send "$cmd\t"
sync_after_tab
expect {
-re "^$cmd.*$" { pass "$test" }
-re /@ { unresolved "$test at prompt" }
-re eof { unresolved "eof" }
}; # expect
sleep .4
sync_after_int
teardown

View File

@ -1,35 +0,0 @@
proc setup {} {
set test setup
set cmd "touch fixture1/t.{pdf,PDF,{,e}ps,{,E}PS}"; # Create temporary files
send "$cmd\r"
expect -ex "$cmd\r\n/@"
}; # setup()
proc teardown {} {
set test teardown
set cmd "rm fixture1/t.{pdf,PDF,{,e}ps,{,E}PS}"; # Remove temporary files
send "$cmd\r"
expect -ex "$cmd\r\n/@"
}; # teardown()
setup
set test "Tab should complete kpdf"
# Try completion
set cmd "kpdf fixture1/"
send "$cmd\t"
expect {
-re "^${cmd}\r\n(\.svn/ +|)bar bar.d/ +foo.d/ +(\.svn/ +|)t.eps +t.EPS +t.pdf +t.PDF +t.ps +t.PS *\r\n/@$cmd$" { pass "$test" }
-re /@ { unresolved "$test at prompt" }
default { unresolved "$test" }
}; # expect
sleep .5
sync_after_int
teardown

View File

@ -1,26 +0,0 @@
proc setup {} {
}; # setup()
proc teardown {} {
}; # teardown()
setup
set test "Tab should complete"
# Try completion
set cmd "kplayer "
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

View File

@ -54,7 +54,6 @@ proc assert_bash_type {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"
@ -98,34 +97,6 @@ proc assert_complete {expected cmd {test ""} {prompt /@} {size 20}} {
}; # assert_complete()
# Make sure a partial argument is completed.
# A completion is tried with `$partial', or if this is empty, the first
# character of the first item of `$expected'. Only the items from $expected,
# starting with this character are then expected as completions.
# @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}} {
if {$test == ""} {set test "$cmd should complete partial argument"}
if {[llength $expected] == 0} {
unresolved "$test"
} else {
set pick {}
foreach item $expected {
if {$partial == ""} {set partial [string range $item 0 0]}
# Only append item if starting with $partial
if {[string range $item 0 [expr [string length $partial] - 1]] == "$partial"} {
lappend pick $item
}; # if
}; # foreach
assert_complete $pick "$cmd $partial" $test $prompt $size
}; # if
}; # assert_complete_partial()
# Make sure any completions are returned
proc assert_complete_any {cmd {test ""} {prompt /@}} {
if {$test == ""} {set test "$cmd should show completions"}
@ -155,6 +126,53 @@ proc assert_complete_any {cmd {test ""} {prompt /@}} {
}; # assert_complete_any()
# Make sure the expected files are returned by TAB-completing the
# specified command in the specified subdirectory.
# @param list $expected
# @param string $cmd Command given to generate items
# @param string $dir Subdirectory to attempt completion in. The directory must be relative from the $TESTDIR and without a trailing slash. E.g. `fixtures/evince'
# @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_dir {expected cmd dir {test ""} {size 20}} {
set prompt "/$dir/@"
assert_bash_exec "cd $dir" "" $prompt
assert_complete $expected $cmd $test $prompt $size
sync_after_int $prompt
assert_bash_exec "cd \$TESTDIR"
}; # assert_complete_dir
# Make sure a partial argument is completed.
# A completion is tried with `$partial', or if this is empty, the first
# character of the first item of `$expected'. Only the items from $expected,
# starting with this character are then expected as completions.
# @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}} {
if {$test == ""} {set test "$cmd should complete partial argument"}
if {[llength $expected] == 0} {
unresolved "$test"
} else {
set pick {}
foreach item $expected {
if {$partial == ""} {set partial [string range $item 0 0]}
# Only append item if starting with $partial
if {[string range $item 0 [expr [string length $partial] - 1]] == "$partial"} {
lappend pick $item
}; # if
}; # foreach
assert_complete $pick "$cmd $partial" $test $prompt $size
}; # if
}; # assert_complete_partial()
# 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.
@ -248,7 +266,7 @@ proc assert_exec {cmd {stdout ''} {test ''}} {
}; # assert_exec()
# Get known hostnames
# Get hostnames
# @return list Hostnames
proc get_hosts {} {
set hosts [exec bash -c "compgen -A hostname"]
@ -266,6 +284,25 @@ proc get_hosts {} {
}; # get_hosts()
# Get signals
# This function is written in analogy to the bash function `_signals()' in
# `bash_completion'.
# @return list Signals starting with `SIG', but with the `SIG' prefix removed.
proc get_signals {} {
set signals {}
foreach signal [exec bash -c {compgen -A signal}] {
# Does signal start with `SIG'?
if {[string range $signal 0 [expr [string length "SIG"] - 1]] == "SIG"} {
# Remove `SIG' prefix
set signal [string range $signal 3 end]
# Add signal (with dash (-) prefix) to list
lappend signals -$signal
}; # if
}; # foreach
return $signals
}; # get_signals()
# Expect items.
# Break items into chunks because `expect' seems to have a limited buffer size
# @param list $items
@ -368,7 +405,12 @@ proc sync_after_int {{prompt /@}} {
set test "Sync after INT"
sleep .1
send \031\003; # QUIT/INT
expect $prompt
# NOTE: Regexp `.*' causes `expect' to discard previous unknown output.
# This is necessary if a completion doesn't match expectations.
# For instance with `filetype_xpec' completion (e.g. `kdvi') if
# one expects `.txt' as a completion (wrong, because it isn't
# there), the unmatched completions need to be cleaned up.
expect -re ".*$prompt$"
}; # sync_after_int()