diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-03-03 12:50:17 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-02-16 19:47:07 -0500 |
commit | 7bc2278da024f48291bce5e24860d148478fe894 (patch) | |
tree | eed557be37c2d9a1cfa5016a3bd442aa21485bf6 /check | |
parent | 568c65f1b83007b8bb5fc456344df939e8a6c655 (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>
Diffstat (limited to 'check')
-rwxr-xr-x | check | 71 |
1 files changed, 39 insertions, 32 deletions
@@ -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 @@ -335,6 +337,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;; @@ -1046,42 +1049,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 |