test: When a test fails, show diff only (save complete output to a file)
authorCarl Worth <cworth@cworth.org>
Thu, 22 Apr 2010 20:22:08 +0000 (13:22 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 22 Apr 2010 20:22:08 +0000 (13:22 -0700)
We're starting to get test output that's fairly long, so it's much
kinder to just show a diff rather than displaying the complete
expected and actual output. To allow the user to investigate things
after the fact, we save the expected and actual output to files named
test-${test_number}.expected and test-${test_number}.output .

test/notmuch-test

index c6703f0e52b42edfedb228423c8f9bca74275a8f..676b66ec76b822de914a34bd0e66bef2c6a4f35d 100755 (executable)
@@ -168,8 +168,10 @@ pass_if_equal ()
        echo "  PASS"
     else
        echo "  FAIL"
-       echo "  Expected output: $expected"
-       echo "  Actual output:   $output"
+       testname=test-$(printf "%03d" $tests)
+       echo "$expected" > $testname.expected
+       echo "$output" > $testname.output
+       diff -u $testname.expected $testname.output || true
        test_failures=$((test_failures + 1))
     fi
 }