1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 2001-2012 Free Software Foundation, Inc.
4 ## This program is free software; you can redistribute it and/or modify
5 ## it under the terms of the GNU General Public License as published by
6 ## the Free Software Foundation; either version 2, or (at your option)
9 ## This program is distributed in the hope that it will be useful,
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ## GNU General Public License for more details.
14 ## You should have received a copy of the GNU General Public License
15 ## along with this program. If not, see <http://www.gnu.org/licenses/>.
17 am__tty_colors_dummy = \
18 mgn= red= grn= lgn= blu= brg= std=; \
21 # If stdout is a non-dumb tty, use colors. If test -t is not supported,
22 # then this fails; a conservative approach. Of course do not redirect
23 # stdout here, just stderr.
25 $(am__tty_colors_dummy); \
26 test "X$(AM_COLOR_TESTS)" != Xno \
27 && test "X$$TERM" != Xdumb \
28 && { test "X$(AM_COLOR_TESTS)" = Xalways || test -t 1 2>/dev/null; } \
30 am__color_tests=yes; \
40 am__tty_colors = $(am__tty_colors_dummy)
49 ## New parallel test driver.
51 ## The first version of the code here was adapted from check.mk, which was
52 ## originally written at EPITA/LRDE, further developed at Gostai, then made
53 ## its way from GNU coreutils to end up, largely rewritten, in Automake.
54 ## The current version is an heavy rewrite of that, to allow for support
55 ## of more test metadata, and the use of custom test derivers and protocols
58 am__recheck_rx = ^[ ]*:recheck:[ ]*
59 am__global_test_result_rx = ^[ ]*:global-test-result:[ ]*
60 am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]*
62 # A command that, given a newline-separated list of test names on the
63 # standard input, print the name of the tests that are to be re-run
64 # upon "make recheck".
65 am__list_recheck_tests = $(AWK) '{ \
66 ## By default, we assume the test is to be re-run.
68 while ((rc = (getline line < ($$0 ".trs"))) != 0) \
72 ## If we've encountered an I/O error here, there are three possibilities:
74 ## [1] The '.log' file exists, but the '.trs' does not; in this case,
75 ## we "gracefully" recover by assuming the corresponding test is
76 ## to be re-run (which will re-create the missing '.trs' file).
78 ## [2] Both the '.log' and '.trs' files are missing; this means that
79 ## the corresponding test has not been run, and is thus *not* to
82 ## [3] We have encountered some corner-case problem (e.g., a '.log' or
83 ## '.trs' files somehow made unreadable, or issues with a bad NFS
84 ## connection, or whatever); we don't handle such corner cases.
86 if ((getline line2 < ($$0 ".log")) < 0) \
90 else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \
91 ## A directive explicitly specifying the test is *not* to be re-run.
96 else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \
98 ## A directive explicitly specifying the test *is* to be re-run.
101 ## else continue with the next iteration.
105 ## Don't leak open file descriptors, as this could cause serious
106 ## problems when there are many tests (yes, even on Linux).
107 close ($$0 ".trs"); \
108 close ($$0 ".log"); \
111 # A command that, given a newline-separated list of test names on the
112 # standard input, create the global log from their .trs and .log files.
113 am__create_global_log = $(AWK) ' \
114 function fatal(msg) \
116 print "fatal: making $@: " msg | "cat >&2"; \
119 function rst_section(header) \
122 len = length(header); \
123 for (i = 1; i <= len; i = i + 1) \
128 ## By default, we assume the test log is to be copied in the global log,
129 ## and that its result is simply "RUN" (i.e., we still don't know what
130 ## it outcome was, but we know that at least it has run).
131 copy_in_global_log = 1; \
132 global_test_result = "RUN"; \
133 while ((rc = (getline line < ($$0 ".trs"))) != 0) \
136 fatal("failed to read from " $$0 ".trs"); \
137 if (line ~ /$(am__global_test_result_rx)/) \
139 sub("$(am__global_test_result_rx)", "", line); \
140 sub("[ ]*$$", "", line); \
141 global_test_result = line; \
143 else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \
144 copy_in_global_log = 0; \
146 if (copy_in_global_log) \
148 rst_section(global_test_result ": " $$0); \
149 while ((rc = (getline line < ($$0 ".log"))) != 0) \
152 fatal("failed to read from " $$0 ".log"); \
157 ## Don't leak open file descriptors, as this could cause serious
158 ## problems when there are many tests (yes, even on Linux).
159 close ($$0 ".trs"); \
160 close ($$0 ".log"); \
163 # Restructured Text title.
164 am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
166 # Solaris 10 'make', and several other traditional 'make' implementations,
167 # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it
168 # by disabling -e (using the XSI extension "set +e") if it's set.
169 am__sh_e_setup = case $$- in *e*) set +e;; esac
171 # Default flags passed to test drivers.
172 am__common_driver_flags = \
173 --color-tests "$$am__color_tests" \
174 --enable-hard-errors "$$am__enable_hard_errors" \
175 --expect-failure "$$am__expect_failure"
177 # To be inserted before the command running the test. Creates the
178 # directory for the log if needed. Stores in $dir the directory
179 # containing $f, in $tst the test, in $log the log. Executes the
180 # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
181 # passes TESTS_ENVIRONMENT. Set up options for the wrapper that
182 # will run the test scripts (or their associated LOG_COMPILER, if
186 $(am__vpath_adj_setup) $(am__vpath_adj) \
188 srcdir=$(srcdir); export srcdir; \
189 am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`; \
190 test "x$$am__odir" = x. || $(MKDIR_P) "$$am__odir" || exit $$?; \
191 if test -f "./$$f"; then dir=./; \
192 elif test -f "$$f"; then dir=; \
193 else dir="$(srcdir)/"; fi; \
194 tst=$$dir$$f; log='$@'; \
195 if test -n '$(DISABLE_HARD_ERRORS)'; then \
196 am__enable_hard_errors=no; \
198 am__enable_hard_errors=yes; \
200 ## The use of $dir below is required to account for VPATH
201 ## rewriting done by Sun make.
202 case " $(XFAIL_TESTS) " in \
203 *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \
204 am__expect_failure=yes;; \
206 am__expect_failure=no;; \
208 $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
210 # A shell command to get the names of the tests scripts with any registered
211 # extension removed (i.e., equivalently, the names of the test logs, with
212 # the '.log' extension removed). The result is saved in the shell variable
213 # '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly,
214 # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)",
215 # since that might cause problem with VPATH rewrites for suffix-less tests.
216 # See also 'test-harness-vpath-rewrite.test' and 'test-trs-basic.test'.
217 am__set_TESTS_bases = \
218 bases='$(TEST_LOGS)'; \
219 bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
220 ## Trim away any extra whitespace. This has already proved useful
221 ## in avoiding weird bug on lesser make implementations. It also
222 ## works around the GNU make 3.80 bug where trailing whitespace in
223 ## "TESTS = foo.test $(empty)" causes $(TESTS_LOGS) to erroneously
224 ## expand to "foo.log .log".
227 # Recover from deleted '.trs' file; this should ensure that
228 # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create
229 # both 'foo.log' and 'foo.trs'. Break the recipe in two subshells
230 # to avoid problems with "make -n".
233 $(MAKE) $(AM_MAKEFLAGS) $<
235 $(TEST_SUITE_LOG): $(TEST_LOGS)
236 @$(am__set_TESTS_bases); \
237 ## Helper shell function, tells whether a path refers to an existing,
238 ## regular, readable file.
239 am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
240 ## We need to ensures that all the required '.trs' and '.log' files will
241 ## be present and readable. The direct dependencies of $(TEST_SUITE_LOG)
242 ## only ensure that all the '.log' files exists; they don't ensure that
243 ## the '.log' files are readable, and worse, they don't ensure that the
244 ## '.trs' files even exist.
245 redo_bases=`for i in $$bases; do \
246 am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
248 if test -n "$$redo_bases"; then \
249 ## Uh-oh, either some '.log' files were unreadable, or some '.trs' files
250 ## were missing (or unreadable). We need to re-run the corresponding
251 ## tests in order to re-create them.
252 redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
253 redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
254 if $(am__make_dryrun); then :; else \
255 ## Break "rm -f" into two calls to minimize the possibility of exceeding
256 ## command line length limits.
257 rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
260 ## Use a trick to to ensure that we don't go into an infinite recursion
261 ## in case a test log in $(TEST_LOGS) is the same as $(TEST_SUITE_LOG).
262 ## Yes, this has already happened in practice. Sigh!
263 if test -n "$$am__remaking_logs"; then \
264 echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
265 "recursion detected" >&2; \
267 am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
269 if $(am__make_dryrun); then :; else \
270 ## Sanity check: each unreadable or non-existent test result file should
271 ## has been properly remade at this point, as should the corresponding log
274 errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
275 for i in $$redo_bases; do \
276 test -f $$i.trs && test -r $$i.trs \
277 || { echo "$$errmsg $$i.trs" >&2; st=1; }; \
278 test -f $$i.log && test -r $$i.log \
279 || { echo "$$errmsg $$i.log" >&2; st=1; }; \
281 test $$st -eq 0 || exit 1; \
283 ## We need a new subshell to work portably with "make -n", since the
284 ## previous part of the recipe contained a $(MAKE) invocation.
285 @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
287 ## List of test result files.
288 results=`for b in $$bases; do echo $$b.trs; done`; \
289 test -n "$$results" || results=/dev/null; \
290 ## Prepare data for the test suite summary. These do not take into account
291 ## unreadable test results, but they'll be appropriately updated later if
293 all=` grep "^$$ws*:test-result:" $$results | wc -l`; \
294 pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \
295 fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \
296 skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \
297 xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
298 xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
299 error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
300 ## Whether the testsuite was successful or not.
301 if test `expr $$fail + $$xpass + $$error` -eq 0; then \
306 ## Make $br a line of exactly 76 '=' characters, that will be used to
307 ## enclose the testsuite summary report when displayed on the console.
308 br='==================='; br=$$br$$br$$br$$br; \
309 ## When writing the test summary to the console, we want to color a line
310 ## reporting the count of some result *only* if at least one test
311 ## experienced such a result. This function is handy in this regard.
314 if test x"$$1" = x"--maybe-color"; then \
315 maybe_colorize=yes; \
316 elif test x"$$1" = x"--no-color"; then \
319 echo "$@: invalid 'result_count' usage" >&2; exit 4; \
322 desc=$$1 count=$$2; \
323 if test $$maybe_colorize = yes && test $$count -gt 0; then \
324 color_start=$$3 color_end=$$std; \
326 color_start= color_end=; \
328 echo "$${color_start}# $$desc $$count$${color_end}"; \
330 ## A shell function that creates the testsuite summary. We need it
331 ## because we have to create *two* summaries, one for test-suite.log,
332 ## and a possibly-colorized one for console output.
333 create_testsuite_report () \
335 result_count $$1 "TOTAL:" $$all "$$brg"; \
336 result_count $$1 "PASS: " $$pass "$$grn"; \
337 result_count $$1 "SKIP: " $$skip "$$blu"; \
338 result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
339 result_count $$1 "FAIL: " $$fail "$$red"; \
340 result_count $$1 "XPASS:" $$xpass "$$red"; \
341 result_count $$1 "ERROR:" $$error "$$mgn"; \
343 ## Write "global" testsuite log.
345 echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
347 create_testsuite_report --no-color; \
349 echo ".. contents:: :depth: 2"; \
351 for b in $$bases; do echo $$b; done \
352 | $(am__create_global_log); \
353 } >$(TEST_SUITE_LOG).tmp || exit 1; \
354 mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
355 ## Emit the test summary on the console.
360 test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
362 ## Multi line coloring is problematic with "less -R", so we really need
363 ## to color each line individually.
364 echo "$${col}$$br$${std}"; \
365 echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \
366 echo "$${col}$$br$${std}"; \
367 ## This is expected to go to the console, so it might have to be colorized.
368 create_testsuite_report --maybe-color; \
369 echo "$$col$$br$$std"; \
370 if $$success; then :; else \
371 echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \
372 if test -n "$(PACKAGE_BUGREPORT)"; then \
373 echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
375 echo "$$col$$br$$std"; \
377 ## Be sure to exit with the proper exit status. The use of "exit 1" below
378 ## is required to work around a FreeBSD make bug (present only when running
379 ## in concurrent mode). See automake bug#9245:
380 ## <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9245>
381 ## and FreeBSD PR bin/159730:
382 ## <http://www.freebsd.org/cgi/query-pr.cgi?pr=159730>.
385 RECHECK_LOGS = $(TEST_LOGS)
387 ## ------------------------------------------ ##
388 ## Running all tests, or rechecking failures. ##
389 ## ------------------------------------------ ##
392 ## If we are running "make recheck", it's not the user which can decide
393 ## which tests to consider for re-execution, so we must ignore the value
394 ## of $(RECHECK_LOGS).
395 ## Here and below, we expand $(RECHECK_LOGS) only once, to avoid exceeding
396 ## line length limits.
397 @if test $@ != recheck; then \
398 list='$(RECHECK_LOGS)'; \
399 test -z "$$list" || rm -f $$list; \
401 @if test $@ != recheck; then \
402 list='$(RECHECK_LOGS:.log=.trs)'; \
403 test -z "$$list" || rm -f $$list; \
405 ## We always have to remove TEST_SUITE_LOG, to ensure its rule is run
406 ## in any case even in lazy mode: otherwise, if no test needs rerunning,
407 ## or a prior run plus reruns all happen within the same timestamp (can
408 ## happen with a prior "make TESTS=<subset>"), then we get no log output.
409 ## OTOH, this means that, in the rule for '$(TEST_SUITE_LOG)', we
410 ## cannot use '$?' to compute the set of lazily rerun tests, lest
411 ## we rely on .PHONY to work portably.
412 @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
413 @$(am__set_TESTS_bases); \
414 if test $@ = recheck; then \
415 ## If running a "make recheck", we must only consider tests that had an
416 ## unexpected outcome (FAIL or XPASS) in the earlier run.
417 bases=`for i in $$bases; do echo $$i; done \
418 | $(am__list_recheck_tests)` || exit 1; \
420 log_list=`for i in $$bases; do echo $$i.log; done`; \
421 trs_list=`for i in $$bases; do echo $$i.trs; done`; \
422 ## Remove newlines and normalize whitespace, being careful to avoid extra
423 ## whitespace in the definition of $log_list, since its value will be
424 ## passed to the recursive make invocation below through the TEST_LOGS
425 ## macro, and leading/trailing white space in a make macro definition can
426 ## be problematic. In this particular case, trailing white space is known
427 ## to have caused segmentation faults on Solaris 10 XPG4 make:
428 log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
429 ## Under "make recheck", remove the .log and .trs files associated
430 ## with the files to recheck, so that those will be rerun by the
431 ## "make test-suite.log" recursive invocation below. But use a proper
432 ## hack to avoid extra files removal when running under "make -n".
433 if test $@ != recheck || $(am__make_dryrun); then :; else \
434 test -z "$$log_list" || rm -f $$log_list; \
435 test -z "$$trs_list" || rm -f $$trs_list; \
437 $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"
439 ## Recheck must depend on $(check_SCRIPTS), $(check_PROGRAMS), etc.
440 ## It must also depend on the 'all' target. See automake bug#11252.
441 recheck: all %CHECK_DEPS%
443 AM_RECURSIVE_TARGETS += check recheck
447 else !%?PARALLEL_TESTS%
449 check-TESTS: $(TESTS)
450 @failed=0; all=0; xfail=0; xpass=0; skip=0; \
451 srcdir=$(srcdir); export srcdir; \
452 ## Make sure Solaris VPATH-expands all members of this list, even
453 ## the first and the last one; thus the spaces around $(TESTS)
456 if test -n "$$list"; then \
457 for tst in $$list; do \
458 if test -f ./$$tst; then dir=./; \
459 ## Note: Solaris 2.7 seems to expand TESTS using VPATH. That's
460 ## why we also try 'dir='.
461 elif test -f $$tst; then dir=; \
462 else dir="$(srcdir)/"; fi; \
463 if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \
465 all=`expr $$all + 1`; \
466 case " $(XFAIL_TESTS) " in \
467 *[\ \ ]$$tst[\ \ ]*) \
468 xpass=`expr $$xpass + 1`; \
469 failed=`expr $$failed + 1`; \
470 col=$$red; res=XPASS; \
473 col=$$grn; res=PASS; \
476 elif test $$? -ne 77; then \
478 all=`expr $$all + 1`; \
479 case " $(XFAIL_TESTS) " in \
480 *[\ \ ]$$tst[\ \ ]*) \
481 xfail=`expr $$xfail + 1`; \
482 col=$$lgn; res=XFAIL; \
485 failed=`expr $$failed + 1`; \
486 col=$$red; res=FAIL; \
491 skip=`expr $$skip + 1`; \
492 col=$$blu; res=SKIP; \
494 echo "$${col}$$res$${std}: $$tst"; \
496 ## Prepare the banner
497 if test "$$all" -eq 1; then \
504 if test "$$failed" -eq 0; then \
505 if test "$$xfail" -eq 0; then \
506 banner="$$All$$all $$tests passed"; \
508 if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
509 banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
512 if test "$$xpass" -eq 0; then \
513 banner="$$failed of $$all $$tests failed"; \
515 if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
516 banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
519 ## DASHES should contain the largest line of the banner.
522 if test "$$skip" -ne 0; then \
523 if test "$$skip" -eq 1; then \
524 skipped="($$skip test was not run)"; \
526 skipped="($$skip tests were not run)"; \
528 test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
529 dashes="$$skipped"; \
532 if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
533 report="Please report to $(PACKAGE_BUGREPORT)"; \
534 test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
537 dashes=`echo "$$dashes" | sed s/./=/g`; \
538 if test "$$failed" -eq 0; then \
543 ## Multi line coloring is problematic with "less -R", so we really need
544 ## to color each line individually.
545 echo "$${col}$$dashes$${std}"; \
546 echo "$${col}$$banner$${std}"; \
547 test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \
548 test -z "$$report" || echo "$${col}$$report$${std}"; \
549 echo "$${col}$$dashes$${std}"; \
550 test "$$failed" -eq 0; \
553 endif !%?PARALLEL_TESTS%