diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2019-01-31 23:39:27 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2019-01-31 23:39:27 -0500 |
commit | deef4028ecd70d5b0006b83da07d170c38efb3aa (patch) | |
tree | b2df73f4c8cd787b60df5efdd8f5fda9acac0f62 | |
parent | dbf435f4555ee3a1f2f7c929866f63dc5a48662b (diff) | |
download | bfs-deef4028ecd70d5b0006b83da07d170c38efb3aa.tar.xz |
tests: Fail if bfs fails
For tests that expect bfs to fail, the return value disambiguates
whether bfs itself failed or whether the output was unexpected.
-rwxr-xr-x | tests.sh | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -787,6 +787,11 @@ function invoke_bfs() { $BFS "$@" } +# Return value when bfs fails +EX_BFS=10 +# Return value when a difference is detected +EX_DIFF=20 + function bfs_diff() ( bfs_verbose "$@" @@ -802,9 +807,16 @@ function bfs_diff() ( fi $BFS "$@" | bfs_sort >"$ACTUAL" + local STATUS="${PIPESTATUS[0]}" if [ ! "$UPDATE" ]; then - diff -u "$EXPECTED" "$ACTUAL" + diff -u "$EXPECTED" "$ACTUAL" || return $EX_DIFF + fi + + if [ "$STATUS" -eq 0 ]; then + return 0 + else + return $EX_BFS fi ) @@ -890,7 +902,7 @@ function test_depth_error() { chmod +r scratch/foo rm -rf scratch/* - return $ret + [ $ret -eq $EX_BFS ] } function test_name() { @@ -1046,10 +1058,12 @@ function test_L_loops() { function test_L_loops_continue() { bfs_diff -L loops 2>/dev/null + [ $? -eq $EX_BFS ] } function test_X() { bfs_diff -X weirdnames 2>/dev/null + [ $? -eq $EX_BFS ] } function test_follow() { @@ -1708,7 +1722,7 @@ function test_printf_Y_error() { chmod +x scratch/foo rm -rf scratch/* - return $ret + [ $ret -eq $EX_BFS ] } function test_fstype() { |