Skip to content

Commit

Permalink
Improve printed output for failing tests
Browse files Browse the repository at this point in the history
Point the user to the ${test_name}/last_output file in the event of a failure.
Improve the output when a test fails to be more readable.
  • Loading branch information
james-stocks committed Mar 13, 2017
1 parent 82d0746 commit 8fd8198
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ test_bin() {
bundle exec metadata-json-lint $* metadata.json >last_output 2>&1
RESULT=$?
if [ $RESULT -ne $expect ]; then
fail "Failing Test (unexpected exit code) '${name}' (bin)"
fail "Failing Test '${name}' (unexpected exit code '${RESULT}' instead of '${expect}') (bin)"
echo " Note: you can examine '${name}/last_output' for any output"
else
# If the test is not expected to succeed then it should match an expected output
if [ $expect -eq $SUCCESS ]; then
Expand All @@ -44,13 +45,14 @@ test_bin() {
if grep --quiet "`cat expected`" last_output; then
echo "Successful Test '${name}' (bin)"
else
fail "Failing Test (did not get expected output) '${name}' (bin)"
echo "Expected: '`cat expected`'"
echo "Actual: '`cat last_output`'"
fail "Failing Test '${name}' (did not get expected output) (bin)"
echo " Comparing '${name}/expected' with '${name}/last_output':"
echo " Expected: '`cat expected`'"
echo " Actual: '`cat last_output`'"
fi
else
fail "Failing Test (expected output file ${name}/expected is missing) '${name}' (bin)"
echo "Actual output that needs tested: '`cat last_output`'"
fail "Failing Test '${name}' (expected output file ${name}/expected is missing) (bin)"
echo " Actual output that needs tested ('${name}/last_output'): '`cat last_output`'"
fi
fi
fi
Expand Down

0 comments on commit 8fd8198

Please sign in to comment.