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 derivers 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.test' and 'test-trs-basic.test'.
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 $(TEST_SUITE_LOG): $(TEST_LOGS)
244 @$(am__set_TESTS_bases); \
245 ## Helper shell function, tells whether a path refers to an existing,
246 ## regular, readable file.
247 am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
248 ## We need to ensures that all the required '.trs' and '.log' files will
249 ## be present and readable. The direct dependencies of $(TEST_SUITE_LOG)
250 ## only ensure that all the '.log' files exists; they don't ensure that
251 ## the '.log' files are readable, and worse, they don't ensure that the
252 ## '.trs' files even exist.
253 redo_bases=`for i in $$bases; do \
254 am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
256 if test -n "$$redo_bases"; then \
257 ## Uh-oh, either some '.log' files were unreadable, or some '.trs' files
258 ## were missing (or unreadable). We need to re-run the corresponding
259 ## tests in order to re-create them.
260 redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
261 redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
262 if $(am__make_dryrun); then :; else \
263 ## Break "rm -f" into two calls to minimize the possibility of exceeding
264 ## command line length limits.
265 rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
268 ## Use a trick to to ensure that we don't go into an infinite recursion
269 ## in case a test log in $(TEST_LOGS) is the same as $(TEST_SUITE_LOG).
270 ## Yes, this has already happened in practice. Sigh!
271 if test -n "$$am__remaking_logs"; then \
272 echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
273 "recursion detected" >&2; \
275 am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
277 if $(am__make_dryrun); then :; else \
278 ## Sanity check: each unreadable or non-existent test result file should
279 ## has been properly remade at this point, as should the corresponding log
282 errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
283 for i in $$redo_bases; do \
284 test -f $$i.trs && test -r $$i.trs \
285 || { echo "$$errmsg $$i.trs" >&2; st=1; }; \
286 test -f $$i.log && test -r $$i.log \
287 || { echo "$$errmsg $$i.log" >&2; st=1; }; \
289 test $$st -eq 0 || exit 1; \
291 ## We need a new subshell to work portably with "make -n", since the
292 ## previous part of the recipe contained a $(MAKE) invocation.
293 @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
295 ## List of test result files.
296 results=`for b in $$bases; do echo $$b.trs; done`; \
297 test -n "$$results" || results=/dev/null; \
298 ## Prepare data for the test suite summary. These do not take into account
299 ## unreadable test results, but they'll be appropriately updated later if
301 all=` grep "^$$ws*:test-result:" $$results | wc -l`; \
302 pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \
303 fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \
304 skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \
305 xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
306 xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
307 error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
308 ## Whether the testsuite was successful or not.
309 if test `expr $$fail + $$xpass + $$error` -eq 0; then \
314 ## Make $br a line of exactly 76 '=' characters, that will be used to
315 ## enclose the testsuite summary report when displayed on the console.
316 br='==================='; br=$$br$$br$$br$$br; \
317 ## When writing the test summary to the console, we want to color a line
318 ## reporting the count of some result *only* if at least one test
319 ## experienced such a result. This function is handy in this regard.
322 if test x"$$1" = x"--maybe-color"; then \
323 maybe_colorize=yes; \
324 elif test x"$$1" = x"--no-color"; then \
327 echo "$@: invalid 'result_count' usage" >&2; exit 4; \
330 desc=$$1 count=$$2; \
331 if test $$maybe_colorize = yes && test $$count -gt 0; then \
332 color_start=$$3 color_end=$$std; \
334 color_start= color_end=; \
336 echo "$${color_start}# $$desc $$count$${color_end}"; \
338 ## A shell function that creates the testsuite summary. We need it
339 ## because we have to create *two* summaries, one for test-suite.log,
340 ## and a possibly-colorized one for console output.
341 create_testsuite_report () \
343 result_count $$1 "TOTAL:" $$all "$$brg"; \
344 result_count $$1 "PASS: " $$pass "$$grn"; \
345 result_count $$1 "SKIP: " $$skip "$$blu"; \
346 result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
347 result_count $$1 "FAIL: " $$fail "$$red"; \
348 result_count $$1 "XPASS:" $$xpass "$$red"; \
349 result_count $$1 "ERROR:" $$error "$$mgn"; \
351 ## Write "global" testsuite log.
353 echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
355 create_testsuite_report --no-color; \
357 echo ".. contents:: :depth: 2"; \
359 for b in $$bases; do echo $$b; done \
360 | $(am__create_global_log); \
361 } >$(TEST_SUITE_LOG).tmp || exit 1; \
362 mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
363 ## Emit the test summary on the console.
368 test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
370 ## Multi line coloring is problematic with "less -R", so we really need
371 ## to color each line individually.
372 echo "$${col}$$br$${std}"; \
373 echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \
374 echo "$${col}$$br$${std}"; \
375 ## This is expected to go to the console, so it might have to be colorized.
376 create_testsuite_report --maybe-color; \
377 echo "$$col$$br$$std"; \
378 if $$success; then :; else \
379 echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \
380 if test -n "$(PACKAGE_BUGREPORT)"; then \
381 echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
383 echo "$$col$$br$$std"; \
385 ## Be sure to exit with the proper exit status. The use of "exit 1" below
386 ## is required to work around a FreeBSD make bug (present only when running
387 ## in concurrent mode). See automake bug#9245:
388 ## <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9245>
389 ## and FreeBSD PR bin/159730:
390 ## <http://www.freebsd.org/cgi/query-pr.cgi?pr=159730>.
393 RECHECK_LOGS = $(TEST_LOGS)
395 ## ------------------------------------------ ##
396 ## Running all tests, or rechecking failures. ##
397 ## ------------------------------------------ ##
400 ## If we are running "make recheck", it's not the user which can decide
401 ## which tests to consider for re-execution, so we must ignore the value
402 ## of $(RECHECK_LOGS).
403 ## Here and below, we expand $(RECHECK_LOGS) only once, to avoid exceeding
404 ## line length limits.
405 @if test $@ != recheck; then \
406 list='$(RECHECK_LOGS)'; \
407 test -z "$$list" || rm -f $$list; \
409 @if test $@ != recheck; then \
410 list='$(RECHECK_LOGS:.log=.trs)'; \
411 test -z "$$list" || rm -f $$list; \
413 ## We always have to remove TEST_SUITE_LOG, to ensure its rule is run
414 ## in any case even in lazy mode: otherwise, if no test needs rerunning,
415 ## or a prior run plus reruns all happen within the same timestamp (can
416 ## happen with a prior "make TESTS=<subset>"), then we get no log output.
417 ## OTOH, this means that, in the rule for '$(TEST_SUITE_LOG)', we
418 ## cannot use '$?' to compute the set of lazily rerun tests, lest
419 ## we rely on .PHONY to work portably.
420 @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
421 @$(am__set_TESTS_bases); \
422 if test $@ = recheck; then \
423 ## If running a "make recheck", we must only consider tests that had an
424 ## unexpected outcome (FAIL or XPASS) in the earlier run.
425 bases=`for i in $$bases; do echo $$i; done \
426 | $(am__list_recheck_tests)` || exit 1; \
428 log_list=`for i in $$bases; do echo $$i.log; done`; \
429 trs_list=`for i in $$bases; do echo $$i.trs; done`; \
430 ## Remove newlines and normalize whitespace, being careful to avoid extra
431 ## whitespace in the definition of $log_list, since its value will be
432 ## passed to the recursive make invocation below through the TEST_LOGS
433 ## macro, and leading/trailing white space in a make macro definition can
434 ## be problematic. In this particular case, trailing white space is known
435 ## to have caused segmentation faults on Solaris 10 XPG4 make:
436 log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
437 ## Under "make recheck", remove the .log and .trs files associated
438 ## with the files to recheck, so that those will be rerun by the
439 ## "make test-suite.log" recursive invocation below. But use a proper
440 ## hack to avoid extra files removal when running under "make -n".
441 if test $@ != recheck || $(am__make_dryrun); then :; else \
442 test -z "$$log_list" || rm -f $$log_list; \
443 test -z "$$trs_list" || rm -f $$trs_list; \
445 $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"
447 ## Recheck must depend on $(check_SCRIPTS), $(check_PROGRAMS), etc.
448 ## It must also depend on the 'all' target. See automake bug#11252.
449 recheck: all %CHECK_DEPS%
451 AM_RECURSIVE_TARGETS += check recheck
457 ## Obsolescent serial testsuite driver.
459 check-TESTS: $(TESTS)
460 @failed=0; all=0; xfail=0; xpass=0; skip=0; \
461 srcdir=$(srcdir); export srcdir; \
462 ## Make sure Solaris VPATH-expands all members of this list, even
463 ## the first and the last one; thus the spaces around $(TESTS)
466 if test -n "$$list"; then \
467 for tst in $$list; do \
468 if test -f ./$$tst; then dir=./; \
469 ## Note: Solaris 2.7 seems to expand TESTS using VPATH. That's
470 ## why we also try 'dir='.
471 elif test -f $$tst; then dir=; \
472 else dir="$(srcdir)/"; fi; \
473 if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \
475 all=`expr $$all + 1`; \
476 case " $(XFAIL_TESTS) " in \
477 *[\ \ ]$$tst[\ \ ]*) \
478 xpass=`expr $$xpass + 1`; \
479 failed=`expr $$failed + 1`; \
480 col=$$red; res=XPASS; \
483 col=$$grn; res=PASS; \
486 elif test $$? -ne 77; then \
488 all=`expr $$all + 1`; \
489 case " $(XFAIL_TESTS) " in \
490 *[\ \ ]$$tst[\ \ ]*) \
491 xfail=`expr $$xfail + 1`; \
492 col=$$lgn; res=XFAIL; \
495 failed=`expr $$failed + 1`; \
496 col=$$red; res=FAIL; \
501 skip=`expr $$skip + 1`; \
502 col=$$blu; res=SKIP; \
504 echo "$${col}$$res$${std}: $$tst"; \
506 ## Prepare the banner
507 if test "$$all" -eq 1; then \
514 if test "$$failed" -eq 0; then \
515 if test "$$xfail" -eq 0; then \
516 banner="$$All$$all $$tests passed"; \
518 if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
519 banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
522 if test "$$xpass" -eq 0; then \
523 banner="$$failed of $$all $$tests failed"; \
525 if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
526 banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
529 ## DASHES should contain the largest line of the banner.
532 if test "$$skip" -ne 0; then \
533 if test "$$skip" -eq 1; then \
534 skipped="($$skip test was not run)"; \
536 skipped="($$skip tests were not run)"; \
538 test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
539 dashes="$$skipped"; \
542 if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
543 report="Please report to $(PACKAGE_BUGREPORT)"; \
544 test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
547 dashes=`echo "$$dashes" | sed s/./=/g`; \
548 if test "$$failed" -eq 0; then \
553 ## Multi line coloring is problematic with "less -R", so we really need
554 ## to color each line individually.
555 echo "$${col}$$dashes$${std}"; \
556 echo "$${col}$$banner$${std}"; \
557 test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \
558 test -z "$$report" || echo "$${col}$$report$${std}"; \
559 echo "$${col}$$dashes$${std}"; \
560 test "$$failed" -eq 0; \
563 endif %?SERIAL_TESTS%