mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Tweak interactive debug output
This commit is contained in:
parent
510ff6a689
commit
51c2005ea2
2 changed files with 25 additions and 5 deletions
|
@ -57,6 +57,7 @@ proc expect_prompt {args} {
|
||||||
}
|
}
|
||||||
set prompt_action ""
|
set prompt_action ""
|
||||||
set expargs {}
|
set expargs {}
|
||||||
|
set debugpats {}
|
||||||
set nounmatched no
|
set nounmatched no
|
||||||
set matchidx 0
|
set matchidx 0
|
||||||
set matched(any) no
|
set matched(any) no
|
||||||
|
@ -68,6 +69,7 @@ proc expect_prompt {args} {
|
||||||
set state "action"
|
set state "action"
|
||||||
}
|
}
|
||||||
"action" {
|
"action" {
|
||||||
|
lappend debugpats [lindex $expargs end]
|
||||||
lappend expargs [subst -nocommands {
|
lappend expargs [subst -nocommands {
|
||||||
log_debug "matched extra pattern to expect_prompt: [quote \$expect_out(0,string)]"
|
log_debug "matched extra pattern to expect_prompt: [quote \$expect_out(0,string)]"
|
||||||
if {!\$matched($matchidx)} {
|
if {!\$matched($matchidx)} {
|
||||||
|
@ -93,6 +95,7 @@ proc expect_prompt {args} {
|
||||||
-gl -
|
-gl -
|
||||||
-re -
|
-re -
|
||||||
-ex {
|
-ex {
|
||||||
|
lappend debugpats $arg
|
||||||
set state "pat"
|
set state "pat"
|
||||||
}
|
}
|
||||||
-i -
|
-i -
|
||||||
|
@ -108,7 +111,7 @@ proc expect_prompt {args} {
|
||||||
error "BUG: unknown expect flag in expect_prompt"
|
error "BUG: unknown expect flag in expect_prompt"
|
||||||
}
|
}
|
||||||
default {
|
default {
|
||||||
set state "pat"
|
set state "action"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if {$keep} {
|
if {$keep} {
|
||||||
|
@ -134,8 +137,8 @@ proc expect_prompt {args} {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if {[llength $expargs] > 0} {
|
if {[llength $debugpats] > 0} {
|
||||||
log_info "expecting prompt $prompt_counter + patterns"
|
log_info "expecting prompt $prompt_counter + \[$debugpats]"
|
||||||
} else {
|
} else {
|
||||||
log_info "expecting prompt $prompt_counter"
|
log_info "expecting prompt $prompt_counter"
|
||||||
}
|
}
|
||||||
|
@ -153,7 +156,6 @@ proc trace_expect {cmd args} {
|
||||||
switch [lindex $args end] {
|
switch [lindex $args end] {
|
||||||
enter {
|
enter {
|
||||||
log_debug "entering expect"
|
log_debug "entering expect"
|
||||||
log_debug "command: $cmd"
|
|
||||||
uplevel {set expect_out(buffer) {}}
|
uplevel {set expect_out(buffer) {}}
|
||||||
}
|
}
|
||||||
leave {
|
leave {
|
||||||
|
@ -195,6 +197,22 @@ proc trace_spawn {cmd args} {
|
||||||
}
|
}
|
||||||
eof {
|
eof {
|
||||||
log_debug "eof; buffer=[quote $expect_out(buffer)]"
|
log_debug "eof; buffer=[quote $expect_out(buffer)]"
|
||||||
|
# even though we're about to abort, we want to wait so we can get the status
|
||||||
|
# note: it's possible that fish could have closed its end and then hung, and
|
||||||
|
# expect doesn't provide any way to set a timeout for wait. But I think that's
|
||||||
|
# an acceptable risk.
|
||||||
|
puts stderr "eof; waiting on child process to exit"
|
||||||
|
set status [wait]
|
||||||
|
if {[lindex $status 2] == -1} {
|
||||||
|
# operating system error
|
||||||
|
puts stderr "error: OS error code [lindex $status 3]"
|
||||||
|
} else {
|
||||||
|
set msg "process [lindex $status 0] exited with status [lindex $status 3]"
|
||||||
|
if {[llength $status] > 4} {
|
||||||
|
append msg " ([lrange $status 4 end])"
|
||||||
|
}
|
||||||
|
puts stderr $msg
|
||||||
|
}
|
||||||
abort "eof"
|
abort "eof"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,11 @@ for i in *.expect
|
||||||
diff -u $i.tmp.err $i.err
|
diff -u $i.tmp.err $i.err
|
||||||
end
|
end
|
||||||
|
|
||||||
if test $tmp_status != (cat $i.status)
|
set -l exp_status (cat $i.status)[1]
|
||||||
|
if test $tmp_status != $exp_status
|
||||||
set res fail
|
set res fail
|
||||||
echo "Exit status differs for file $i."
|
echo "Exit status differs for file $i."
|
||||||
|
echo "Expected $exp_status, got $tmp_status."
|
||||||
end
|
end
|
||||||
|
|
||||||
if test $res = ok
|
if test $res = ok
|
||||||
|
|
Loading…
Reference in a new issue