[Bash-completion-devel] finger test suite failure
Freddy Vulto
f.vulto at wanadoo.nl
Sat Nov 21 09:18:03 UTC 2009
On 091120 23:18, Ville Skyttä wrote:
> I have one entry for "localhost" in my SSH known hosts files, avahi not
> running, and these in /etc/hosts, perhaps that's where the dupes come from:
> 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
> ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
That seems to be it. The list of tcl/expect hosts is assembled by
`get_hosts()' in `test/lib/library.exp'. It does a `compgen -A hostname' which
indeed returns duplicates:
$ cat /etc/hosts
127.0.0.1 localhost
::1 localhost
$ compgen -A hostname
localhost
::1
localhost
By the way, the tcl way of debugging this goes like this:
./test$ tclsh
% source lib/library.exp
% get_hosts
localhost
::1
localhost
I'll add a `unique' to both `get_hosts()' and `match_items()':
---8<-------------------------------------------------------------------
diff --git a/test/lib/library.exp b/test/lib/library.exp
index 7319793..2d09179 100644
--- a/test/lib/library.exp
+++ b/test/lib/library.exp
@@ -371,7 +371,7 @@ proc get_hosts {} {
if {[llength $avahi_hosts] > 0} {
lappend hosts $avahi_hosts
}; # if
- return $hosts
+ return [lsort -unique $hosts]
}; # get_hosts()
@@ -416,7 +416,7 @@ proc get_signals {} {
# @param integer $size Chunk size
# @result boolean True if successful, False if not
proc match_items {items test {size 20}} {
- set items [exec sort << [join $items "\n"]]
+ set items [exec sort | uniq << [join $items "\n"]]
set result false
for {set i 0} {$i < [llength $items]} {set i [expr {$i + $size}]} {
set expected ""
---8<-------------------------------------------------------------------
However, next issue is that the `finger' test is using the first host which now
happenes to be `::1' and is causing troubles. I was able to workaround this by
skipping hosts starting with `:':
---8<-------------------------------------------------------------------
diff --git a/test/lib/completions/finger.exp b/test/lib/completions/finger.exp
index 4ad21cf..bf34d82 100644
--- a/test/lib/completions/finger.exp
+++ b/test/lib/completions/finger.exp
@@ -36,13 +36,17 @@ set test "Tab should complete partial hostname"
set hosts {}
set char ""
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"} {
- # Prefix hosts with username 'test@'
- lappend hosts "test@$h"
+ # Don't use hosts starting with a colon (:)
+ if {[string range $h 0 0] != ":"} {
+ if {$char == ""} {set char [string range $h 0 0]}
+ # Only append hostname if starting with $char
+ if {[string range $h 0 0] == "$char"} {
+ # Prefix hosts with username 'test@'
+ lappend hosts "test@$h"
+ }; # if
}; # if
}; # foreach
---8<-------------------------------------------------------------------
But other tests (e.g. ssh) are now failing as well, so we'd better fix this for
real? Assuming this should happen:
$ finger test@:<TAB>
$ finger test@::1
bash-completion is failing on my machine: it's offering a list of usernames
to complete... so the testsuite has now revealed a bug in bash-completion?
Freddy Vulto
http://fvue.nl
More information about the Bash-completion-devel
mailing list