Ticket #3784: extfs: add diff output to tester.

Signed-off-by: Mooffie <mooffie@gmail.com>
This commit is contained in:
Mooffie 2017-03-07 23:41:22 +02:00
parent 91b69d2652
commit 55624eae3b

View File

@ -110,11 +110,18 @@ has_prog() {
command -v "$1" >/dev/null 2>&1 command -v "$1" >/dev/null 2>&1
} }
#
# Are we running interactively? Or is our output redirected to a file/pipe?
#
is_interactive() {
[ -t 1 ]
}
# #
# Can we use colors? # Can we use colors?
# #
has_colors() { has_colors() {
[ -t 1 ] && has_string "$TERM" 'linux\|xterm\|screen\|tmux\|putty' is_interactive && has_string "$TERM" 'linux\|xterm\|screen\|tmux\|putty'
} }
init_colors() { init_colors() {
@ -329,14 +336,23 @@ run() {
err "If the actual output is the correct one, just copy the latter file" err "If the actual output is the correct one, just copy the latter file"
err "onto the former (and commit to the git repository)." err "onto the former (and commit to the git repository)."
err err
if [ $opt_run_mcdiff_on_error = "yes" ]; then if is_interactive; then
notice "Hit ENTER to launch mcdiff ..." if [ $opt_run_mcdiff_on_error = "yes" ]; then
read dummy_var # dash needs this. notice "Hit ENTER to launch mcdiff ..."
${MCDIFF:-mcdiff} "$expected_parsed_output" "$actual_parsed_output" read dummy_var # dash needs this.
${MCDIFF:-mcdiff} "$expected_parsed_output" "$actual_parsed_output"
else
notice "Tip: invoke this program with '--mcdiff' to automatically launch"
notice "mcdiff to visually inspect the diff."
notice
notice "(Running this program non-interactively (i.e., redirecting the"
notice "output to a file or pipe) automatically adds diff to the output.)"
notice
fi
else else
notice "Tip: invoke this program with '--mcdiff' to automatically launch" err "------------ diff of the expected output vs the actual output: -------------"
notice "mcdiff to visually inspect the diff." diff -U2 "$expected_parsed_output" "$actual_parsed_output"
notice err "------------------------------- end of diff --------------------------------"
fi fi
continue continue
fi fi