From deef4028ecd70d5b0006b83da07d170c38efb3aa Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 31 Jan 2019 23:39:27 -0500 Subject: 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. --- tests.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tests.sh b/tests.sh index 5905d38..775a254 100755 --- a/tests.sh +++ b/tests.sh @@ -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() { -- cgit v1.2.3