## of more test metadata, and the use of custom test derivers and protocols
## (among them, TAP).
- # Restructured Text title and section.
+# Required to support explicit use of $(srcdir) in TESTS entries.
+# That might actually be very useful in practice, for example in usages
+# like this:
+# TESTS = $(wildcard $(srcdir)/t[0-9][0-9]*.sh)
+# Removing the '$(srcdir)' in there would cause the idiom to break in
+# VPATH builds.
+am__cooked_tests = $(patsubst $(srcdir)/%,%,$(strip $(TESTS)))
+am__cooked_xfail_tests = $(patsubst $(srcdir)/%,%,$(strip $(XFAIL_TESTS)))
+
-function fatal(msg) \
+ am__recheck_rx = ^[ ]*:recheck:[ ]*
+ am__global_test_result_rx = ^[ ]*:global-test-result:[ ]*
+ am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]*
+
+ # A command that, given a newline-separated list of test names on the
+ # standard input, print the name of the tests that are to be re-run
+ # upon "make recheck".
+ am__list_recheck_tests = $(AWK) '{ \
+ ## By default, we assume the test is to be re-run.
+ recheck = 1; \
+ while ((rc = (getline line < ($$0 ".trs"))) != 0) \
+ { \
+ if (rc < 0) \
+ { \
+ ## If we've encountered an I/O error here, there are three possibilities:
+ ##
+ ## [1] The '.log' file exists, but the '.trs' does not; in this case,
+ ## we "gracefully" recover by assuming the corresponding test is
+ ## to be re-run (which will re-create the missing '.trs' file).
+ ##
+ ## [2] Both the '.log' and '.trs' files are missing; this means that
+ ## the corresponding test has not been run, and is thus *not* to
+ ## be re-run.
+ ##
+ ## [3] We have encountered some corner-case problem (e.g., a '.log' or
+ ## '.trs' files somehow made unreadable, or issues with a bad NFS
+ ## connection, or whatever); we don't handle such corner cases.
+ ##
+ if ((getline line2 < ($$0 ".log")) < 0) \
+ recheck = 0; \
+ break; \
+ } \
+ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \
+ ## A directive explicitly specifying the test is *not* to be re-run.
+ { \
+ recheck = 0; \
+ break; \
+ } \
+ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \
+ { \
+ ## A directive explicitly specifying the test *is* to be re-run.
+ break; \
+ } \
+ ## else continue with the next iteration.
+ }; \
+ if (recheck) \
+ print $$0; \
+ ## Don't leak open file descriptors, as this could cause serious
+ ## problems when there are many tests (yes, even on Linux).
+ close ($$0 ".trs"); \
+ close ($$0 ".log"); \
+ }'
+
+ # A command that, given a newline-separated list of test names on the
+ # standard input, create the global log from their .trs and .log files.
+ am__create_global_log = $(AWK) ' \
- print "fatal: making $@: " msg | "cat >&2"; \
- exit 1; \
++## Don't leak open file descriptors, as this could cause serious
++## problems when there are many tests (yes, even on Linux).
++function close_current() \
+ { \
- fatal("failed to read from " $$0 ".trs"); \
++ close ($$0 ".trs"); \
++ close ($$0 ".log"); \
++} \
++function error(msg) \
++{ \
++ print msg | "cat >&2"; \
++ exit_status = 1; \
++} \
++function input_error(file) \
++{ \
++ error("awk" ": cannot read \"" file "\""); \
++ close_current(); \
++ next; \
+ } \
+ function rst_section(header) \
+ { \
+ print header; \
+ len = length(header); \
+ for (i = 1; i <= len; i = i + 1) \
+ printf "="; \
+ printf "\n\n"; \
+ } \
++BEGIN { exit_status = 0; } \
+ { \
+ ## By default, we assume the test log is to be copied in the global log,
+ ## and that its result is simply "RUN" (i.e., we still don't know what
+ ## it outcome was, but we know that at least it has run).
+ copy_in_global_log = 1; \
+ global_test_result = "RUN"; \
+ while ((rc = (getline line < ($$0 ".trs"))) != 0) \
+ { \
+ if (rc < 0) \
- fatal("failed to read from " $$0 ".log"); \
++ input_error($$0 ".trs"); \
+ if (line ~ /$(am__global_test_result_rx)/) \
+ { \
+ sub("$(am__global_test_result_rx)", "", line); \
+ sub("[ ]*$$", "", line); \
+ global_test_result = line; \
+ } \
+ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \
+ copy_in_global_log = 0; \
+ }; \
+ if (copy_in_global_log) \
+ { \
+ rst_section(global_test_result ": " $$0); \
+ while ((rc = (getline line < ($$0 ".log"))) != 0) \
+ { \
+ if (rc < 0) \
-## Don't leak open file descriptors, as this could cause serious
-## problems when there are many tests (yes, even on Linux).
- close ($$0 ".trs"); \
- close ($$0 ".log"); \
++ input_error($$0 ".log"); \
+ print line; \
+ }; \
+ }; \
++ close_current(); \
++} \
++END { \
++ if (exit_status != 0) \
++ error("fatal: making $@: I/O error reading test results"); \
++ exit(exit_status); \
+ }'
+
+ # Restructured Text title.
am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
- am__rst_section = { sed 'p;s/./=/g;' && echo; }
# Solaris 10 'make', and several other traditional 'make' implementations,
# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it
echo; \
echo ".. contents:: :depth: 2"; \
echo; \
- bases='$(am__TEST_BASES)'; for i in $$bases; do \
- ## FIXME: one fork per test -- this is horrendously inefficient!
- if grep "^$$ws*:copy-in-global-log:$$ws*no$$ws*$$" $$i.trs \
- >/dev/null; then continue; \
- fi; \
- ## Get the declared "global result" of the test.
- ## FIXME: yet another one fork per test here!
- glob_res=`sed -n -e "s/$$ws*$$//" \
- -e "s/^$$ws*:global-test-result:$$ws*//p" \
- $$i.trs`; \
- ## If no global result is explicitly declared, we'll merely mark the
- ## test as "RUN" in the global test log.
- test -n "$$glob_res" || glob_res=RUN; \
- ## Write the name and result of the test as an RST section title.
- echo "$$glob_res: $$i" | $(am__rst_section); \
- ## Register any failure in reading test logs, to report an error later.
- cat $$i.log || st=1; \
- echo; \
- done; \
- test $$st -eq 0; \
- } >$(TEST_SUITE_LOG).tmp; then \
- mv -f $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
- else \
- rm -f $(TEST_SUITE_LOG).tmp; \
- fatal "I/O error reading test logs"; \
- fi; \
++ bases='$(am__TEST_BASES)'; \
+ for b in $$bases; do echo $$b; done \
+ | $(am__create_global_log); \
- } >$(TEST_SUITE_LOG).tmp || exit 1; \
- mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
++ } >$(TEST_SUITE_LOG).tmp; then \
++ mv -f $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
++ else \
++## The awk program in $(am__create_global_log) should have already emitted
++## a proper error message about I/O error, no need to repeat it.
++ rm -f $(TEST_SUITE_LOG).tmp; exit 1; \
++ fi; \
## Emit the test summary on the console.
if $$success; then \
col="$$grn"; \
## cannot use '$?' to compute the set of lazily rerun tests, lest
## we rely on .PHONY to work portably.
@test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
- @ws='[ ]'; \
- log_list='' trs_list=''; bases='$(am__TEST_BASES)'; \
- for i in $$bases; do \
- @$(am__set_TESTS_bases); \
++ @bases='$(am__TEST_BASES)'; \
+ if test $@ = recheck; then \
## If running a "make recheck", we must only consider tests that had an
- ## unexpected outcome (FAIL or XPASS) in the earlier run. In particular,
- ## skip tests that haven't been run. But recover gracefully from deleted
- ## '.trs' files.
- if test $@ = recheck; then \
- test -f $$i.trs || test -f $$i.log || continue; \
- ## FIXME: one fork per test -- this is horrendously inefficient!
- grep "^$$ws*:recheck:$$ws*no$$ws*$$" $$i.trs \
- >/dev/null 2>&1 && continue; \
- else :; fi; \
- log_list="$$log_list $$i.log"; \
- trs_list="$$trs_list $$i.trs"; \
- done; \
+ ## unexpected outcome (FAIL or XPASS) in the earlier run.
+ bases=`for i in $$bases; do echo $$i; done \
+ | $(am__list_recheck_tests)` || exit 1; \
+ fi; \
+ log_list=`for i in $$bases; do echo $$i.log; done`; \
+ trs_list=`for i in $$bases; do echo $$i.trs; done`; \
-## Remove newlines and normalize whitespace, being careful to avoid extra
-## whitespace in the definition of $log_list, since its value will be
-## passed to the recursive make invocation below through the TEST_LOGS
-## macro, and leading/trailing white space in a make macro definition can
-## be problematic. In this particular case, trailing white space is known
-## to have caused segmentation faults on Solaris 10 XPG4 make:
++## Remove newlines and normalize whitespace.
+ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
## Under "make recheck", remove the .log and .trs files associated
## with the files to recheck, so that those will be rerun by the
## "make test-suite.log" recursive invocation below. But use a proper
# Some simple checks, and then ordinary check. These are only really
# guaranteed to work on my machine.
syntax_check_rules = \
+ $(sc_tests_plain_check_rules) \
sc_test_names \
sc_diff_automake_in_automake \
-sc_diff_aclocal_in_automake \
+sc_diff_aclocal_in_aclocal \
sc_perl_syntax \
sc_no_brace_variable_expansions \
sc_rm_minus_f \
sc_perl_at_uscore_in_scalar_context \
sc_perl_local \
sc_AMDEP_TRUE_in_automake_in \
-sc_tests_make_without_am_makeflags \
+sc_tests_no_gmake_requirement \
+sc_tests_no_gmake_checking \
+sc_tests_make_can_chain_suffix_rules \
+sc_tests_make_dont_do_useless_vpath_rebuilds \
+sc_no_dotmake_target \
+sc_no_am_makeflags \
+sc_tests_no_make_e \
+sc_docs_no_make_e \
+sc_make_simple_include \
+sc_tests_make_simple_include \
sc_tests_obsolete_variables \
- sc_tests_plain_make \
- sc_tests_plain_autoconf \
- sc_tests_plain_autoupdate \
- sc_tests_plain_automake \
- sc_tests_plain_autom4te \
- sc_tests_plain_autoheader \
- sc_tests_plain_autoreconf \
sc_tests_here_document_format \
sc_tests_Exit_not_exit \
sc_tests_automake_fails \
- sc_tests_plain_aclocal \
- sc_tests_plain_perl \
sc_tests_required_after_defs \
-sc_tests_overriding_macros_on_cmdline \
sc_tests_plain_sleep \
- sc_tests_plain_egrep_fgrep \
+ sc_m4_am_plain_egrep_fgrep \
sc_tests_no_configure_in \
sc_tests_PATH_SEPARATOR \
sc_tests_logs_duplicate_prefixes \
echo 'Unescaped @.' 1>&2; \
exit 1; \
fi
-
-## Check that the list of tests given in the Makefile is equal to the
-## list of all test scripts in the Automake testsuite.
-maintainer-check: maintainer-check-list-of-tests
+
+ $(syntax_check_rules): automake aclocal
+ maintainer-check: $(syntax_check_rules)
+ .PHONY: maintainer-check $(syntax_check_rules)
./configure
-for files in \
- 'foo.log bar.log' \
- 'foo.trs bar.trs' \
- 'foo.trs bar.log' \
- 'foo.log bar.trs' \
-; do
+doit ()
+{
+ rm -f $*
$MAKE check
rm -f test-suite.log
- chmod a-r $files
- $MAKE test-suite.log || { ls -l; Exit 1; }
- ls -l
- grep '^foofoofoo$' foo.log
- grep '^:test-result: PASS' foo.trs
- grep '^barbarbar$' bar.log
- grep '^:test-result: SKIP' bar.trs
- grep '^SKIP: bar' test-suite.log
- grep '^barbarbar$' test-suite.log
- $EGREP ':.*foo|foofoofoo' test-suite.log && Exit 1
- : For shells with busted 'set -e'.
+ chmod a-r $*
+ $MAKE test-suite.log 2>stderr && { cat stderr >&2; Exit 1; }
+ cat stderr >&2
+}
+
+could_not_read ()
+{
+ # We have to settle for weak checks to avoid spurious failures due to
+ # the differences in error massages on different systems; for example:
+ #
+ # $ cat unreadable-file # GNU/Linux or NetBSD
+ # cat: unreadable-file: Permission denied
+ # $ cat unreadable-file # Solaris 10
+ # cat: cannot open unreadable
+ #
+ # $ grep foo unreadable-file # GNU/Linux and NetBSD
+ # grep: unreadable: Permission denied
+ # $ grep foo unreadable-file # Solaris 10
+ # grep: can't open "unreadable"
+ #
++ # Plus, we must cater to error messages displayed by our own awk
++ # script: "cannot read "unreadable"".
++ #
+ # FIXME: this might still needs adjustments on other systems ...
+ #
+ grep "$1:.*[pP]ermission denied" stderr \
- || $EGREP "can(no|')t open [\"'\`]?$1" stderr
++ || $EGREP "can(no|')t (open|read) [\"'\`]?$1" stderr
+}
+
+for lst in bar.log 'foo.log bar.log'; do
+ doit $lst
+ could_not_read bar.log
- grep 'test-suite\.log:.* I/O error reading test logs' stderr
++ grep 'test-suite\.log:.* I/O error reading test results' stderr
done
+doit foo.trs
+could_not_read foo.trs
+grep 'test-suite\.log:.* I/O error reading test results' stderr
+
+doit foo.trs bar.trs
+could_not_read foo.trs
+could_not_read bar.trs
+grep 'test-suite\.log:.* I/O error reading test results' stderr
+
+doit foo.trs bar.log
+could_not_read foo.trs
+grep 'test-suite\.log:.* I/O error reading test results' stderr
+
: