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=; \
22 $(am__tty_colors_dummy); \
23 if test "X$(AM_COLOR_TESTS)" = Xno; then \
25 elif test "X$(AM_COLOR_TESTS)" = Xalways; then \
26 am__color_tests=yes; \
27 ## If stdout is a non-dumb tty, use colors. If test -t is not supported,
28 ## then this check fails; a conservative approach. Of course do not
29 ## redirect stdout here, just stderr.
30 elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \
31 am__color_tests=yes; \
33 if test $$am__color_tests = yes; then \
44 am__tty_colors = $(am__tty_colors_dummy)
53 ## New parallel test driver.
55 ## The first version of the code here was adapted from check.mk, which was
56 ## originally written at EPITA/LRDE, further developed at Gostai, then made
57 ## its way from GNU coreutils to end up, largely rewritten, in Automake.
58 ## The current version is an heavy rewrite of that, to allow for support
59 ## of more test metadata, and the use of custom test drivers and protocols
62 am__recheck_rx = ^[ ]*:recheck:[ ]*
63 am__global_test_result_rx = ^[ ]*:global-test-result:[ ]*
64 am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]*
66 # A command that, given a newline-separated list of test names on the
67 # standard input, print the name of the tests that are to be re-run
68 # upon "make recheck".
69 am__list_recheck_tests = $(AWK) '{ \
70 ## By default, we assume the test is to be re-run.
72 while ((rc = (getline line < ($$0 ".trs"))) != 0) \
76 ## If we've encountered an I/O error here, there are three possibilities:
78 ## [1] The '.log' file exists, but the '.trs' does not; in this case,
79 ## we "gracefully" recover by assuming the corresponding test is
80 ## to be re-run (which will re-create the missing '.trs' file).
82 ## [2] Both the '.log' and '.trs' files are missing; this means that
83 ## the corresponding test has not been run, and is thus *not* to
86 ## [3] We have encountered some corner-case problem (e.g., a '.log' or
87 ## '.trs' files somehow made unreadable, or issues with a bad NFS
88 ## connection, or whatever); we don't handle such corner cases.
90 if ((getline line2 < ($$0 ".log")) < 0) \
94 else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \
95 ## A directive explicitly specifying the test is *not* to be re-run.
100 else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \
102 ## A directive explicitly specifying the test *is* to be re-run.
105 ## else continue with the next iteration.
109 ## Don't leak open file descriptors, as this could cause serious
110 ## problems when there are many tests (yes, even on Linux).
111 close ($$0 ".trs"); \
112 close ($$0 ".log"); \
115 # A command that, given a newline-separated list of test names on the
116 # standard input, create the global log from their .trs and .log files.
117 am__create_global_log = $(AWK) ' \
118 function fatal(msg) \
120 print "fatal: making $@: " msg | "cat >&2"; \
123 function rst_section(header) \
126 len = length(header); \
127 for (i = 1; i <= len; i = i + 1) \
132 ## By default, we assume the test log is to be copied in the global log,
133 ## and that its result is simply "RUN" (i.e., we still don't know what
134 ## it outcome was, but we know that at least it has run).
135 copy_in_global_log = 1; \
136 global_test_result = "RUN"; \
137 while ((rc = (getline line < ($$0 ".trs"))) != 0) \
140 fatal("failed to read from " $$0 ".trs"); \
141 if (line ~ /$(am__global_test_result_rx)/) \
143 sub("$(am__global_test_result_rx)", "", line); \
144 sub("[ ]*$$", "", line); \
145 global_test_result = line; \
147 else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \
148 copy_in_global_log = 0; \
150 if (copy_in_global_log) \
152 rst_section(global_test_result ": " $$0); \
153 while ((rc = (getline line < ($$0 ".log"))) != 0) \
156 fatal("failed to read from " $$0 ".log"); \
161 ## Don't leak open file descriptors, as this could cause serious
162 ## problems when there are many tests (yes, even on Linux).
163 close ($$0 ".trs"); \
164 close ($$0 ".log"); \
167 # Restructured Text title.
168 am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
170 # Solaris 10 'make', and several other traditional 'make' implementations,
171 # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it
172 # by disabling -e (using the XSI extension "set +e") if it's set.
173 am__sh_e_setup = case $$- in *e*) set +e;; esac
175 # Default flags passed to test drivers.
176 am__common_driver_flags = \
177 --color-tests "$$am__color_tests" \
178 --enable-hard-errors "$$am__enable_hard_errors" \
179 --expect-failure "$$am__expect_failure"
181 # To be inserted before the command running the test. Creates the
182 # directory for the log if needed. Stores in $dir the directory
183 # containing $f, in $tst the test, in $log the log. Executes the
184 # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
185 # passes TESTS_ENVIRONMENT. Set up options for the wrapper that
186 # will run the test scripts (or their associated LOG_COMPILER, if
190 $(am__vpath_adj_setup) $(am__vpath_adj) \
192 srcdir=$(srcdir); export srcdir; \
194 */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \
197 test "x$$am__odir" = x"." || test -d "$$am__odir" \
198 || $(MKDIR_P) "$$am__odir" || exit $$?; \
199 if test -f "./$$f"; then dir=./; \
200 elif test -f "$$f"; then dir=; \
201 else dir="$(srcdir)/"; fi; \
202 tst=$$dir$$f; log='$@'; \
203 if test -n '$(DISABLE_HARD_ERRORS)'; then \
204 am__enable_hard_errors=no; \
206 am__enable_hard_errors=yes; \
208 ## The use of $dir below is required to account for VPATH
209 ## rewriting done by Sun make.
210 case " $(XFAIL_TESTS) " in \
211 *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \
212 am__expect_failure=yes;; \
214 am__expect_failure=no;; \
216 $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
218 # A shell command to get the names of the tests scripts with any registered
219 # extension removed (i.e., equivalently, the names of the test logs, with
220 # the '.log' extension removed). The result is saved in the shell variable
221 # '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly,
222 # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)",
223 # since that might cause problem with VPATH rewrites for suffix-less tests.
224 # See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'.
225 am__set_TESTS_bases = \
226 bases='$(TEST_LOGS)'; \
227 bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
228 ## Trim away any extra whitespace. This has already proved useful
229 ## in avoiding weird bug on lesser make implementations. It also
230 ## works around the GNU make 3.80 bug where trailing whitespace in
231 ## "TESTS = foo.test $(empty)" causes $(TESTS_LOGS) to erroneously
232 ## expand to "foo.log .log".
235 # Recover from deleted '.trs' file; this should ensure that
236 # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create
237 # both 'foo.log' and 'foo.trs'. Break the recipe in two subshells
238 # to avoid problems with "make -n".
241 $(MAKE) $(AM_MAKEFLAGS) $<
243 # Leading 'am--fnord' is there to ensure the list of targets does not
244 # exand to empty, as could happen e.g. with make check TESTS=''.
245 am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck)
249 $(TEST_SUITE_LOG): $(TEST_LOGS)
250 @$(am__set_TESTS_bases); \
251 ## Helper shell function, tells whether a path refers to an existing,
252 ## regular, readable file.
253 am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
254 ## We need to ensures that all the required '.trs' and '.log' files will
255 ## be present and readable. The direct dependencies of $(TEST_SUITE_LOG)
256 ## only ensure that all the '.log' files exists; they don't ensure that
257 ## the '.log' files are readable, and worse, they don't ensure that the
258 ## '.trs' files even exist.
259 redo_bases=`for i in $$bases; do \
260 am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
262 if test -n "$$redo_bases"; then \
263 ## Uh-oh, either some '.log' files were unreadable, or some '.trs' files
264 ## were missing (or unreadable). We need to re-run the corresponding
265 ## tests in order to re-create them.
266 redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
267 redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
268 if $(am__make_dryrun); then :; else \
269 ## Break "rm -f" into two calls to minimize the possibility of exceeding
270 ## command line length limits.
271 rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
274 ## Use a trick to to ensure that we don't go into an infinite recursion
275 ## in case a test log in $(TEST_LOGS) is the same as $(TEST_SUITE_LOG).
276 ## Yes, this has already happened in practice. Sigh!
277 if test -n "$$am__remaking_logs"; then \
278 echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
279 "recursion detected" >&2; \
281 am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
283 if $(am__make_dryrun); then :; else \
284 ## Sanity check: each unreadable or non-existent test result file should
285 ## has been properly remade at this point, as should the corresponding log
288 errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
289 for i in $$redo_bases; do \
290 test -f $$i.trs && test -r $$i.trs \
291 || { echo "$$errmsg $$i.trs" >&2; st=1; }; \
292 test -f $$i.log && test -r $$i.log \
293 || { echo "$$errmsg $$i.log" >&2; st=1; }; \
295 test $$st -eq 0 || exit 1; \
297 ## We need a new subshell to work portably with "make -n", since the
298 ## previous part of the recipe contained a $(MAKE) invocation.
299 @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
301 ## List of test result files.
302 results=`for b in $$bases; do echo $$b.trs; done`; \
303 test -n "$$results" || results=/dev/null; \
304 ## Prepare data for the test suite summary. These do not take into account
305 ## unreadable test results, but they'll be appropriately updated later if
307 all=` grep "^$$ws*:test-result:" $$results | wc -l`; \
308 pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \
309 fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \
310 skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \
311 xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
312 xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
313 error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
314 ## Whether the testsuite was successful or not.
315 if test `expr $$fail + $$xpass + $$error` -eq 0; then \
320 ## Make $br a line of exactly 76 '=' characters, that will be used to
321 ## enclose the testsuite summary report when displayed on the console.
322 br='==================='; br=$$br$$br$$br$$br; \
323 ## When writing the test summary to the console, we want to color a line
324 ## reporting the count of some result *only* if at least one test
325 ## experienced such a result. This function is handy in this regard.
328 if test x"$$1" = x"--maybe-color"; then \
329 maybe_colorize=yes; \
330 elif test x"$$1" = x"--no-color"; then \
333 echo "$@: invalid 'result_count' usage" >&2; exit 4; \
336 desc=$$1 count=$$2; \
337 if test $$maybe_colorize = yes && test $$count -gt 0; then \
338 color_start=$$3 color_end=$$std; \
340 color_start= color_end=; \
342 echo "$${color_start}# $$desc $$count$${color_end}"; \
344 ## A shell function that creates the testsuite summary. We need it
345 ## because we have to create *two* summaries, one for test-suite.log,
346 ## and a possibly-colorized one for console output.
347 create_testsuite_report () \
349 result_count $$1 "TOTAL:" $$all "$$brg"; \
350 result_count $$1 "PASS: " $$pass "$$grn"; \
351 result_count $$1 "SKIP: " $$skip "$$blu"; \
352 result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
353 result_count $$1 "FAIL: " $$fail "$$red"; \
354 result_count $$1 "XPASS:" $$xpass "$$red"; \
355 result_count $$1 "ERROR:" $$error "$$mgn"; \
357 ## Write "global" testsuite log.
359 echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
361 create_testsuite_report --no-color; \
363 echo ".. contents:: :depth: 2"; \
365 for b in $$bases; do echo $$b; done \
366 | $(am__create_global_log); \
367 } >$(TEST_SUITE_LOG).tmp || exit 1; \
368 mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
369 ## Emit the test summary on the console.
374 test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
376 ## Multi line coloring is problematic with "less -R", so we really need
377 ## to color each line individually.
378 echo "$${col}$$br$${std}"; \
379 echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \
380 echo "$${col}$$br$${std}"; \
381 ## This is expected to go to the console, so it might have to be colorized.
382 create_testsuite_report --maybe-color; \
383 echo "$$col$$br$$std"; \
384 if $$success; then :; else \
385 echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \
386 if test -n "$(PACKAGE_BUGREPORT)"; then \
387 echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
389 echo "$$col$$br$$std"; \
391 ## Be sure to exit with the proper exit status. The use of "exit 1" below
392 ## is required to work around a FreeBSD make bug (present only when running
393 ## in concurrent mode). See automake bug#9245:
394 ## <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9245>
395 ## and FreeBSD PR bin/159730:
396 ## <http://www.freebsd.org/cgi/query-pr.cgi?pr=159730>.
399 RECHECK_LOGS = $(TEST_LOGS)
401 ## ------------------------------------------ ##
402 ## Running all tests, or rechecking failures. ##
403 ## ------------------------------------------ ##
406 @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
407 @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
408 ## We always have to remove $(TEST_SUITE_LOG), to ensure its rule is run
409 ## in any case even in lazy mode: otherwise, if no test needs rerunning,
410 ## or a prior run plus reruns all happen within the same timestamp (can
411 ## happen with a prior "make TESTS=<subset>"), then we get no log output.
412 ## OTOH, this means that, in the rule for '$(TEST_SUITE_LOG)', we
413 ## cannot use '$?' to compute the set of lazily rerun tests, lest
414 ## we rely on .PHONY to work portably.
415 @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
416 @set +e; $(am__set_TESTS_bases); \
417 log_list=`for i in $$bases; do echo $$i.log; done`; \
418 trs_list=`for i in $$bases; do echo $$i.trs; done`; \
419 ## Remove newlines and normalize whitespace. Trailing (and possibly
420 ## leading) whitespace is known to cause segmentation faults on
421 ## Solaris 10 XPG4 make.
422 log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
423 $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \
424 ## Be sure to exit with the proper exit status (automake bug#9245). See
425 ## comments in the recipe of $(TEST_SUITE_LOG) above for more information.
428 ## Recheck must depend on $(check_SCRIPTS), $(check_PROGRAMS), etc.
429 ## It must also depend on the 'all' target. See automake bug#11252.
430 recheck: all %CHECK_DEPS%
431 ## See comments above in the check-TESTS recipe for why remove
432 ## $(TEST_SUITE_LOG) here.
433 @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
434 @set +e; $(am__set_TESTS_bases); \
435 ## We must only consider tests that had an unexpected outcome (FAIL
436 ## or XPASS) in the earlier run.
437 bases=`for i in $$bases; do echo $$i; done \
438 | $(am__list_recheck_tests)` || exit 1; \
439 log_list=`for i in $$bases; do echo $$i.log; done`; \
440 ## Remove newlines and normalize whitespace. Trailing (and possibly
441 ## leading) whitespace is known to cause segmentation faults on
442 ## Solaris 10 XPG4 make.
443 log_list=`echo $$log_list`; \
444 ## Move the '.log' and '.trs' files associated with the tests to be
445 ## re-run out of the way, so that those tests will be re-run by the
446 ## "make test-suite.log" recursive invocation below.
447 ## Two tricky requirements:
448 ## - we must avoid extra files removal when running under "make -n";
449 ## - in case the test is a compiled program whose compilation fails,
450 ## we must ensure that any '.log' and '.trs' file referring to such
451 ## test are preserved, so that future "make recheck" invocations
452 ## will still try to re-compile and re-run it (automake bug#11791).
453 ## The tricky recursive make invocation below should cater to such
455 $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \
456 am__force_recheck=am--force-recheck \
457 TEST_LOGS="$$log_list"; \
458 ## Be sure to exit with the proper exit status (automake bug#9245). See
459 ## comments in the recipe of $(TEST_SUITE_LOG) above for more information.
462 AM_RECURSIVE_TARGETS += check recheck
466 else !%?PARALLEL_TESTS%
468 check-TESTS: $(TESTS)
469 @failed=0; all=0; xfail=0; xpass=0; skip=0; \
470 srcdir=$(srcdir); export srcdir; \
471 ## Make sure Solaris VPATH-expands all members of this list, even
472 ## the first and the last one; thus the spaces around $(TESTS)
475 if test -n "$$list"; then \
476 for tst in $$list; do \
477 if test -f ./$$tst; then dir=./; \
478 ## Note: Solaris 2.7 seems to expand TESTS using VPATH. That's
479 ## why we also try 'dir='.
480 elif test -f $$tst; then dir=; \
481 else dir="$(srcdir)/"; fi; \
482 if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \
484 all=`expr $$all + 1`; \
485 case " $(XFAIL_TESTS) " in \
486 *[\ \ ]$$tst[\ \ ]*) \
487 xpass=`expr $$xpass + 1`; \
488 failed=`expr $$failed + 1`; \
489 col=$$red; res=XPASS; \
492 col=$$grn; res=PASS; \
495 elif test $$? -ne 77; then \
497 all=`expr $$all + 1`; \
498 case " $(XFAIL_TESTS) " in \
499 *[\ \ ]$$tst[\ \ ]*) \
500 xfail=`expr $$xfail + 1`; \
501 col=$$lgn; res=XFAIL; \
504 failed=`expr $$failed + 1`; \
505 col=$$red; res=FAIL; \
510 skip=`expr $$skip + 1`; \
511 col=$$blu; res=SKIP; \
513 echo "$${col}$$res$${std}: $$tst"; \
515 ## Prepare the banner
516 if test "$$all" -eq 1; then \
523 if test "$$failed" -eq 0; then \
524 if test "$$xfail" -eq 0; then \
525 banner="$$All$$all $$tests passed"; \
527 if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
528 banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
531 if test "$$xpass" -eq 0; then \
532 banner="$$failed of $$all $$tests failed"; \
534 if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
535 banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
538 ## DASHES should contain the largest line of the banner.
541 if test "$$skip" -ne 0; then \
542 if test "$$skip" -eq 1; then \
543 skipped="($$skip test was not run)"; \
545 skipped="($$skip tests were not run)"; \
547 test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
548 dashes="$$skipped"; \
551 if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
552 report="Please report to $(PACKAGE_BUGREPORT)"; \
553 test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
556 dashes=`echo "$$dashes" | sed s/./=/g`; \
557 if test "$$failed" -eq 0; then \
562 ## Multi line coloring is problematic with "less -R", so we really need
563 ## to color each line individually.
564 echo "$${col}$$dashes$${std}"; \
565 echo "$${col}$$banner$${std}"; \
566 test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \
567 test -z "$$report" || echo "$${col}$$report$${std}"; \
568 echo "$${col}$$dashes$${std}"; \
569 test "$$failed" -eq 0; \
572 endif !%?PARALLEL_TESTS%