From 8d83c967d312327c36048a4b78061f34fabe56c6 Mon Sep 17 00:00:00 2001 From: Charles Ferguson Date: Thu, 29 Jun 2017 20:01:15 +0100 Subject: [PATCH] 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. --- tests/invocation.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/invocation.sh b/tests/invocation.sh index 69468d69e..f31445dca 100755 --- a/tests/invocation.sh +++ b/tests/invocation.sh @@ -84,6 +84,15 @@ term_white="$(tput setaf 7)" 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 # execution of the test. @@ -237,11 +246,11 @@ function test_file() { if [ "$out_status" != '0' ] ; then say yellow "Output differs for file $file. Diff follows:" - colordiff -u "${test_stdout}" "${want_stdout}" + "$difftool" -u "${test_stdout}" "${want_stdout}" fi if [ "$err_status" != '0' ] ; then say yellow "Error output differs for file $file. Diff follows:" - colordiff -u "${test_stderr}" "${want_stderr}" + "$difftool" -u "${test_stderr}" "${want_stderr}" fi rc=1 fi