From: Stefano Lattarini Date: Sat, 28 Jul 2012 08:59:08 +0000 (+0200) Subject: [ng] serial-tests: remove one level of indentation in a recipe X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86da267360d2b32941f17ccad07204f94bbd043d;p=thirdparty%2Fautomake.git [ng] serial-tests: remove one level of indentation in a recipe * lib/am/serial-tests.am (check-TESTS): Here. And add a few comments. These changes make the already quite complicated recipe slightly easier to follow. Signed-off-by: Stefano Lattarini --- diff --git a/lib/am/serial-tests.am b/lib/am/serial-tests.am index 592a796a1..0c31e2649 100644 --- a/lib/am/serial-tests.am +++ b/lib/am/serial-tests.am @@ -44,90 +44,96 @@ check-TESTS: $(am__cooked_tests) *) return 1;; \ esac; \ }; \ - if test -n "$$list"; then \ - for tst in $$list; do \ - if test -f ./$$tst; then dir=./; \ - else dir="$(srcdir)/"; fi; \ - if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \ -## Success - all=`expr $$all + 1`; \ - if is_xfail_test; then \ - xpass=`expr $$xpass + 1`; \ - failed=`expr $$failed + 1`; \ - col=$$red; res=XPASS; \ - else \ - col=$$grn; res=PASS; \ - fi; \ - elif test $$? -ne 77; then \ -## Failure - all=`expr $$all + 1`; \ - if is_xfail_test; then \ - xfail=`expr $$xfail + 1`; \ - col=$$lgn; res=XFAIL; \ - else \ - failed=`expr $$failed + 1`; \ - col=$$red; res=FAIL; \ - fi; \ + test -n "$$list" || exit 0; \ +## Run the tests one by one in series, collecting their results. + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ +## For VPATH support. + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \ +## Success. + all=`expr $$all + 1`; \ + if is_xfail_test; then \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + col=$$red; res=XPASS; \ else \ -## Skipped - skip=`expr $$skip + 1`; \ - col=$$blu; res=SKIP; \ + col=$$grn; res=PASS; \ fi; \ - echo "$${col}$$res$${std}: $$tst"; \ - done; \ -## Prepare the banner - if test "$$all" -eq 1; then \ - tests="test"; \ - All=""; \ - else \ - tests="tests"; \ - All="All "; \ - fi; \ - if test "$$failed" -eq 0; then \ - if test "$$xfail" -eq 0; then \ - banner="$$All$$all $$tests passed"; \ + elif test $$? -ne 77; then \ +## Failure. Expected or unexpected? + all=`expr $$all + 1`; \ + if is_xfail_test; then \ +## Expected failure (XFAIL). + xfail=`expr $$xfail + 1`; \ + col=$$lgn; res=XFAIL; \ else \ - if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ - banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ +## Unexpected failure (FAIL). + failed=`expr $$failed + 1`; \ + col=$$red; res=FAIL; \ fi; \ else \ - if test "$$xpass" -eq 0; then \ - banner="$$failed of $$all $$tests failed"; \ - else \ - if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ - banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ - fi; \ +## Test skipped. + skip=`expr $$skip + 1`; \ + col=$$blu; res=SKIP; \ fi; \ -## DASHES should contain the largest line of the banner. - dashes="$$banner"; \ - skipped=""; \ - if test "$$skip" -ne 0; then \ - if test "$$skip" -eq 1; then \ - skipped="($$skip test was not run)"; \ - else \ - skipped="($$skip tests were not run)"; \ - fi; \ - test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ - dashes="$$skipped"; \ +## Report this single result on stdout. + echo "$${col}$$res$${std}: $$tst"; \ + done; \ +## Done running the tests. Will now have to display the global +## outcome, with proper formatting. +## Let's start preparing the banner. + if test "$$all" -eq 1; then \ + tests="test"; \ + All=""; \ + else \ + tests="tests"; \ + All="All "; \ + fi; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="$$All$$all $$tests passed"; \ + else \ + if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ + banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ fi; \ - report=""; \ - if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ - report="Please report to $(PACKAGE_BUGREPORT)"; \ - test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ - dashes="$$report"; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all $$tests failed"; \ + else \ + if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ + banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ fi; \ - dashes=`echo "$$dashes" | sed s/./=/g`; \ - if test "$$failed" -eq 0; then \ - col="$$grn"; \ + fi; \ +## DASHES should contain the largest line of the banner. + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + if test "$$skip" -eq 1; then \ + skipped="($$skip test was not run)"; \ else \ - col="$$red"; \ + skipped="($$skip tests were not run)"; \ fi; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + if test "$$failed" -eq 0; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + fi; \ ## Multi line coloring is problematic with "less -R", so we really need ## to color each line individually. - echo "$${col}$$dashes$${std}"; \ - echo "$${col}$$banner$${std}"; \ - test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ - test -z "$$report" || echo "$${col}$$report$${std}"; \ - echo "$${col}$$dashes$${std}"; \ - test "$$failed" -eq 0; \ - else :; fi + echo "$${col}$$dashes$${std}"; \ + echo "$${col}$$banner$${std}"; \ + test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ + test -z "$$report" || echo "$${col}$$report$${std}"; \ + echo "$${col}$$dashes$${std}"; \ + test "$$failed" -eq 0 || exit 1