summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-03-03 12:50:17 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2024-07-11 19:28:35 -0400
commitcac4cc8009094608bbfc09966aa7ecfb220d91eb (patch)
tree548d2f91029e5f9d0b15368ab7bd36fea114de10
parenta2952c2a714bbb22dad8ca25204112db8c19274f (diff)
check: Add -f: failfast mode
This adds a new flag to check which exits immediately after the first test failure, so as to leave test/scratch devices untouched and make it easier to debug rare test failures. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rwxr-xr-xcheck71
1 files changed, 39 insertions, 32 deletions
diff --git a/check b/check
index 9222cd7e..c8e492c8 100755
--- a/check
+++ b/check
@@ -13,6 +13,7 @@ sum_bad=0
bad=()
notrun=()
interrupt=true
+failfast=false
diff="diff -u"
showme=false
have_test_arg=false
@@ -76,6 +77,7 @@ check options
--exact-order run tests in the exact order specified
-i <n> iterate the test list <n> times
-I <n> iterate the test list <n> times, but stops iterating further in case of any test failure
+ -f failfast - halt after first test failure
-d dump test output to stdout
-b brief test summary
-R fmt[,fmt] generate report in formats specified. Supported formats: xunit, xunit-quiet
@@ -329,6 +331,7 @@ while [ $# -gt 0 ]; do
;;
-i) iterations=$2; shift ;;
-I) iterations=$2; istop=true; shift ;;
+ -f) failfast=true; ;;
-T) timestamp=true ;;
-d) DUMP_OUTPUT=true ;;
-b) brief_test_summary=true;;
@@ -1053,42 +1056,46 @@ function run_section()
if [ ! -f $seq.out ]; then
_dump_err "no qualified output"
tc_status="fail"
- _stash_test_status "$seqnum" "$tc_status"
- continue;
- fi
-
- # coreutils 8.16+ changed quote formats in error messages
- # from `foo' to 'foo'. Filter old versions to match the new
- # version.
- sed -i "s/\`/\'/g" $tmp.out
- if diff $seq.out $tmp.out >/dev/null 2>&1 ; then
- if [ "$tc_status" != "fail" ]; then
- echo "$seqnum `expr $stop - $start`" >>$tmp.time
- echo -n " `expr $stop - $start`s"
- fi
- echo ""
else
- _dump_err "- output mismatch (see $seqres.out.bad)"
- mv $tmp.out $seqres.out.bad
- $diff $seq.out $seqres.out.bad | {
- if test "$DIFF_LENGTH" -le 0; then
- cat
- else
- head -n "$DIFF_LENGTH"
- echo "..."
- echo "(Run '$diff $here/$seq.out $seqres.out.bad'" \
- " to see the entire diff)"
- fi; } | sed -e 's/^\(.\)/ \1/'
- tc_status="fail"
- fi
- if [ -f $seqres.hints ]; then
- if [ "$tc_status" == "fail" ]; then
- echo
- cat $seqres.hints
+ # coreutils 8.16+ changed quote formats in error messages
+ # from `foo' to 'foo'. Filter old versions to match the new
+ # version.
+ sed -i "s/\`/\'/g" $tmp.out
+ if diff $seq.out $tmp.out >/dev/null 2>&1 ; then
+ if [ "$tc_status" != "fail" ]; then
+ echo "$seqnum `expr $stop - $start`" >>$tmp.time
+ echo -n " `expr $stop - $start`s"
+ fi
+ echo ""
else
- rm -f $seqres.hints
+ _dump_err "- output mismatch (see $seqres.out.bad)"
+ mv $tmp.out $seqres.out.bad
+ $diff $seq.out $seqres.out.bad | {
+ if test "$DIFF_LENGTH" -le 0; then
+ cat
+ else
+ head -n "$DIFF_LENGTH"
+ echo "..."
+ echo "(Run '$diff $here/$seq.out $seqres.out.bad'" \
+ " to see the entire diff)"
+ fi; } | sed -e 's/^\(.\)/ \1/'
+ tc_status="fail"
+ fi
+ if [ -f $seqres.hints ]; then
+ if [ "$tc_status" == "fail" ]; then
+ echo
+ cat $seqres.hints
+ else
+ rm -f $seqres.hints
+ fi
fi
fi
+
+ if [ "$tc_status" == "fail" ] && $failfast; then
+ _dump_err "exiting after first test failure"
+ status=1
+ exit
+ fi
_stash_test_status "$seqnum" "$tc_status"
done