From 0c5015d4677faf8f2f983e5f8445c59bca60f3e1 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Thu, 28 Mar 2019 18:23:32 -0500 Subject: [PATCH] Correct the reversed diff output for all tests This has been driving nuts for years. The output of the diff emitted when a test fails was always reversed, because the diff tool is called with `${difftool} ${new} ${old}` so all the `-` and `+` contexts are reversed, and the highlights are all screwed up. The output of a `make test` run should show what has changed from the baseline/expected, not how the expected differs from the actual. When considered from both the perspective of intentional changes to the test outputs and failed test outputs, it is desirable to see how the test output has changed from the previously expected, and not the other way around. (If you were used to the previous behavior, I apologize. But it was wrong.) --- tests/interactive.fish | 4 ++-- tests/invocation.sh | 8 ++++---- tests/test.fish | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/interactive.fish b/tests/interactive.fish index 933749446..f6a05a12b 100644 --- a/tests/interactive.fish +++ b/tests/interactive.fish @@ -69,11 +69,11 @@ function test_file say red "fail" if test $out_status -ne 0 say yellow "Output differs for file $file. Diff follows:" - colordiff -u $file.tmp.out $file.out + colordiff -u $file.out $file.tmp.out end if test $err_status -ne 0 say yellow "Error output differs for file $file. Diff follows:" - colordiff -u $file.tmp.err $file.err + colordiff -u $file.err $file.tmp.err end if test $exit_status -ne 0 say yellow "Exit status differs for file $file." diff --git a/tests/invocation.sh b/tests/invocation.sh index 8ced43e4e..728636ca4 100755 --- a/tests/invocation.sh +++ b/tests/invocation.sh @@ -245,10 +245,10 @@ test_file() ( mv -f "${test_stderr}.new" "${test_stderr}" # Check the results - if ! diff "${test_stdout}" "${want_stdout}" >/dev/null 2>/dev/null ; then + if ! diff "${want_stdout}" "${test_stdout}" >/dev/null 2>/dev/null ; then out_status=1 fi - if ! diff "${test_stderr}" "${want_stderr}" >/dev/null 2>/dev/null ; then + if ! diff "${want_stderr}" "${test_stderr}" >/dev/null 2>/dev/null ; then err_status=1 fi @@ -264,11 +264,11 @@ test_file() ( if [ "$out_status" != '0' ] ; then say "$term_yellow" "Output differs for file $file. Diff follows:" - "$difftool" -u "${test_stdout}" "${want_stdout}" + "$difftool" -u "${want_stdout}" "${test_stdout}" fi if [ "$err_status" != '0' ] ; then say "$term_yellow" "Error output differs for file $file. Diff follows:" - "$difftool" -u "${test_stderr}" "${want_stderr}" + "$difftool" -u "${want_stderr}" "${test_stderr}" fi rc=1 fi diff --git a/tests/test.fish b/tests/test.fish index 0711e0933..62025fe0d 100644 --- a/tests/test.fish +++ b/tests/test.fish @@ -55,11 +55,11 @@ function test_file say red "fail" if test $out_status -ne 0 say yellow "Output differs for file $file. Diff follows:" - colordiff -u $base.tmp.out $base.out + colordiff -u $base.out $base.tmp.out end if test $err_status -ne 0 say yellow "Error output differs for file $file. Diff follows:" - colordiff -u $base.tmp.err $base.err + colordiff -u $base.err $base.tmp.err end if test $exit_status -ne 0 say yellow "Exit status differs for file $file."