* 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 <[email protected]> --- Most of the apparent changes of this patch are just a indentation change; so, for a better grasping the actual change, I copy here the results of "git diff -w", which ignores whitespace changes: diff --git a/lib/am/serial-tests.am b/lib/am/serial-tests.am index 592a796..0c31e26 100644 --- a/lib/am/serial-tests.am +++ b/lib/am/serial-tests.am @@ -44,12 +44,14 @@ check-TESTS: $(am__cooked_tests) *) return 1;; \ esac; \ }; \ - if test -n "$$list"; then \ + 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 +## Success. all=`expr $$all + 1`; \ if is_xfail_test; then \ xpass=`expr $$xpass + 1`; \ @@ -59,23 +61,28 @@ check-TESTS: $(am__cooked_tests) col=$$grn; res=PASS; \ fi; \ elif test $$? -ne 77; then \ -## Failure +## 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 \ +## Unexpected failure (FAIL). failed=`expr $$failed + 1`; \ col=$$red; res=FAIL; \ fi; \ else \ -## Skipped +## Test skipped. skip=`expr $$skip + 1`; \ col=$$blu; res=SKIP; \ fi; \ +## Report this single result on stdout. echo "$${col}$$res$${std}: $$tst"; \ done; \ -## Prepare the banner +## 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=""; \ @@ -129,5 +136,4 @@ check-TESTS: $(am__cooked_tests) test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ test -z "$$report" || echo "$${col}$$report$${std}"; \ echo "$${col}$$dashes$${std}"; \ - test "$$failed" -eq 0; \ - else :; fi + test "$$failed" -eq 0 || exit 1 lib/am/serial-tests.am | 156 +++++++++++++++++++++++++------------------------ 1 file changed, 81 insertions(+), 75 deletions(-) diff --git a/lib/am/serial-tests.am b/lib/am/serial-tests.am index 592a796..0c31e26 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 -- 1.7.12.rc0
