1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 2001, 2003, 2006, 2007, 2008, 2009, 2010, 2011 Free
3 ## 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;p;g;p;s/.*//'
61 am__rst_section = sed 'p;s/./=/g;p;g'
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 in
118 ## avoiding weird bug on lesser make implementations.
121 # Recover from deleted `.trs' file; this should ensure that
122 # "rm -f foo.log; make foo.trs" re-run `foo.test', and re-create
123 # both `foo.log' and `foo.trs'. Break the recipe in two subshells
124 # to avoid problems with "make -n".
127 $(MAKE) $(AM_MAKEFLAGS) $<
129 # Helper recipe used by $(TEST_SUITE_LOG) below, to avoid problems with
130 # "make -n". Break this recipe in multiple shell invocations too, to
131 # really work as expected with "make -n".
134 @rm -f $$redo_results
135 ## The use of the `am__remaking_logs' environment variable below is
136 ## required to ensure that we don't go into an infinite recursion in
137 ## case a test log in $(TEST_LOGS) is the same as $(TEST_SUITE_LOG).
138 ## Yes, this has already happened in practice. Sigh!
139 @if test -n "$$am__remaking_logs"; then \
140 echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
141 "recursion detected" >&2; \
143 am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
145 ## Sanity check: each unreadable or non-existent test result file should
146 ## has been properly remade at this point, as should the corresponding log
149 errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
150 for i in $$redo_bases; do \
151 test -f $$i.trs && test -r $$i.trs \
152 || { echo "$$errmsg $$i.trs"; st=1; }; \
153 test -f $$i.log && test -r $$i.log \
154 || { echo "$$errmsg $$i.log"; st=1; }; \
157 .PHONY: am--redo-logs
159 $(TEST_SUITE_LOG): $(TEST_LOGS)
160 @$(am__set_TESTS_bases); \
161 ## Helper shell function, tells whether a path refers to an existing,
162 ## regular, readable file.
163 am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
164 ## We need to ensures that all the required `.trs' and `.log' files will
165 ## be present and readable. The direct dependencies of $(TEST_SUITE_LOG)
166 ## only ensure that all the `.log' files exists; they don't ensure that
167 ## the `.log' files are readable, and worse, they don't ensure that the
168 ## `.trs' files even exist.
169 redo_bases=`for i in $$bases; do \
170 am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
172 if test -n "$$redo_bases"; then \
173 ## Uh-oh, either some `.log' files were unreadable, or some `.trs' files
174 ## were missing (or unreadable). We need to re-run the corresponding
175 ## tests in order to re-create them.
176 redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
177 redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
178 ## The exported variables are needed by the helper hook.
179 redo_bases="$$redo_bases" \
180 redo_logs="$$redo_logs" \
181 redo_results="$$redo_results" \
182 $(MAKE) $(AM_MAKEFLAGS) am--redo-logs || exit 1; \
184 ## We need a new subshell to work portably with "make -n", since the
185 ## previous part of the recipe contained a $(MAKE) invocation.
186 @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
188 ## List of test result files.
189 results=`for b in $$bases; do echo $$b.trs; done`; \
190 test -n "$$results" || results=/dev/null; \
191 ## Prepare data for the test suite summary. These do not take into account
192 ## unreadable test results, but they'll be appropriately updated later if
194 all=` grep "^$$ws*:test-result:" $$results | wc -l`; \
195 pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \
196 fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \
197 skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \
198 xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
199 xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
200 error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
201 ## Whether the testsuite was successful or not.
202 if test `expr $$fail + $$xpass + $$error` -eq 0; then \
207 ## Make $br a line of exactly 76 `=' characters, that will be used to
208 ## enclose the testsuite summary report when displayed on the console.
209 br='==================='; br=$$br$$br$$br$$br; \
210 ## When writing the test summary to the console, we want to color a line
211 ## reporting the count of some result *only* if at least one test
212 ## experienced such a result. This function is handy in this regard.
215 if test x"$$1" = x"--maybe-color"; then \
216 maybe_colorize=yes; \
217 elif test x"$$1" = x"--no-color"; then \
220 echo "$@: invalid 'result_count' usage" >&2; exit 4; \
223 desc=$$1 count=$$2; \
224 if test $$maybe_colorize = yes && test $$count -gt 0; then \
225 color_start=$$3 color_end=$$std; \
227 color_start= color_end=; \
229 echo "$${color_start}# $$desc $$count$${color_end}"; \
231 ## A shell function that creates the testsuite summary. We need it
232 ## because we have to create *two* summaries, one for test-suite.log,
233 ## and a possibly-colorized one for console output.
234 create_testsuite_report () \
236 result_count $$1 "TOTAL:" $$all "$$brg"; \
237 result_count $$1 "PASS: " $$pass "$$grn"; \
238 result_count $$1 "SKIP: " $$skip "$$blu"; \
239 result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
240 result_count $$1 "FAIL: " $$fail "$$red"; \
241 result_count $$1 "XPASS:" $$xpass "$$red"; \
242 result_count $$1 "ERROR:" $$error "$$mgn"; \
244 ## Write "global" testsuite log.
246 echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
248 create_testsuite_report --no-color; \
250 echo ".. contents:: :depth: 2"; \
252 for i in $$bases; do \
253 ## FIXME: one fork per test -- this is horrendously inefficient!
254 if grep "^$$ws*:copy-in-global-log:$$ws*no$$ws*$$" $$i.trs \
255 >/dev/null; then continue; \
257 ## Get the declared "global result" of the test.
258 ## FIXME: yet another one fork per test here!
259 glob_res=`sed -n -e "s/$$ws*$$//" \
260 -e "s/^$$ws*:global-test-result:$$ws*//p" \
262 ## If no global result is explicitly declared, we'll merely mark the
263 ## test as "RUN" in the global test log.
264 test -n "$$glob_res" || glob_res=RUN; \
265 ## Write the name and result of the test as an RST section title.
266 echo "$$glob_res: $$i" | $(am__rst_section); \
267 ## If we should have remade any unreadable `.log', above.
268 if test ! -r $$i.log; then \
269 echo "fatal: making $@: $$i.log is unreadable" >&2; \
274 } >$(TEST_SUITE_LOG).tmp; \
275 mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
276 ## Emit the test summary on the console.
281 test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
283 ## Multi line coloring is problematic with "less -R", so we really need
284 ## to color each line individually.
285 echo "$${col}$$br$${std}"; \
286 echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \
287 echo "$${col}$$br$${std}"; \
288 ## This is expected to go to the console, so it might have to be colorized.
289 create_testsuite_report --maybe-color; \
290 echo "$$col$$br$$std"; \
291 if $$success; then :; else \
292 echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \
293 if test -n "$(PACKAGE_BUGREPORT)"; then \
294 echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
296 echo "$$col$$br$$std"; \
298 ## Be sure to exit with the proper exit status. The use of "exit 1" below
299 ## is required to work around a FreeBSD make bug (present only when running
300 ## in concurrent mode). See automake bug#9245:
301 ## <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9245>
302 ## and FreeBSD PR bin/159730:
303 ## <http://www.freebsd.org/cgi/query-pr.cgi?pr=159730>.
306 RECHECK_LOGS = $(TEST_LOGS)
310 ## Expand $(RECHECK_LOGS) only once, to avoid exceeding line length limits.
311 @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
312 @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
313 ## We always have to remove TEST_SUITE_LOG, to ensure its rule is run
314 ## in any case even in lazy mode: otherwise, if no test needs rerunning,
315 ## or a prior run plus reruns all happen within the same timestamp
316 ## (can happen with a prior `make TESTS=<subset>'),
317 ## then we get no log output.
318 ## OTOH, this means that, in the rule for `$(TEST_SUITE_LOG)', we
319 ## cannot use `$?' to compute the set of lazily rerun tests, lest
320 ## we rely on .PHONY to work portably.
322 ## Trailing whitespace in `TESTS = foo.test $(empty)' causes GNU make
323 ## 3.80 to erroneously expand $(TESTS_LOGS) to `foo.log .log'.
324 ## Work around this bug.
325 @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
326 @list='$(TEST_LOGS)'; \
327 list=`for i in $$list; do \
328 test .log = $$i || echo $$i; \
329 done | tr '\012\015' ' '`; \
330 ## This apparently useless munging helps to avoid a nasty bug (a
331 ## segmentation fault!) on Solaris XPG4 make.
332 list=`echo "$$list" | sed 's/ *$$//'`; \
333 $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$list"
335 AM_RECURSIVE_TARGETS += check
342 @list='$(RST2HTML) $$RST2HTML rst2html rst2html.py'; \
343 for r2h in $$list; do \
344 if ($$r2h --version) >/dev/null 2>&1; then \
348 if test -z "$$R2H"; then \
349 echo >&2 "cannot find rst2html, cannot create $@"; \
355 # Be sure to run check first, and then to convert the result.
356 # Beware of concurrent executions. Run "check" not "check-TESTS", as
357 # check-SCRIPTS and other dependencies are rebuilt by the former only.
358 # And expect check to fail.
360 @if $(MAKE) $(AM_MAKEFLAGS) check; then \
363 $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_HTML) || exit 4; \
369 AM_RECURSIVE_TARGETS += check-html
371 ## -------------------- ##
372 ## Rechecking failures. ##
373 ## -------------------- ##
375 ## Rerun all tests that experienced an error or an unexpected failure.
376 recheck recheck-html:
378 target=`echo $@ | sed 's,^re,,'`; \
379 $(am__set_TESTS_bases); \
380 list=`for i in $$bases; do \
381 ## Skip tests that haven't been run, but recover gracefully from deleted
383 test -f $$i.trs || test -f $$i.log || continue; \
384 ## FIXME: one fork per test -- this is horrendously inefficient!
385 grep "^$$ws*:recheck:$$ws*no$$ws*$$" $$i.trs \
386 >/dev/null 2>&1 || echo $$i.log; \
387 done | tr '\012\015' ' '`; \
388 ## This apparently useless munging helps to avoid a nasty bug (a
389 ## segmentation fault!) on Solaris XPG4 make.
390 list=`echo "$$list" | sed 's/ *$$//'`; \
391 $(MAKE) $(AM_MAKEFLAGS) $$target AM_MAKEFLAGS='$(AM_MAKEFLAGS) TEST_LOGS="'"$$list"'"'
393 .PHONY: recheck recheck-html
394 .MAKE: recheck recheck-html
396 AM_RECURSIVE_TARGETS += recheck recheck-html
398 else !%?PARALLEL_TESTS%
400 check-TESTS: $(TESTS)
401 @failed=0; all=0; xfail=0; xpass=0; skip=0; \
402 srcdir=$(srcdir); export srcdir; \
403 ## Make sure Solaris VPATH-expands all members of this list, even
404 ## the first and the last one; thus the spaces around $(TESTS)
407 if test -n "$$list"; then \
408 for tst in $$list; do \
409 if test -f ./$$tst; then dir=./; \
410 ## Note: Solaris 2.7 seems to expand TESTS using VPATH. That's
411 ## why we also try `dir='
412 elif test -f $$tst; then dir=; \
413 else dir="$(srcdir)/"; fi; \
414 if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \
416 all=`expr $$all + 1`; \
417 case " $(XFAIL_TESTS) " in \
418 *[\ \ ]$$tst[\ \ ]*) \
419 xpass=`expr $$xpass + 1`; \
420 failed=`expr $$failed + 1`; \
421 col=$$red; res=XPASS; \
424 col=$$grn; res=PASS; \
427 elif test $$? -ne 77; then \
429 all=`expr $$all + 1`; \
430 case " $(XFAIL_TESTS) " in \
431 *[\ \ ]$$tst[\ \ ]*) \
432 xfail=`expr $$xfail + 1`; \
433 col=$$lgn; res=XFAIL; \
436 failed=`expr $$failed + 1`; \
437 col=$$red; res=FAIL; \
442 skip=`expr $$skip + 1`; \
443 col=$$blu; res=SKIP; \
445 echo "$${col}$$res$${std}: $$tst"; \
447 ## Prepare the banner
448 if test "$$all" -eq 1; then \
455 if test "$$failed" -eq 0; then \
456 if test "$$xfail" -eq 0; then \
457 banner="$$All$$all $$tests passed"; \
459 if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
460 banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
463 if test "$$xpass" -eq 0; then \
464 banner="$$failed of $$all $$tests failed"; \
466 if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
467 banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
470 ## DASHES should contain the largest line of the banner.
473 if test "$$skip" -ne 0; then \
474 if test "$$skip" -eq 1; then \
475 skipped="($$skip test was not run)"; \
477 skipped="($$skip tests were not run)"; \
479 test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
480 dashes="$$skipped"; \
483 if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
484 report="Please report to $(PACKAGE_BUGREPORT)"; \
485 test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
488 dashes=`echo "$$dashes" | sed s/./=/g`; \
489 if test "$$failed" -eq 0; then \
494 ## Multi line coloring is problematic with "less -R", so we really need
495 ## to color each line individually.
496 echo "$${col}$$dashes$${std}"; \
497 echo "$${col}$$banner$${std}"; \
498 test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \
499 test -z "$$report" || echo "$${col}$$report$${std}"; \
500 echo "$${col}$$dashes$${std}"; \
501 test "$$failed" -eq 0; \
504 endif !%?PARALLEL_TESTS%