Support reporting diffs even when colordiff is not present.

The Travis macOS test systems do not appear to have colordiff present, so any
failures would mean that no output would be shown. This may also be a
problem for the other test scripts as well, but the invocation tests are
the ones being affected here.

We change our behaviour to downgrade to the plain diff tool if colordiff is
not present.
This commit is contained in:
Charles Ferguson 2017-06-29 20:01:15 +01:00 committed by Kurtis Rader
parent b48cfbefba
commit 8d83c967d3

View file

@ -84,6 +84,15 @@ term_white="$(tput setaf 7)"
term_reset="$(tput sgr0)" term_reset="$(tput sgr0)"
# Check whether we have the 'colordiff' tool - if not, we'll revert to
# boring regular 'diff'.
if [ "$(type -t colordiff)" != '' ] ; then
difftool='colordiff'
else
difftool='diff'
fi
## ##
# Set variables to known values so that they will not affect the # Set variables to known values so that they will not affect the
# execution of the test. # execution of the test.
@ -237,11 +246,11 @@ function test_file() {
if [ "$out_status" != '0' ] ; then if [ "$out_status" != '0' ] ; then
say yellow "Output differs for file $file. Diff follows:" say yellow "Output differs for file $file. Diff follows:"
colordiff -u "${test_stdout}" "${want_stdout}" "$difftool" -u "${test_stdout}" "${want_stdout}"
fi fi
if [ "$err_status" != '0' ] ; then if [ "$err_status" != '0' ] ; then
say yellow "Error output differs for file $file. Diff follows:" say yellow "Error output differs for file $file. Diff follows:"
colordiff -u "${test_stderr}" "${want_stderr}" "$difftool" -u "${test_stderr}" "${want_stderr}"
fi fi
rc=1 rc=1
fi fi