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
|
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 {
|
set files {
|
||||||
foo/
|
foo/
|
||||||
.bmp .BMP .cbr .CBR .cbz .CBZ .djv .DJV .djvu .DJVU
|
.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_bash_exec "cd fixtures/evince" "" $prompt
|
||||||
assert_complete $files "evince " "" $prompt
|
assert_complete $files "evince " "" $prompt
|
||||||
sync_after_int $prompt
|
sync_after_int $prompt
|
||||||
assert_bash_exec "cd ../.."
|
assert_bash_exec "cd \$TESTDIR"
|
||||||
|
|
||||||
|
|
||||||
teardown
|
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 {} {
|
proc setup {} {
|
||||||
|
save_env
|
||||||
}; # setup()
|
}; # setup()
|
||||||
|
|
||||||
|
|
||||||
proc teardown {} {
|
proc teardown {} {
|
||||||
|
assert_env_unmodified {/OLDPWD=/d}
|
||||||
}; # teardown()
|
}; # teardown()
|
||||||
|
|
||||||
|
|
||||||
setup
|
setup
|
||||||
|
|
||||||
|
|
||||||
set test "Tab should show completions"
|
assert_complete_any "find "
|
||||||
# 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
|
|
||||||
|
|
||||||
|
|
||||||
sync_after_int
|
sync_after_int
|
||||||
@ -35,39 +29,24 @@ sync_after_int
|
|||||||
|
|
||||||
|
|
||||||
set test "-wholename should complete files/dirs"
|
set test "-wholename should complete files/dirs"
|
||||||
# Change directory
|
# Change directory to `fixture1'
|
||||||
set cmd "cd fixture1"
|
set dir fixture1
|
||||||
send "$cmd\r"
|
set prompt "/$dir/@"
|
||||||
expect -ex "$cmd\r\n/fixture1/@"
|
assert_bash_exec "cd $dir" "" $prompt
|
||||||
# Complete
|
# NOTE: `-p' adds a slash to directories
|
||||||
set cmd "find -wholename "
|
set files [split [exec bash -c "cd $dir && ls -p"] "\n"]
|
||||||
send "$cmd\t"
|
assert_complete $files "find -wholename " "" $prompt
|
||||||
expect {
|
sync_after_int $prompt
|
||||||
-re "$cmd\r\n(\.svn/ +|)bar +bar bar.d/ +foo +foo.d/ *(\.svn/ *|)\r\n/fixture1/@$cmd$" {
|
assert_bash_exec "cd \$TESTDIR"
|
||||||
pass "$test"
|
|
||||||
}
|
|
||||||
-re /@ { unresolved "$test at prompt" }
|
|
||||||
-re eof { unresolved "eof" }
|
|
||||||
}; # expect
|
|
||||||
|
|
||||||
|
|
||||||
sync_after_int
|
|
||||||
|
|
||||||
|
|
||||||
# Restore directory
|
|
||||||
set cmd "cd .."
|
|
||||||
send "$cmd\r"
|
|
||||||
expect -ex "$cmd\r\n/@"
|
|
||||||
|
|
||||||
|
|
||||||
set test "-uid should complete uids"
|
set test "-uid should complete uids"
|
||||||
# Complete
|
# Complete
|
||||||
set cmd "find -uid "
|
set cmd "find -uid "
|
||||||
send "$cmd\t"
|
send "$cmd\t"
|
||||||
expect {
|
expect {
|
||||||
-re "$cmd\r\n\\d+.*/@$cmd$" {
|
-re "$cmd\r\n\\d+.*/@$cmd$" { pass "$test" }
|
||||||
pass "$test"
|
|
||||||
}
|
|
||||||
-re /@ { unresolved "$test at prompt" }
|
-re /@ { unresolved "$test at prompt" }
|
||||||
-re eof { unresolved "eof" }
|
-re eof { unresolved "eof" }
|
||||||
}; # expect
|
}; # expect
|
||||||
@ -81,9 +60,7 @@ set test "-gid should complete gids"
|
|||||||
set cmd "find -gid "
|
set cmd "find -gid "
|
||||||
send "$cmd\t"
|
send "$cmd\t"
|
||||||
expect {
|
expect {
|
||||||
-re "$cmd\r\n\\d+.*/@$cmd$" {
|
-re "$cmd\r\n\\d+.*/@$cmd$" { pass "$test" }
|
||||||
pass "$test"
|
|
||||||
}
|
|
||||||
-re /@ { unresolved "$test at prompt" }
|
-re /@ { unresolved "$test at prompt" }
|
||||||
-re eof { unresolved "eof" }
|
-re eof { unresolved "eof" }
|
||||||
}; # expect
|
}; # 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
|
# Escape special regexp characters
|
||||||
regsub -all {([\[\]\(\)\.\\\+])} $cmd {\\\1} cmd
|
regsub -all {([\[\]\(\)\.\\\+])} $cmd {\\\1} cmd
|
||||||
expect {
|
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 $prompt { unresolved "$test at prompt" }
|
||||||
-re eof { unresolved "eof" }
|
-re eof { unresolved "eof" }
|
||||||
}; # expect
|
}; # expect
|
||||||
@ -238,10 +242,16 @@ proc assert_exec {cmd {stdout ''} {test ''}} {
|
|||||||
# @return list Hostnames
|
# @return list Hostnames
|
||||||
proc get_hosts {} {
|
proc get_hosts {} {
|
||||||
set hosts [exec bash -c "compgen -A hostname"]
|
set hosts [exec bash -c "compgen -A hostname"]
|
||||||
lappend hosts [exec bash -c {
|
# NOTE: Circumenventing `avahi_host' and appending directly to `hosts'
|
||||||
type avahi-browse >&/dev/null &&
|
# causes an empty element to be inserted in `hosts'.
|
||||||
avahi-browse -kcpr _workstation._tcp | grep ^= | cut -d\; -f7 | sort -u
|
# -- 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
|
return $hosts
|
||||||
}; # get_hosts()
|
}; # get_hosts()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user