1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 2001, 2003, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 ## Free Software Foundation, Inc.
5 ## This program is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 2, or (at your option)
10 ## This program is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program. If not, see <http://www.gnu.org/licenses/>.
18 am__tty_colors_dummy = \
19 mgn= red= grn= lgn= blu= brg= std=; \
22 # If stdout is a non-dumb tty, use colors. If test -t is not supported,
23 # then this fails; a conservative approach. Of course do not redirect
24 # stdout here, just stderr.
26 $(am__tty_colors_dummy); \
27 test "X$(AM_COLOR_TESTS)" != Xno \
28 && test "X$$TERM" != Xdumb \
29 && { test "X$(AM_COLOR_TESTS)" = Xalways || test -t 1 2>/dev/null; } \
31 am__color_tests=yes; \
41 am__tty_colors = $(am__tty_colors_dummy)
50 ## New parallel test driver.
52 ## The first version of the code here was adapted from check.mk, which was
53 ## originally written at EPITA/LRDE, further developed at Gostai, then made
54 ## its way from GNU coreutils to end up, largely rewritten, in Automake.
55 ## The current version is an heavy rewrite of that, to allow for support
56 ## of more test metadata, and the use of custom test derivers and protocols
59 # Restructured Text title and section.
60 am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
61 am__rst_section = { sed 'p;s/./=/g;' && echo; }
63 # Solaris 10 'make', and several other traditional 'make' implementations,
64 # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it
65 # by disabling -e (using the XSI extension "set +e") if it's set.
66 am__sh_e_setup = case $$- in *e*) set +e;; esac
68 # Default flags passed to test drivers.
69 am__common_driver_flags = \
70 --color-tests "$$am__color_tests" \
71 --enable-hard-errors "$$am__enable_hard_errors" \
72 --expect-failure "$$am__expect_failure"
74 # To be inserted before the command running the test. Creates the
75 # directory for the log if needed. Stores in $dir the directory
76 # containing $f, in $tst the test, in $log the log. Executes the
77 # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
78 # passes TESTS_ENVIRONMENT. Set up options for the wrapper that
79 # will run the test scripts (or their associated LOG_COMPILER, if
83 $(am__vpath_adj_setup) $(am__vpath_adj) \
85 srcdir=$(srcdir); export srcdir; \
86 am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`; \
87 test "x$$am__odir" = x. || $(MKDIR_P) "$$am__odir" || exit $$?; \
88 if test -f "./$$f"; then dir=./; \
89 elif test -f "$$f"; then dir=; \
90 else dir="$(srcdir)/"; fi; \
91 tst=$$dir$$f; log='$@'; \
92 if test -n '$(DISABLE_HARD_ERRORS)'; then \
93 am__enable_hard_errors=no; \
95 am__enable_hard_errors=yes; \
97 ## The use of $dir below is required to account for VPATH
98 ## rewriting done by Sun make.
99 case " $(XFAIL_TESTS) " in \
100 *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \
101 am__expect_failure=yes;; \
103 am__expect_failure=no;; \
105 $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
107 # A shell command to get the names of the tests scripts with any registered
108 # extension removed (i.e., equivalently, the names of the test logs, with
109 # the `.log' extension removed). The result is saved in the shell variable
110 # `$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly,
111 # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)",
112 # since that might cause problem with VPATH rewrites for suffix-less tests.
113 # See also 'test-harness-vpath-rewrite.test' and 'test-trs-basic.test'.
114 am__set_TESTS_bases = \
115 bases='$(TEST_LOGS)'; \
116 bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
117 ## Trim away any extra whitespace. This has already proved useful
118 ## in avoiding weird bug on lesser make implementations. It also
119 ## works around the GNU make 3.80 bug where trailing whitespace in
120 ## "TESTS = foo.test $(empty)" causes $(TESTS_LOGS) to erroneously
121 ## expand to "foo.log .log".
124 # Recover from deleted `.trs' file; this should ensure that
125 # "rm -f foo.log; make foo.trs" re-run `foo.test', and re-create
126 # both `foo.log' and `foo.trs'. Break the recipe in two subshells
127 # to avoid problems with "make -n".
130 $(MAKE) $(AM_MAKEFLAGS) $<
132 $(TEST_SUITE_LOG): $(TEST_LOGS)
133 @$(am__set_TESTS_bases); \
134 ## Helper shell function, tells whether a path refers to an existing,
135 ## regular, readable file.
136 am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
137 ## We need to ensures that all the required `.trs' and `.log' files will
138 ## be present and readable. The direct dependencies of $(TEST_SUITE_LOG)
139 ## only ensure that all the `.log' files exists; they don't ensure that
140 ## the `.log' files are readable, and worse, they don't ensure that the
141 ## `.trs' files even exist.
142 redo_bases=`for i in $$bases; do \
143 am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
145 if test -n "$$redo_bases"; then \
146 ## Uh-oh, either some `.log' files were unreadable, or some `.trs' files
147 ## were missing (or unreadable). We need to re-run the corresponding
148 ## tests in order to re-create them.
149 redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
150 redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
151 if $(am__make_dryrun); then :; else \
152 ## Break "rm -f" into two calls to minimize the possibility of exceeding
153 ## command line length limits.
154 rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
157 ## Use a trick to to ensure that we don't go into an infinite recursion
158 ## in case a test log in $(TEST_LOGS) is the same as $(TEST_SUITE_LOG).
159 ## Yes, this has already happened in practice. Sigh!
160 if test -n "$$am__remaking_logs"; then \
161 echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
162 "recursion detected" >&2; \
164 am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
166 if $(am__make_dryrun); then :; else \
167 ## Sanity check: each unreadable or non-existent test result file should
168 ## has been properly remade at this point, as should the corresponding log
171 errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
172 for i in $$redo_bases; do \
173 test -f $$i.trs && test -r $$i.trs \
174 || { echo "$$errmsg $$i.trs"; st=1; }; \
175 test -f $$i.log && test -r $$i.log \
176 || { echo "$$errmsg $$i.log"; st=1; }; \
178 test $$st -eq 0 || exit 1; \
180 ## We need a new subshell to work portably with "make -n", since the
181 ## previous part of the recipe contained a $(MAKE) invocation.
182 @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
184 ## List of test result files.
185 results=`for b in $$bases; do echo $$b.trs; done`; \
186 test -n "$$results" || results=/dev/null; \
187 ## Prepare data for the test suite summary. These do not take into account
188 ## unreadable test results, but they'll be appropriately updated later if
190 all=` grep "^$$ws*:test-result:" $$results | wc -l`; \
191 pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \
192 fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \
193 skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \
194 xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
195 xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
196 error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
197 ## Whether the testsuite was successful or not.
198 if test `expr $$fail + $$xpass + $$error` -eq 0; then \
203 ## Make $br a line of exactly 76 `=' characters, that will be used to
204 ## enclose the testsuite summary report when displayed on the console.
205 br='==================='; br=$$br$$br$$br$$br; \
206 ## When writing the test summary to the console, we want to color a line
207 ## reporting the count of some result *only* if at least one test
208 ## experienced such a result. This function is handy in this regard.
211 if test x"$$1" = x"--maybe-color"; then \
212 maybe_colorize=yes; \
213 elif test x"$$1" = x"--no-color"; then \
216 echo "$@: invalid 'result_count' usage" >&2; exit 4; \
219 desc=$$1 count=$$2; \
220 if test $$maybe_colorize = yes && test $$count -gt 0; then \
221 color_start=$$3 color_end=$$std; \
223 color_start= color_end=; \
225 echo "$${color_start}# $$desc $$count$${color_end}"; \
227 ## A shell function that creates the testsuite summary. We need it
228 ## because we have to create *two* summaries, one for test-suite.log,
229 ## and a possibly-colorized one for console output.
230 create_testsuite_report () \
232 result_count $$1 "TOTAL:" $$all "$$brg"; \
233 result_count $$1 "PASS: " $$pass "$$grn"; \
234 result_count $$1 "SKIP: " $$skip "$$blu"; \
235 result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
236 result_count $$1 "FAIL: " $$fail "$$red"; \
237 result_count $$1 "XPASS:" $$xpass "$$red"; \
238 result_count $$1 "ERROR:" $$error "$$mgn"; \
240 ## Write "global" testsuite log.
242 echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
244 create_testsuite_report --no-color; \
246 echo ".. contents:: :depth: 2"; \
248 for i in $$bases; do \
249 ## FIXME: one fork per test -- this is horrendously inefficient!
250 if grep "^$$ws*:copy-in-global-log:$$ws*no$$ws*$$" $$i.trs \
251 >/dev/null; then continue; \
253 ## Get the declared "global result" of the test.
254 ## FIXME: yet another one fork per test here!
255 glob_res=`sed -n -e "s/$$ws*$$//" \
256 -e "s/^$$ws*:global-test-result:$$ws*//p" \
258 ## If no global result is explicitly declared, we'll merely mark the
259 ## test as "RUN" in the global test log.
260 test -n "$$glob_res" || glob_res=RUN; \
261 ## Write the name and result of the test as an RST section title.
262 echo "$$glob_res: $$i" | $(am__rst_section); \
263 ## If we should have remade any unreadable `.log', above.
264 if test ! -r $$i.log; then \
265 echo "fatal: making $@: $$i.log is unreadable" >&2; \
270 } >$(TEST_SUITE_LOG).tmp; \
271 mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
272 ## Emit the test summary on the console.
277 test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
279 ## Multi line coloring is problematic with "less -R", so we really need
280 ## to color each line individually.
281 echo "$${col}$$br$${std}"; \
282 echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \
283 echo "$${col}$$br$${std}"; \
284 ## This is expected to go to the console, so it might have to be colorized.
285 create_testsuite_report --maybe-color; \
286 echo "$$col$$br$$std"; \
287 if $$success; then :; else \
288 echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \
289 if test -n "$(PACKAGE_BUGREPORT)"; then \
290 echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
292 echo "$$col$$br$$std"; \
294 ## Be sure to exit with the proper exit status. The use of "exit 1" below
295 ## is required to work around a FreeBSD make bug (present only when running
296 ## in concurrent mode). See automake bug#9245:
297 ## <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9245>
298 ## and FreeBSD PR bin/159730:
299 ## <http://www.freebsd.org/cgi/query-pr.cgi?pr=159730>.
302 RECHECK_LOGS = $(TEST_LOGS)
304 ## ------------------------------------------ ##
305 ## Running all tests, or rechecking failures. ##
306 ## ------------------------------------------ ##
309 ## If we are running "make recheck", it's not the user which can decide
310 ## which tests to consider for re-execution, so we must ignore the value
311 ## of $(RECHECK_LOGS).
312 ## Here and below, we expand $(RECHECK_LOGS) only once, to avoid exceeding
313 ## line length limits.
314 @if test $@ != recheck; then \
315 list='$(RECHECK_LOGS)'; \
316 test -z "$$list" || rm -f $$list; \
318 @if test $@ != recheck; then \
319 list='$(RECHECK_LOGS:.log=.trs)'; \
320 test -z "$$list" || rm -f $$list; \
322 ## We always have to remove TEST_SUITE_LOG, to ensure its rule is run
323 ## in any case even in lazy mode: otherwise, if no test needs rerunning,
324 ## or a prior run plus reruns all happen within the same timestamp (can
325 ## happen with a prior `make TESTS=<subset>'), then we get no log output.
326 ## OTOH, this means that, in the rule for `$(TEST_SUITE_LOG)', we
327 ## cannot use `$?' to compute the set of lazily rerun tests, lest
328 ## we rely on .PHONY to work portably.
329 @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
331 log_list='' trs_list=''; $(am__set_TESTS_bases); \
332 for i in $$bases; do \
333 ## If running a "make recheck", we must only consider tests that had an
334 ## unexpected outcome (FAIL or XPASS) in the earlier run. In particular,
335 ## skip tests that haven't been run. But recover gracefully from deleted
337 if test $@ = recheck; then \
338 test -f $$i.trs || test -f $$i.log || continue; \
339 ## FIXME: one fork per test -- this is horrendously inefficient!
340 grep "^$$ws*:recheck:$$ws*no$$ws*$$" $$i.trs \
341 >/dev/null 2>&1 && continue; \
343 ## Be careful to avoid extra whitespace in the definition of $list, since
344 ## its value will be passed to the recursive make invocation below through
345 ## the TEST_LOGS macro, and leading/trailing white space in a make macro
346 ## definition can be problematic. In this particular case, trailing white
347 ## space was known to cause a segmentation fault on Solaris 10 XPG4 make:
348 ## <http://lists.gnu.org/archive/html/bug-automake/2010-08/msg00004.html>
349 if test -z "$$log_list"; then \
350 log_list="$$i.log"; \
352 log_list="$$log_list $$i.log"; \
354 if test -z "$$trs_list"; then \
355 trs_list="$$i.trs"; \
357 trs_list="$$trs_list $$i.trs"; \
360 ## Under "make recheck", remove the .log and .trs files associated
361 ## with the files to recheck, so that those will be rerun by the
362 ## "make test-suite.log" recursive invocation below. But use a proper
363 ## hack to avoid extra files removal when running under "make -n".
364 if test $@ != recheck || $(am__make_dryrun); then :; else \
365 test -z "$$log_list" || rm -f $$log_list; \
366 test -z "$$trs_list" || rm -f $$trs_list; \
368 $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"
370 ## Recheck must depend on $(check_SCRIPTS), $(check_PROGRAMS), etc.
371 recheck: %CHECK_DEPS%
373 AM_RECURSIVE_TARGETS += check recheck
377 else !%?PARALLEL_TESTS%
379 check-TESTS: $(TESTS)
380 @failed=0; all=0; xfail=0; xpass=0; skip=0; \
381 srcdir=$(srcdir); export srcdir; \
382 ## Make sure Solaris VPATH-expands all members of this list, even
383 ## the first and the last one; thus the spaces around $(TESTS)
386 if test -n "$$list"; then \
387 for tst in $$list; do \
388 if test -f ./$$tst; then dir=./; \
389 ## Note: Solaris 2.7 seems to expand TESTS using VPATH. That's
390 ## why we also try `dir='
391 elif test -f $$tst; then dir=; \
392 else dir="$(srcdir)/"; fi; \
393 if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \
395 all=`expr $$all + 1`; \
396 case " $(XFAIL_TESTS) " in \
397 *[\ \ ]$$tst[\ \ ]*) \
398 xpass=`expr $$xpass + 1`; \
399 failed=`expr $$failed + 1`; \
400 col=$$red; res=XPASS; \
403 col=$$grn; res=PASS; \
406 elif test $$? -ne 77; then \
408 all=`expr $$all + 1`; \
409 case " $(XFAIL_TESTS) " in \
410 *[\ \ ]$$tst[\ \ ]*) \
411 xfail=`expr $$xfail + 1`; \
412 col=$$lgn; res=XFAIL; \
415 failed=`expr $$failed + 1`; \
416 col=$$red; res=FAIL; \
421 skip=`expr $$skip + 1`; \
422 col=$$blu; res=SKIP; \
424 echo "$${col}$$res$${std}: $$tst"; \
426 ## Prepare the banner
427 if test "$$all" -eq 1; then \
434 if test "$$failed" -eq 0; then \
435 if test "$$xfail" -eq 0; then \
436 banner="$$All$$all $$tests passed"; \
438 if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
439 banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
442 if test "$$xpass" -eq 0; then \
443 banner="$$failed of $$all $$tests failed"; \
445 if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
446 banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
449 ## DASHES should contain the largest line of the banner.
452 if test "$$skip" -ne 0; then \
453 if test "$$skip" -eq 1; then \
454 skipped="($$skip test was not run)"; \
456 skipped="($$skip tests were not run)"; \
458 test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
459 dashes="$$skipped"; \
462 if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
463 report="Please report to $(PACKAGE_BUGREPORT)"; \
464 test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
467 dashes=`echo "$$dashes" | sed s/./=/g`; \
468 if test "$$failed" -eq 0; then \
473 ## Multi line coloring is problematic with "less -R", so we really need
474 ## to color each line individually.
475 echo "$${col}$$dashes$${std}"; \
476 echo "$${col}$$banner$${std}"; \
477 test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \
478 test -z "$$report" || echo "$${col}$$report$${std}"; \
479 echo "$${col}$$dashes$${std}"; \
480 test "$$failed" -eq 0; \
483 endif !%?PARALLEL_TESTS%