(testsuite) Moved location of making-list-unique

Moved making-expected-list-unique out of `match_items()' & `get_hosts()'
into `assert_complete()' because the former are low level functions and
items need not necessarily be unique.  They only need to be unique when
we're actually testing *completions*.
This commit is contained in:
Freddy Vulto 2009-11-25 22:31:29 +01:00
parent 8c94bf6944
commit a9717be57b
2 changed files with 7 additions and 3 deletions

View File

@ -101,7 +101,7 @@ assert_bash_exec "cd $dir" "" $prompt
set cmd "scp -F 'spaced conf' " set cmd "scp -F 'spaced conf' "
send "$cmd\t" send "$cmd\t"
expect -ex "$cmd\r\n" expect -ex "$cmd\r\n"
if {[match_items $expected $test]} { if {[match_items [lsort -unique $expected] $test]} {
expect { expect {
-re $prompt { pass "$test" } -re $prompt { pass "$test" }
-re eof { unresolved "eof" } -re eof { unresolved "eof" }

View File

@ -127,6 +127,8 @@ proc assert_complete {expected cmd {test ""} {prompt /@} {size 20} {cword ""}} {
}; # if }; # if
} else { } else {
expect -ex "$cmd\r\n" expect -ex "$cmd\r\n"
# Make sure expected items are unique
set expected [lsort -unique $expected]
}; # if }; # if
if {[match_items $expected $test]} { if {[match_items $expected $test]} {
@ -371,7 +373,7 @@ proc get_hosts {} {
if {[llength $avahi_hosts] > 0} { if {[llength $avahi_hosts] > 0} {
lappend hosts $avahi_hosts lappend hosts $avahi_hosts
}; # if }; # if
return [lsort -unique $hosts] return $hosts
}; # get_hosts() }; # get_hosts()
@ -416,7 +418,9 @@ proc get_signals {} {
# @param integer $size Chunk size # @param integer $size Chunk size
# @result boolean True if successful, False if not # @result boolean True if successful, False if not
proc match_items {items test {size 20}} { proc match_items {items test {size 20}} {
set items [exec sort | uniq << [join $items "\n"]] # NOTE: `exec sort' is used instead of `lsort' to achieve exactly the
# same sort order as in bash -- FVu, Wed Nov 25 22:25:28 CET 2009
set items [exec sort << [join $items "\n"]]
set result false set result false
for {set i 0} {$i < [llength $items]} {set i [expr {$i + $size}]} { for {set i 0} {$i < [llength $items]} {set i [expr {$i + $size}]} {
set expected "" set expected ""