(testsuite) Add -unsorted option to _get_hosts()
_known_hosts_real tests were failing after commit 81794a9: FAIL: Hosts should be put in COMPREPLY FAIL: Hosts should have username prefix and colon suffix This is because tcl's get_hosts() is now doing a unique sort, but bash _known_hosts_real() IS returning duplicates relying on bash's compgen/complete to remove the duplicates). Fixed by calling _get_hosts -unsorted.
This commit is contained in:
parent
7cd17ada11
commit
68e9a8e6eb
@ -633,10 +633,17 @@ proc get_known_hosts {{cword ''}} {
|
||||
|
||||
|
||||
# Get hostnames
|
||||
# @param list $args Options:
|
||||
# --unsorted Do not sort unique. Default is sort unique.
|
||||
# @return list Hostnames
|
||||
# @see get_known_hosts()
|
||||
proc get_hosts {} {
|
||||
set hosts [exec bash -c "compgen -A hostname | sort -u"]
|
||||
proc get_hosts {{args {}}} {
|
||||
array set arg [::cmdline::getoptions args {
|
||||
{unsorted "do not sort unique"}
|
||||
}]
|
||||
set sort "| sort -u"
|
||||
if {$arg(unsorted)} {set sort ""}
|
||||
set hosts [exec bash -c "compgen -A hostname $sort"]
|
||||
# NOTE: Circumventing var `avahi_hosts' and appending directly to `hosts'
|
||||
# causes an empty element to be inserted in `hosts'.
|
||||
# -- FVu, Fri Jul 17 23:11:46 CEST 2009
|
||||
|
@ -19,7 +19,7 @@ setup
|
||||
|
||||
|
||||
set test "Hosts should be put in COMPREPLY"
|
||||
set hosts [get_hosts]
|
||||
set hosts [get_hosts -unsorted]
|
||||
# Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config
|
||||
# doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6 test cases in ./fixtures/_known_hosts_real/known_hosts
|
||||
lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0 1111:2222:3333:4444:5555:6666:xxxx:abab 11xx:2222:3333:4444:5555:6666:xxxx:abab ::42
|
||||
@ -31,7 +31,7 @@ sync_after_int
|
||||
|
||||
|
||||
set test "Hosts should have username prefix and colon suffix"
|
||||
set hosts [get_hosts]
|
||||
set hosts [get_hosts -unsorted]
|
||||
# Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config
|
||||
# doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6 test cases in ./fixtures/_known_hosts_real/known_hosts
|
||||
lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0 1111:2222:3333:4444:5555:6666:xxxx:abab 11xx:2222:3333:4444:5555:6666:xxxx:abab ::42
|
||||
@ -49,7 +49,7 @@ sync_after_int
|
||||
|
||||
|
||||
set test "Files containing consecutive spaces should work"
|
||||
set hosts [get_hosts]
|
||||
set hosts [get_hosts -unsorted]
|
||||
set hosts_orig $hosts
|
||||
# Hosts `gee' and `hus' are defined in `./fixtures/_known_hosts_real/spaced conf'
|
||||
# Host `two' is defined in ./fixtures/_known_hosts_real/known_hosts2
|
||||
@ -77,7 +77,7 @@ sync_after_int
|
||||
|
||||
|
||||
set test "Files starting with tilde (~) should work"
|
||||
set hosts [get_hosts]
|
||||
set hosts [get_hosts -unsorted]
|
||||
# Host `two' is defined in ./fixtures/_known_hosts_real/known_hosts2
|
||||
# Host `three' is defined in ./fixtures/_known_hosts_real/known_hosts3
|
||||
lappend hosts two three
|
||||
|
Loading…
x
Reference in New Issue
Block a user