X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=lib%2Fam%2Fcheck.am;h=9cda82aba62956860c76f53bbf5da4fbc3e529c6;hb=a16b838b03e759e5a98fdb9f1546d6ad302b3f4c;hp=0628c866153eadab59fb547372c710fcb40fb8d0;hpb=509348ecc96e7984f7630cc5f1300e7b174bb133;p=platform%2Fupstream%2Fautomake.git diff --git a/lib/am/check.am b/lib/am/check.am index 0628c86..9cda82a 100644 --- a/lib/am/check.am +++ b/lib/am/check.am @@ -1,6 +1,5 @@ ## automake - create Makefile.in from Makefile.am -## Copyright (C) 2001, 2003, 2006, 2007, 2008, 2009, 2010, 2011 Free -## Software Foundation, Inc. +## Copyright (C) 2001-2012 Free Software Foundation, Inc. ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -19,23 +18,27 @@ am__tty_colors_dummy = \ mgn= red= grn= lgn= blu= brg= std=; \ am__color_tests=no if %?COLOR% -# If stdout is a non-dumb tty, use colors. If test -t is not supported, -# then this fails; a conservative approach. Of course do not redirect -# stdout here, just stderr. -am__tty_colors = \ -$(am__tty_colors_dummy); \ -test "X$(AM_COLOR_TESTS)" != Xno \ -&& test "X$$TERM" != Xdumb \ -&& { test "X$(AM_COLOR_TESTS)" = Xalways || test -t 1 2>/dev/null; } \ -&& { \ - am__color_tests=yes; \ - red=''; \ - grn=''; \ - lgn=''; \ - blu=''; \ - mgn=''; \ - brg=''; \ - std=''; \ +am__tty_colors = { \ + $(am__tty_colors_dummy); \ + if test "X$(AM_COLOR_TESTS)" = Xno; then \ + am__color_tests=no; \ + elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ + am__color_tests=yes; \ +## If stdout is a non-dumb tty, use colors. If test -t is not supported, +## then this check fails; a conservative approach. Of course do not +## redirect stdout here, just stderr. + elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ + am__color_tests=yes; \ + fi; \ + if test $$am__color_tests = yes; then \ + red=''; \ + grn=''; \ + lgn=''; \ + blu=''; \ + mgn=''; \ + brg=''; \ + std=''; \ + fi; \ } else !%?COLOR% am__tty_colors = $(am__tty_colors_dummy) @@ -56,9 +59,113 @@ include inst-vars.am ## of more test metadata, and the use of custom test derivers and protocols ## (among them, TAP). -# Restructured Text title and section. -am__rst_title = sed 's/.*/ & /;h;s/./=/g;p;x;p;g;p;s/.*//' -am__rst_section = sed 'p;s/./=/g;p;g' +am__recheck_rx = ^[ ]*:recheck:[ ]* +am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* +am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* + +# A command that, given a newline-separated list of test names on the +# standard input, print the name of the tests that are to be re-run +# upon "make recheck". +am__list_recheck_tests = $(AWK) '{ \ +## By default, we assume the test is to be re-run. + recheck = 1; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + { \ +## If we've encountered an I/O error here, there are three possibilities: +## +## [1] The '.log' file exists, but the '.trs' does not; in this case, +## we "gracefully" recover by assuming the corresponding test is +## to be re-run (which will re-create the missing '.trs' file). +## +## [2] Both the '.log' and '.trs' files are missing; this means that +## the corresponding test has not been run, and is thus *not* to +## be re-run. +## +## [3] We have encountered some corner-case problem (e.g., a '.log' or +## '.trs' files somehow made unreadable, or issues with a bad NFS +## connection, or whatever); we don't handle such corner cases. +## + if ((getline line2 < ($$0 ".log")) < 0) \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ +## A directive explicitly specifying the test is *not* to be re-run. + { \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ + { \ +## A directive explicitly specifying the test *is* to be re-run. + break; \ + } \ +## else continue with the next iteration. + }; \ + if (recheck) \ + print $$0; \ +## Don't leak open file descriptors, as this could cause serious +## problems when there are many tests (yes, even on Linux). + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' + +# A command that, given a newline-separated list of test names on the +# standard input, create the global log from their .trs and .log files. +am__create_global_log = $(AWK) ' \ +function fatal(msg) \ +{ \ + print "fatal: making $@: " msg | "cat >&2"; \ + exit 1; \ +} \ +function rst_section(header) \ +{ \ + print header; \ + len = length(header); \ + for (i = 1; i <= len; i = i + 1) \ + printf "="; \ + printf "\n\n"; \ +} \ +{ \ +## By default, we assume the test log is to be copied in the global log, +## and that its result is simply "RUN" (i.e., we still don't know what +## it outcome was, but we know that at least it has run). + copy_in_global_log = 1; \ + global_test_result = "RUN"; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".trs"); \ + if (line ~ /$(am__global_test_result_rx)/) \ + { \ + sub("$(am__global_test_result_rx)", "", line); \ + sub("[ ]*$$", "", line); \ + global_test_result = line; \ + } \ + else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ + copy_in_global_log = 0; \ + }; \ + if (copy_in_global_log) \ + { \ + rst_section(global_test_result ": " $$0); \ + while ((rc = (getline line < ($$0 ".log"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".log"); \ + print line; \ + }; \ + printf "\n"; \ + }; \ +## Don't leak open file descriptors, as this could cause serious +## problems when there are many tests (yes, even on Linux). + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' + +# Restructured Text title. +am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } # Solaris 10 'make', and several other traditional 'make' implementations, # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it @@ -83,8 +190,12 @@ $(am__sh_e_setup); \ $(am__vpath_adj_setup) $(am__vpath_adj) \ $(am__tty_colors); \ srcdir=$(srcdir); export srcdir; \ -am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`; \ -test "x$$am__odir" = x. || $(MKDIR_P) "$$am__odir" || exit $$?; \ +case "$@" in \ + */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ + *) am__odir=.;; \ +esac; \ +test "x$$am__odir" = x"." || test -d "$$am__odir" \ + || $(MKDIR_P) "$$am__odir" || exit $$?; \ if test -f "./$$f"; then dir=./; \ elif test -f "$$f"; then dir=; \ else dir="$(srcdir)/"; fi; \ @@ -106,81 +217,77 @@ $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) # A shell command to get the names of the tests scripts with any registered # extension removed (i.e., equivalently, the names of the test logs, with -# the `.log' extension removed). The result is saved in the shell variable -# `$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, +# the '.log' extension removed). The result is saved in the shell variable +# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", # since that might cause problem with VPATH rewrites for suffix-less tests. # See also 'test-harness-vpath-rewrite.test' and 'test-trs-basic.test'. am__set_TESTS_bases = \ bases='$(TEST_LOGS)'; \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ -## Trim away any extra whitespace. This has already proved useful in -## avoiding weird bug on lesser make implementations. +## Trim away any extra whitespace. This has already proved useful +## in avoiding weird bug on lesser make implementations. It also +## works around the GNU make 3.80 bug where trailing whitespace in +## "TESTS = foo.test $(empty)" causes $(TESTS_LOGS) to erroneously +## expand to "foo.log .log". bases=`echo $$bases` -# Recover from deleted `.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run `foo.test', and re-create -# both `foo.log' and `foo.trs'. Break the recipe in two subshells +# Recover from deleted '.trs' file; this should ensure that +# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create +# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells # to avoid problems with "make -n". .log.trs: rm -f $< $@ $(MAKE) $(AM_MAKEFLAGS) $< -# Helper recipe used by $(TEST_SUITE_LOG) below, to avoid problems with -# "make -n". Break this recipe in multiple shell invocations too, to -# really work as expected with "make -n". -am--redo-logs: - @rm -f $$redo_logs - @rm -f $$redo_results -## The use of the `am__remaking_logs' environment variable below is -## required to ensure that we don't go into an infinite recursion in -## case a test log in $(TEST_LOGS) is the same as $(TEST_SUITE_LOG). -## Yes, this has already happened in practice. Sigh! - @if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - else \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; -## Sanity check: each unreadable or non-existent test result file should -## has been properly remade at this point, as should the corresponding log -## file. - @st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs"; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log"; st=1; }; \ - done; \ - test $$st -eq 0 -.PHONY: am--redo-logs - $(TEST_SUITE_LOG): $(TEST_LOGS) @$(am__set_TESTS_bases); \ ## Helper shell function, tells whether a path refers to an existing, ## regular, readable file. am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ -## We need to ensures that all the required `.trs' and `.log' files will +## We need to ensures that all the required '.trs' and '.log' files will ## be present and readable. The direct dependencies of $(TEST_SUITE_LOG) -## only ensure that all the `.log' files exists; they don't ensure that -## the `.log' files are readable, and worse, they don't ensure that the -## `.trs' files even exist. +## only ensure that all the '.log' files exists; they don't ensure that +## the '.log' files are readable, and worse, they don't ensure that the +## '.trs' files even exist. redo_bases=`for i in $$bases; do \ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ done`; \ if test -n "$$redo_bases"; then \ -## Uh-oh, either some `.log' files were unreadable, or some `.trs' files +## Uh-oh, either some '.log' files were unreadable, or some '.trs' files ## were missing (or unreadable). We need to re-run the corresponding ## tests in order to re-create them. redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ -## The exported variables are needed by the helper hook. - redo_bases="$$redo_bases" \ - redo_logs="$$redo_logs" \ - redo_results="$$redo_results" \ - $(MAKE) $(AM_MAKEFLAGS) am--redo-logs || exit 1; \ - else :; fi; + if $(am__make_dryrun); then :; else \ +## Break "rm -f" into two calls to minimize the possibility of exceeding +## command line length limits. + rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ + fi; \ + fi; \ +## Use a trick to to ensure that we don't go into an infinite recursion +## in case a test log in $(TEST_LOGS) is the same as $(TEST_SUITE_LOG). +## Yes, this has already happened in practice. Sigh! + if test -n "$$am__remaking_logs"; then \ + echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ + "recursion detected" >&2; \ + else \ + am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ + fi; \ + if $(am__make_dryrun); then :; else \ +## Sanity check: each unreadable or non-existent test result file should +## has been properly remade at this point, as should the corresponding log +## file. + st=0; \ + errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ + for i in $$redo_bases; do \ + test -f $$i.trs && test -r $$i.trs \ + || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ + test -f $$i.log && test -r $$i.log \ + || { echo "$$errmsg $$i.log" >&2; st=1; }; \ + done; \ + test $$st -eq 0 || exit 1; \ + fi ## We need a new subshell to work portably with "make -n", since the ## previous part of the recipe contained a $(MAKE) invocation. @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ @@ -204,7 +311,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS) else \ success=false; \ fi; \ -## Make $br a line of exactly 76 `=' characters, that will be used to +## Make $br a line of exactly 76 '=' characters, that will be used to ## enclose the testsuite summary report when displayed on the console. br='==================='; br=$$br$$br$$br$$br; \ ## When writing the test summary to the console, we want to color a line @@ -249,29 +356,9 @@ $(TEST_SUITE_LOG): $(TEST_LOGS) echo; \ echo ".. contents:: :depth: 2"; \ echo; \ - for i in $$bases; do \ -## FIXME: one fork per test -- this is horrendously inefficient! - if grep "^$$ws*:copy-in-global-log:$$ws*no$$ws*$$" $$i.trs \ - >/dev/null; then continue; \ - fi; \ -## Get the declared "global result" of the test. -## FIXME: yet another one fork per test here! - glob_res=`sed -n -e "s/$$ws*$$//" \ - -e "s/^$$ws*:global-test-result:$$ws*//p" \ - $$i.trs`; \ -## If no global result is explicitly declared, we'll merely mark the -## test as "RUN" in the global test log. - test -n "$$glob_res" || glob_res=RUN; \ -## Write the name and result of the test as an RST section title. - echo "$$glob_res: $$i" | $(am__rst_section); \ -## If we should have remade any unreadable `.log', above. - if test ! -r $$i.log; then \ - echo "fatal: making $@: $$i.log is unreadable" >&2; \ - exit 1; \ - fi; \ - cat $$i.log; echo; \ - done; \ - } >$(TEST_SUITE_LOG).tmp; \ + for b in $$bases; do echo $$b; done \ + | $(am__create_global_log); \ + } >$(TEST_SUITE_LOG).tmp || exit 1; \ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ ## Emit the test summary on the console. if $$success; then \ @@ -305,95 +392,65 @@ $(TEST_SUITE_LOG): $(TEST_LOGS) RECHECK_LOGS = $(TEST_LOGS) -# Run all the tests. -check-TESTS: -## Expand $(RECHECK_LOGS) only once, to avoid exceeding line length limits. - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list +## ------------------------------------------ ## +## Running all tests, or rechecking failures. ## +## ------------------------------------------ ## + +check-TESTS recheck: +## If we are running "make recheck", it's not the user which can decide +## which tests to consider for re-execution, so we must ignore the value +## of $(RECHECK_LOGS). +## Here and below, we expand $(RECHECK_LOGS) only once, to avoid exceeding +## line length limits. + @if test $@ != recheck; then \ + list='$(RECHECK_LOGS)'; \ + test -z "$$list" || rm -f $$list; \ + fi + @if test $@ != recheck; then \ + list='$(RECHECK_LOGS:.log=.trs)'; \ + test -z "$$list" || rm -f $$list; \ + fi ## We always have to remove TEST_SUITE_LOG, to ensure its rule is run ## in any case even in lazy mode: otherwise, if no test needs rerunning, -## or a prior run plus reruns all happen within the same timestamp -## (can happen with a prior `make TESTS='), -## then we get no log output. -## OTOH, this means that, in the rule for `$(TEST_SUITE_LOG)', we -## cannot use `$?' to compute the set of lazily rerun tests, lest +## or a prior run plus reruns all happen within the same timestamp (can +## happen with a prior "make TESTS="), then we get no log output. +## OTOH, this means that, in the rule for '$(TEST_SUITE_LOG)', we +## cannot use '$?' to compute the set of lazily rerun tests, lest ## we rely on .PHONY to work portably. -## -## Trailing whitespace in `TESTS = foo.test $(empty)' causes GNU make -## 3.80 to erroneously expand $(TESTS_LOGS) to `foo.log .log'. -## Work around this bug. @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @list='$(TEST_LOGS)'; \ - list=`for i in $$list; do \ - test .log = $$i || echo $$i; \ - done | tr '\012\015' ' '`; \ -## This apparently useless munging helps to avoid a nasty bug (a -## segmentation fault!) on Solaris XPG4 make. - list=`echo "$$list" | sed 's/ *$$//'`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$list" - -AM_RECURSIVE_TARGETS += check - -## -------------- ## -## Produce HTML. ## -## -------------- ## - -.log.html: - @list='$(RST2HTML) $$RST2HTML rst2html rst2html.py'; \ - for r2h in $$list; do \ - if ($$r2h --version) >/dev/null 2>&1; then \ - R2H=$$r2h; \ - fi; \ - done; \ - if test -z "$$R2H"; then \ - echo >&2 "cannot find rst2html, cannot create $@"; \ - exit 2; \ - fi; \ - $$R2H $< >$@.tmp - @mv $@.tmp $@ - -# Be sure to run check first, and then to convert the result. -# Beware of concurrent executions. Run "check" not "check-TESTS", as -# check-SCRIPTS and other dependencies are rebuilt by the former only. -# And expect check to fail. -check-html: - @if $(MAKE) $(AM_MAKEFLAGS) check; then \ - rv=0; else rv=$$?; \ - fi; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_HTML) || exit 4; \ - exit $$rv - -.PHONY: check-html -.MAKE: check-html - -AM_RECURSIVE_TARGETS += check-html - -## -------------------- ## -## Rechecking failures. ## -## -------------------- ## + @$(am__set_TESTS_bases); \ + if test $@ = recheck; then \ +## If running a "make recheck", we must only consider tests that had an +## unexpected outcome (FAIL or XPASS) in the earlier run. + bases=`for i in $$bases; do echo $$i; done \ + | $(am__list_recheck_tests)` || exit 1; \ + fi; \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + trs_list=`for i in $$bases; do echo $$i.trs; done`; \ +## Remove newlines and normalize whitespace, being careful to avoid extra +## whitespace in the definition of $log_list, since its value will be +## passed to the recursive make invocation below through the TEST_LOGS +## macro, and leading/trailing white space in a make macro definition can +## be problematic. In this particular case, trailing white space is known +## to have caused segmentation faults on Solaris 10 XPG4 make: + log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ +## Under "make recheck", remove the .log and .trs files associated +## with the files to recheck, so that those will be rerun by the +## "make test-suite.log" recursive invocation below. But use a proper +## hack to avoid extra files removal when running under "make -n". + if test $@ != recheck || $(am__make_dryrun); then :; else \ + test -z "$$log_list" || rm -f $$log_list; \ + test -z "$$trs_list" || rm -f $$trs_list; \ + fi; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list" -## Rerun all tests that experienced an error or an unexpected failure. -recheck recheck-html: - @ws='[ ]'; \ - target=`echo $@ | sed 's,^re,,'`; \ - $(am__set_TESTS_bases); \ - list=`for i in $$bases; do \ -## Skip tests that haven't been run, but recover gracefully from deleted -## `.trs' files. - test -f $$i.trs || test -f $$i.log || continue; \ -## FIXME: one fork per test -- this is horrendously inefficient! - grep "^$$ws*:recheck:$$ws*no$$ws*$$" $$i.trs \ - >/dev/null 2>&1 || echo $$i.log; \ - done | tr '\012\015' ' '`; \ -## This apparently useless munging helps to avoid a nasty bug (a -## segmentation fault!) on Solaris XPG4 make. - list=`echo "$$list" | sed 's/ *$$//'`; \ - $(MAKE) $(AM_MAKEFLAGS) $$target AM_MAKEFLAGS='$(AM_MAKEFLAGS) TEST_LOGS="'"$$list"'"' +## Recheck must depend on $(check_SCRIPTS), $(check_PROGRAMS), etc. +## It must also depend on the 'all' target. See automake bug#11252. +recheck: all %CHECK_DEPS% -.PHONY: recheck recheck-html -.MAKE: recheck recheck-html +AM_RECURSIVE_TARGETS += check recheck -AM_RECURSIVE_TARGETS += recheck recheck-html +.PHONY: recheck else !%?PARALLEL_TESTS% @@ -408,7 +465,7 @@ check-TESTS: $(TESTS) for tst in $$list; do \ if test -f ./$$tst; then dir=./; \ ## Note: Solaris 2.7 seems to expand TESTS using VPATH. That's -## why we also try `dir=' +## why we also try 'dir='. elif test -f $$tst; then dir=; \ else dir="$(srcdir)/"; fi; \ if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \