Reviewed tests f*
This commit is contained in:
parent
55bc44b035
commit
22675a60f7
@ -1 +0,0 @@
|
||||
source "lib/completions/filesnarf.exp"
|
@ -1 +0,0 @@
|
||||
source "lib/completions/find.exp"
|
@ -1 +0,0 @@
|
||||
source "lib/completions/find_member.exp"
|
@ -1 +0,0 @@
|
||||
source "lib/completions/fmt.exp"
|
@ -1 +0,0 @@
|
||||
source "lib/completions/fold.exp"
|
3
test/completion/filesnarf.exp
Normal file
3
test/completion/filesnarf.exp
Normal file
@ -0,0 +1,3 @@
|
||||
if {[assert_bash_type {filesnarf}]} {
|
||||
source "lib/completions/filesnarf.exp"
|
||||
}; # if
|
3
test/completion/find.exp
Normal file
3
test/completion/find.exp
Normal file
@ -0,0 +1,3 @@
|
||||
if {[assert_bash_type {find}]} {
|
||||
source "lib/completions/find.exp"
|
||||
}; # if
|
3
test/completion/find_member.exp
Normal file
3
test/completion/find_member.exp
Normal file
@ -0,0 +1,3 @@
|
||||
if {[assert_bash_type {find_member}]} {
|
||||
source "lib/completions/find_member.exp"
|
||||
}; # if
|
3
test/completion/fmt.exp
Normal file
3
test/completion/fmt.exp
Normal file
@ -0,0 +1,3 @@
|
||||
if {[assert_bash_type {fmt}]} {
|
||||
source "lib/completions/fmt.exp"
|
||||
}; # if
|
3
test/completion/fold.exp
Normal file
3
test/completion/fold.exp
Normal file
@ -0,0 +1,3 @@
|
||||
if {[assert_bash_type {fold}]} {
|
||||
source "lib/completions/fold.exp"
|
||||
}; # if
|
@ -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
|
||||
|
20
test/lib/completions/filesnarf.exp
Normal file
20
test/lib/completions/filesnarf.exp
Normal file
@ -0,0 +1,20 @@
|
||||
proc setup {} {
|
||||
save_env
|
||||
}; # setup()
|
||||
|
||||
|
||||
proc teardown {} {
|
||||
assert_env_unmodified
|
||||
}; # teardown()
|
||||
|
||||
|
||||
setup
|
||||
|
||||
|
||||
assert_complete_any "filesnarf -"
|
||||
|
||||
|
||||
sync_after_int
|
||||
|
||||
|
||||
teardown
|
@ -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,39 +29,24 @@ 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
|
||||
# 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"
|
||||
|
||||
|
||||
sync_after_int
|
||||
|
||||
|
||||
# Restore directory
|
||||
set cmd "cd .."
|
||||
send "$cmd\r"
|
||||
expect -ex "$cmd\r\n/@"
|
||||
|
||||
|
||||
set test "-uid should complete uids"
|
||||
# Complete
|
||||
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
|
20
test/lib/completions/find_member.exp
Normal file
20
test/lib/completions/find_member.exp
Normal file
@ -0,0 +1,20 @@
|
||||
proc setup {} {
|
||||
save_env
|
||||
}; # setup()
|
||||
|
||||
|
||||
proc teardown {} {
|
||||
assert_env_unmodified
|
||||
}; # teardown()
|
||||
|
||||
|
||||
setup
|
||||
|
||||
|
||||
assert_complete_any "find_member -"
|
||||
|
||||
|
||||
sync_after_int
|
||||
|
||||
|
||||
teardown
|
20
test/lib/completions/fmt.exp
Normal file
20
test/lib/completions/fmt.exp
Normal file
@ -0,0 +1,20 @@
|
||||
proc setup {} {
|
||||
save_env
|
||||
}; # setup()
|
||||
|
||||
|
||||
proc teardown {} {
|
||||
assert_env_unmodified
|
||||
}; # teardown()
|
||||
|
||||
|
||||
setup
|
||||
|
||||
|
||||
assert_complete_any "fmt -"
|
||||
|
||||
|
||||
sync_after_int
|
||||
|
||||
|
||||
teardown
|
20
test/lib/completions/fold.exp
Normal file
20
test/lib/completions/fold.exp
Normal file
@ -0,0 +1,20 @@
|
||||
proc setup {} {
|
||||
save_env
|
||||
}; # setup()
|
||||
|
||||
|
||||
proc teardown {} {
|
||||
assert_env_unmodified
|
||||
}; # teardown()
|
||||
|
||||
|
||||
setup
|
||||
|
||||
|
||||
assert_complete_any "fold --"
|
||||
|
||||
|
||||
sync_after_int
|
||||
|
||||
|
||||
teardown
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user