(testsuite) Fix assert_env_unmodified() & get_hosts_avahi()
assert_env_unmodified() now calls `diff_env' with `LAST-ARG' as the last argument. Now $_ becomes `LAST_ARG' and $_ doesn't interfere with the diff anymore as it would if $_ was the sed script. Added line continuation (\) to bash script of `get_hosts_avahi()'.
This commit is contained in:
parent
c6a8b856de
commit
fe88919de4
@ -225,8 +225,6 @@ proc assert_env_unmodified {{sed ""} {file ""} {diff ""}} {
|
|||||||
regsub -all {([\"\\])} $sed {\\\1} sed
|
regsub -all {([\"\\])} $sed {\\\1} sed
|
||||||
# Escape newlines
|
# Escape newlines
|
||||||
regsub -all {\n} [string trim $sed] "\r\n" sed
|
regsub -all {\n} [string trim $sed] "\r\n" sed
|
||||||
# Mark end of sed script, so that `expect' can match on that
|
|
||||||
append sed "# End of sed script"
|
|
||||||
|
|
||||||
# Prepare diff script
|
# Prepare diff script
|
||||||
|
|
||||||
@ -240,9 +238,12 @@ proc assert_env_unmodified {{sed ""} {file ""} {diff ""}} {
|
|||||||
|
|
||||||
# Execute diff
|
# Execute diff
|
||||||
|
|
||||||
set cmd "diff_env \"[gen_env_filename $file 1]\" \"[gen_env_filename $file 2]\" \"$sed\""
|
# NOTE: The dummy argument 'LAST-ARG' sets bash variable $_ (last argument) to
|
||||||
|
# 'LAST-ARG' so that $_ doesn't mess up the diff (as it would if $_
|
||||||
|
# was the (possibly multi-lined) sed script).
|
||||||
|
set cmd "diff_env \"[gen_env_filename $file 1]\" \"[gen_env_filename $file 2]\" \"$sed\" LAST-ARG"
|
||||||
send "$cmd\r"
|
send "$cmd\r"
|
||||||
expect "# End of sed script\"\r\n"
|
expect "LAST-ARG\r\n"
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
-re "^$diff[wd]@$" { pass "$test" }
|
-re "^$diff[wd]@$" { pass "$test" }
|
||||||
@ -313,7 +314,7 @@ proc get_hosts {} {
|
|||||||
proc get_hosts_avahi {} {
|
proc get_hosts_avahi {} {
|
||||||
# Retrieving hosts is successful?
|
# Retrieving hosts is successful?
|
||||||
if { [catch {exec bash -c {
|
if { [catch {exec bash -c {
|
||||||
type avahi-browse >&/dev/null && [ -n "$(pidof avahi-daemon)" ]
|
type avahi-browse >&/dev/null && [ -n "$(pidof avahi-daemon)" ] \
|
||||||
&& avahi-browse -cpr _workstation._tcp | grep ^= | cut -d\; -f7 | sort -u
|
&& avahi-browse -cpr _workstation._tcp | grep ^= | cut -d\; -f7 | sort -u
|
||||||
}} hosts] } {
|
}} hosts] } {
|
||||||
# No, retrieving hosts yields error;
|
# No, retrieving hosts yields error;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user