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:[ ]*
60 # A command that, given a newline-separated list of test names on the
61 # standard input, print the name of the tests that are to be re-run
62 # upon "make recheck".
63 am__list_recheck_tests = $(AWK) '{ \
64 ## By default, we assume the test is to be re-run.
66 while ((rc = (getline line < ($$0 ".trs"))) != 0) \
70 ## If we've encountered an I/O error here, there are three possibilities:
72 ## [1] The '.log' file exists, but the '.trs' does not; in this case,
73 ## we "gracefully" recover by assuming the corresponding test is
74 ## to be re-run (which will re-create the missing '.trs' file).
76 ## [2] Both the '.log' and '.trs' files are missing; this means that
77 ## the corresponding test has not been run, and is thus *not* to
80 ## [3] We have encountered some corner-case problem (e.g., a '.log' or
81 ## '.trs' files somehow made unreadable, or issues with a bad NFS
82 ## connection, or whatever); we don't handle such corner cases.
84 if ((getline line2 < ($$0 ".log")) < 0) \
88 else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \
89 ## A directive explicitly specifying the test is *not* to be re-run.
94 else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \
96 ## A directive explicitly specifying the test *is* to be re-run.
99 ## else continue with the next iteration.
103 ## Don't leak open file descriptors, as this could cause serious
104 ## problems when there are many tests (yes, even on Linux).
105 close ($$0 ".trs"); \
106 close ($$0 ".log"); \
109 # Restructured Text title and section.
110 am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
111 am__rst_section = { sed 'p;s/./=/g;' && echo; }
113 # Solaris 10 'make', and several other traditional 'make' implementations,
114 # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it
115 # by disabling -e (using the XSI extension "set +e") if it's set.
116 am__sh_e_setup = case $$- in *e*) set +e;; esac
118 # Default flags passed to test drivers.
119 am__common_driver_flags = \
120 --color-tests "$$am__color_tests" \
121 --enable-hard-errors "$$am__enable_hard_errors" \
122 --expect-failure "$$am__expect_failure"
124 # To be inserted before the command running the test. Creates the
125 # directory for the log if needed. Stores in $dir the directory
126 # containing $f, in $tst the test, in $log the log. Executes the
127 # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
128 # passes TESTS_ENVIRONMENT. Set up options for the wrapper that
129 # will run the test scripts (or their associated LOG_COMPILER, if
133 $(am__vpath_adj_setup) $(am__vpath_adj) \
135 srcdir=$(srcdir); export srcdir; \
136 am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`; \
137 test "x$$am__odir" = x. || $(MKDIR_P) "$$am__odir" || exit $$?; \
138 if test -f "./$$f"; then dir=./; \
139 elif test -f "$$f"; then dir=; \
140 else dir="$(srcdir)/"; fi; \
141 tst=$$dir$$f; log='$@'; \
142 if test -n '$(DISABLE_HARD_ERRORS)'; then \
143 am__enable_hard_errors=no; \
145 am__enable_hard_errors=yes; \
147 ## The use of $dir below is required to account for VPATH
148 ## rewriting done by Sun make.
149 case " $(XFAIL_TESTS) " in \
150 *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \
151 am__expect_failure=yes;; \
153 am__expect_failure=no;; \
155 $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
157 # A shell command to get the names of the tests scripts with any registered
158 # extension removed (i.e., equivalently, the names of the test logs, with
159 # the '.log' extension removed). The result is saved in the shell variable
160 # '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly,
161 # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)",
162 # since that might cause problem with VPATH rewrites for suffix-less tests.
163 # See also 'test-harness-vpath-rewrite.test' and 'test-trs-basic.test'.
164 am__set_TESTS_bases = \
165 bases='$(TEST_LOGS)'; \
166 bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
167 ## Trim away any extra whitespace. This has already proved useful
168 ## in avoiding weird bug on lesser make implementations. It also
169 ## works around the GNU make 3.80 bug where trailing whitespace in
170 ## "TESTS = foo.test $(empty)" causes $(TESTS_LOGS) to erroneously
171 ## expand to "foo.log .log".
174 # Recover from deleted '.trs' file; this should ensure that
175 # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create
176 # both 'foo.log' and 'foo.trs'. Break the recipe in two subshells
177 # to avoid problems with "make -n".
180 $(MAKE) $(AM_MAKEFLAGS) $<
182 $(TEST_SUITE_LOG): $(TEST_LOGS)
183 @$(am__set_TESTS_bases); \
184 ## Helper shell function, tells whether a path refers to an existing,
185 ## regular, readable file.
186 am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
187 ## We need to ensures that all the required '.trs' and '.log' files will
188 ## be present and readable. The direct dependencies of $(TEST_SUITE_LOG)
189 ## only ensure that all the '.log' files exists; they don't ensure that
190 ## the '.log' files are readable, and worse, they don't ensure that the
191 ## '.trs' files even exist.
192 redo_bases=`for i in $$bases; do \
193 am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
195 if test -n "$$redo_bases"; then \
196 ## Uh-oh, either some '.log' files were unreadable, or some '.trs' files
197 ## were missing (or unreadable). We need to re-run the corresponding
198 ## tests in order to re-create them.
199 redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
200 redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
201 if $(am__make_dryrun); then :; else \
202 ## Break "rm -f" into two calls to minimize the possibility of exceeding
203 ## command line length limits.
204 rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
207 ## Use a trick to to ensure that we don't go into an infinite recursion
208 ## in case a test log in $(TEST_LOGS) is the same as $(TEST_SUITE_LOG).
209 ## Yes, this has already happened in practice. Sigh!
210 if test -n "$$am__remaking_logs"; then \
211 echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
212 "recursion detected" >&2; \
214 am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
216 if $(am__make_dryrun); then :; else \
217 ## Sanity check: each unreadable or non-existent test result file should
218 ## has been properly remade at this point, as should the corresponding log
221 errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
222 for i in $$redo_bases; do \
223 test -f $$i.trs && test -r $$i.trs \
224 || { echo "$$errmsg $$i.trs" >&2; st=1; }; \
225 test -f $$i.log && test -r $$i.log \
226 || { echo "$$errmsg $$i.log" >&2; st=1; }; \
228 test $$st -eq 0 || exit 1; \
230 ## We need a new subshell to work portably with "make -n", since the
231 ## previous part of the recipe contained a $(MAKE) invocation.
232 @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
234 ## List of test result files.
235 results=`for b in $$bases; do echo $$b.trs; done`; \
236 test -n "$$results" || results=/dev/null; \
237 ## Prepare data for the test suite summary. These do not take into account
238 ## unreadable test results, but they'll be appropriately updated later if
240 all=` grep "^$$ws*:test-result:" $$results | wc -l`; \
241 pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \
242 fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \
243 skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \
244 xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
245 xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
246 error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
247 ## Whether the testsuite was successful or not.
248 if test `expr $$fail + $$xpass + $$error` -eq 0; then \
253 ## Make $br a line of exactly 76 '=' characters, that will be used to
254 ## enclose the testsuite summary report when displayed on the console.
255 br='==================='; br=$$br$$br$$br$$br; \
256 ## When writing the test summary to the console, we want to color a line
257 ## reporting the count of some result *only* if at least one test
258 ## experienced such a result. This function is handy in this regard.
261 if test x"$$1" = x"--maybe-color"; then \
262 maybe_colorize=yes; \
263 elif test x"$$1" = x"--no-color"; then \
266 echo "$@: invalid 'result_count' usage" >&2; exit 4; \
269 desc=$$1 count=$$2; \
270 if test $$maybe_colorize = yes && test $$count -gt 0; then \
271 color_start=$$3 color_end=$$std; \
273 color_start= color_end=; \
275 echo "$${color_start}# $$desc $$count$${color_end}"; \
277 ## A shell function that creates the testsuite summary. We need it
278 ## because we have to create *two* summaries, one for test-suite.log,
279 ## and a possibly-colorized one for console output.
280 create_testsuite_report () \
282 result_count $$1 "TOTAL:" $$all "$$brg"; \
283 result_count $$1 "PASS: " $$pass "$$grn"; \
284 result_count $$1 "SKIP: " $$skip "$$blu"; \
285 result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
286 result_count $$1 "FAIL: " $$fail "$$red"; \
287 result_count $$1 "XPASS:" $$xpass "$$red"; \
288 result_count $$1 "ERROR:" $$error "$$mgn"; \
290 ## Write "global" testsuite log.
292 echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
294 create_testsuite_report --no-color; \
296 echo ".. contents:: :depth: 2"; \
298 for i in $$bases; do \
299 ## FIXME: one fork per test -- this is horrendously inefficient!
300 if grep "^$$ws*:copy-in-global-log:$$ws*no$$ws*$$" $$i.trs \
301 >/dev/null; then continue; \
303 ## Get the declared "global result" of the test.
304 ## FIXME: yet another one fork per test here!
305 glob_res=`sed -n -e "s/$$ws*$$//" \
306 -e "s/^$$ws*:global-test-result:$$ws*//p" \
308 ## If no global result is explicitly declared, we'll merely mark the
309 ## test as "RUN" in the global test log.
310 test -n "$$glob_res" || glob_res=RUN; \
311 ## Write the name and result of the test as an RST section title.
312 echo "$$glob_res: $$i" | $(am__rst_section); \
313 ## If we should have remade any unreadable '.log', above.
314 if test ! -r $$i.log; then \
315 echo "fatal: making $@: $$i.log is unreadable" >&2; \
320 } >$(TEST_SUITE_LOG).tmp; \
321 mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
322 ## Emit the test summary on the console.
327 test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
329 ## Multi line coloring is problematic with "less -R", so we really need
330 ## to color each line individually.
331 echo "$${col}$$br$${std}"; \
332 echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \
333 echo "$${col}$$br$${std}"; \
334 ## This is expected to go to the console, so it might have to be colorized.
335 create_testsuite_report --maybe-color; \
336 echo "$$col$$br$$std"; \
337 if $$success; then :; else \
338 echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \
339 if test -n "$(PACKAGE_BUGREPORT)"; then \
340 echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
342 echo "$$col$$br$$std"; \
344 ## Be sure to exit with the proper exit status. The use of "exit 1" below
345 ## is required to work around a FreeBSD make bug (present only when running
346 ## in concurrent mode). See automake bug#9245:
347 ## <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9245>
348 ## and FreeBSD PR bin/159730:
349 ## <http://www.freebsd.org/cgi/query-pr.cgi?pr=159730>.
352 RECHECK_LOGS = $(TEST_LOGS)
354 ## ------------------------------------------ ##
355 ## Running all tests, or rechecking failures. ##
356 ## ------------------------------------------ ##
359 ## If we are running "make recheck", it's not the user which can decide
360 ## which tests to consider for re-execution, so we must ignore the value
361 ## of $(RECHECK_LOGS).
362 ## Here and below, we expand $(RECHECK_LOGS) only once, to avoid exceeding
363 ## line length limits.
364 @if test $@ != recheck; then \
365 list='$(RECHECK_LOGS)'; \
366 test -z "$$list" || rm -f $$list; \
368 @if test $@ != recheck; then \
369 list='$(RECHECK_LOGS:.log=.trs)'; \
370 test -z "$$list" || rm -f $$list; \
372 ## We always have to remove TEST_SUITE_LOG, to ensure its rule is run
373 ## in any case even in lazy mode: otherwise, if no test needs rerunning,
374 ## or a prior run plus reruns all happen within the same timestamp (can
375 ## happen with a prior "make TESTS=<subset>"), then we get no log output.
376 ## OTOH, this means that, in the rule for '$(TEST_SUITE_LOG)', we
377 ## cannot use '$?' to compute the set of lazily rerun tests, lest
378 ## we rely on .PHONY to work portably.
379 @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
380 @$(am__set_TESTS_bases); \
381 if test $@ = recheck; then \
382 ## If running a "make recheck", we must only consider tests that had an
383 ## unexpected outcome (FAIL or XPASS) in the earlier run.
384 bases=`for i in $$bases; do echo $$i; done \
385 | $(am__list_recheck_tests)` || exit 1; \
387 log_list=`for i in $$bases; do echo $$i.log; done`; \
388 trs_list=`for i in $$bases; do echo $$i.trs; done`; \
389 ## Remove newlines and normalize whitespace, being careful to avoid extra
390 ## whitespace in the definition of $log_list, since its value will be
391 ## passed to the recursive make invocation below through the TEST_LOGS
392 ## macro, and leading/trailing white space in a make macro definition can
393 ## be problematic. In this particular case, trailing white space is known
394 ## to have caused segmentation faults on Solaris 10 XPG4 make:
395 log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
396 ## Under "make recheck", remove the .log and .trs files associated
397 ## with the files to recheck, so that those will be rerun by the
398 ## "make test-suite.log" recursive invocation below. But use a proper
399 ## hack to avoid extra files removal when running under "make -n".
400 if test $@ != recheck || $(am__make_dryrun); then :; else \
401 test -z "$$log_list" || rm -f $$log_list; \
402 test -z "$$trs_list" || rm -f $$trs_list; \
404 $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"
406 ## Recheck must depend on $(check_SCRIPTS), $(check_PROGRAMS), etc.
407 ## It must also depend on the 'all' target. See automake bug#11252.
408 recheck: all %CHECK_DEPS%
410 AM_RECURSIVE_TARGETS += check recheck
414 else !%?PARALLEL_TESTS%
416 check-TESTS: $(TESTS)
417 @failed=0; all=0; xfail=0; xpass=0; skip=0; \
418 srcdir=$(srcdir); export srcdir; \
419 ## Make sure Solaris VPATH-expands all members of this list, even
420 ## the first and the last one; thus the spaces around $(TESTS)
423 if test -n "$$list"; then \
424 for tst in $$list; do \
425 if test -f ./$$tst; then dir=./; \
426 ## Note: Solaris 2.7 seems to expand TESTS using VPATH. That's
427 ## why we also try 'dir='.
428 elif test -f $$tst; then dir=; \
429 else dir="$(srcdir)/"; fi; \
430 if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \
432 all=`expr $$all + 1`; \
433 case " $(XFAIL_TESTS) " in \
434 *[\ \ ]$$tst[\ \ ]*) \
435 xpass=`expr $$xpass + 1`; \
436 failed=`expr $$failed + 1`; \
437 col=$$red; res=XPASS; \
440 col=$$grn; res=PASS; \
443 elif test $$? -ne 77; then \
445 all=`expr $$all + 1`; \
446 case " $(XFAIL_TESTS) " in \
447 *[\ \ ]$$tst[\ \ ]*) \
448 xfail=`expr $$xfail + 1`; \
449 col=$$lgn; res=XFAIL; \
452 failed=`expr $$failed + 1`; \
453 col=$$red; res=FAIL; \
458 skip=`expr $$skip + 1`; \
459 col=$$blu; res=SKIP; \
461 echo "$${col}$$res$${std}: $$tst"; \
463 ## Prepare the banner
464 if test "$$all" -eq 1; then \
471 if test "$$failed" -eq 0; then \
472 if test "$$xfail" -eq 0; then \
473 banner="$$All$$all $$tests passed"; \
475 if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
476 banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
479 if test "$$xpass" -eq 0; then \
480 banner="$$failed of $$all $$tests failed"; \
482 if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
483 banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
486 ## DASHES should contain the largest line of the banner.
489 if test "$$skip" -ne 0; then \
490 if test "$$skip" -eq 1; then \
491 skipped="($$skip test was not run)"; \
493 skipped="($$skip tests were not run)"; \
495 test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
496 dashes="$$skipped"; \
499 if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
500 report="Please report to $(PACKAGE_BUGREPORT)"; \
501 test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
504 dashes=`echo "$$dashes" | sed s/./=/g`; \
505 if test "$$failed" -eq 0; then \
510 ## Multi line coloring is problematic with "less -R", so we really need
511 ## to color each line individually.
512 echo "$${col}$$dashes$${std}"; \
513 echo "$${col}$$banner$${std}"; \
514 test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \
515 test -z "$$report" || echo "$${col}$$report$${std}"; \
516 echo "$${col}$$dashes$${std}"; \
517 test "$$failed" -eq 0; \
520 endif !%?PARALLEL_TESTS%