Merge branch 'test-protocols' into tap-testsuite-work
[platform/upstream/automake.git] / lib / Automake / tests / Makefile.in
index 18308b0..f375e3c 100644 (file)
@@ -74,19 +74,25 @@ am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
 am__v_at_0 = @
 SOURCES =
 DIST_SOURCES =
+am__tty_colors_dummy = \
+  mgn= red= grn= lgn= blu= brg= std=; \
+  am__color_tests=no
 # 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 = \
-red=; grn=; lgn=; blu=; std=; \
+$(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='\e[0;31m'; \
   grn='\e[0;32m'; \
   lgn='\e[1;32m'; \
   blu='\e[1;34m'; \
+  mgn='\e[0;35m'; \
+  brg='\e[1m'; \
   std='\e[m'; \
 }
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@@ -110,88 +116,62 @@ am__nobase_list = $(am__nobase_strip_setup); \
 am__base_list = \
   sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
   sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
-# Restructured Text title and section.
+# Restructured Text title.
 am__rst_title = sed 's/.*/   &   /;h;s/./=/g;p;x;p;g;p;s/.*//'
-am__rst_section = sed 'p;s/./=/g;p;g'
-# Put stdin (possibly several lines separated by ".  ") in a box.
-# Prefix each line by 'col' and terminate each with 'std', for coloring.
-# Multi line coloring is problematic with "less -R", so we really need
-# to color each line individually.
-am__text_box = $(AWK) '{                       \
-  n = split($$0, lines, "\\.  "); max = 0;     \
-  for (i = 1; i <= n; ++i)                     \
-    if (max < length(lines[i]))                        \
-      max = length(lines[i]);                  \
-  for (i = 0; i < max; ++i)                    \
-    line = line "=";                           \
-  print col line std;                          \
-  for (i = 1; i <= n; ++i)                     \
-    if (lines[i])                              \
-      print col lines[i] std;                  \
-  print col line std;                          \
-}'
 # Solaris 10 'make', and several other traditional 'make' implementations,
 # pass "-e" to $(SHELL), and POSIX 2008 even requires this.  Work around it
 # by disabling -e (using the XSI extension "set +e") if it's set.
 am__sh_e_setup = case $$- in *e*) set +e;; esac
+# Default flags passed to test drivers.
+am__common_driver_flags = \
+  --color-tests "$$am__color_tests" \
+  --enable-hard-errors "$$am__enable_hard_errors" \
+  --expect-failure "$$am__expect_failure"
 # To be inserted before the command running the test.  Creates the
 # directory for the log if needed.  Stores in $dir the directory
 # containing $f, in $tst the test, in $log the log.  Executes the
 # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
-# passes TESTS_ENVIRONMENT.  Saves and restores TERM around uses of
-# TESTS_ENVIRONMENT and AM_TESTS_ENVIRONMENT, in case any of them
-# unsets it.
+# passes TESTS_ENVIRONMENT.  Set up options for the wrapper that
+# will run the test scripts (or their associated LOG_COMPILER, if
+# thy have one).
 am__check_pre = \
 $(am__sh_e_setup);                                     \
 $(am__vpath_adj_setup) $(am__vpath_adj)                        \
+$(am__tty_colors);                                     \
 srcdir=$(srcdir); export srcdir;                       \
-rm -f $@-t;                                            \
-am__trap='rm -f '\''$(abs_builddir)/$@-t'\''; (exit $$st); exit $$st'; \
-trap "st=129; $$am__trap" 1; trap "st=130; $$am__trap" 2;      \
-trap "st=141; $$am__trap" 13; trap "st=143; $$am__trap" 15; \
 am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;           \
 test "x$$am__odir" = x. || $(MKDIR_P) "$$am__odir" || exit $$?;        \
 if test -f "./$$f"; then dir=./;                       \
 elif test -f "$$f"; then dir=;                         \
 else dir="$(srcdir)/"; fi;                             \
-tst=$$dir$$f; log='$@'; __SAVED_TERM=$$TERM;           \
-$(AM_TESTS_ENVIRONMENT)                                        \
-$(TESTS_ENVIRONMENT)
-# To be appended to the command running the test.  Handle the stdout
-# and stderr redirection, and catch the exit status.
-am__check_post = \
->$@-t 2>&1;                                            \
-estatus=$$?;                                           \
-if test -n '$(DISABLE_HARD_ERRORS)'                    \
-   && test $$estatus -eq 99; then                      \
-  estatus=1;                                           \
-fi;                                                    \
-TERM=$$__SAVED_TERM; export TERM;                      \
-$(am__tty_colors);                                     \
-xfailed=PASS;                                          \
+tst=$$dir$$f; log='$@';                                \
+if test -n '$(DISABLE_HARD_ERRORS)'; then              \
+  am__enable_hard_errors=no;                           \
+else                                                   \
+  am__enable_hard_errors=yes;                          \
+fi;                                                    \
 case " $(XFAIL_TESTS) " in                             \
   *[\ \        ]$$f[\ \        ]* | *[\ \      ]$$dir$$f[\ \   ]*) \
-    xfailed=XFAIL;;                                    \
-esac;                                                  \
-case $$estatus.$$xfailed in                            \
-    0.XFAIL) col=$$red; res=XPASS;;                    \
-    0.*)     col=$$grn; res=PASS ;;                    \
-    77.*)    col=$$blu; res=SKIP ;;                    \
-    99.*)    col=$$red; res=FAIL ;;                    \
-    *.XFAIL) col=$$lgn; res=XFAIL;;                    \
-    *.*)     col=$$red; res=FAIL ;;                    \
-esac;                                                  \
-echo "$${col}$$res$${std}: $$f";                       \
-echo "$$res: $$f (exit: $$estatus)" |                  \
-  $(am__rst_section) >$@;                              \
-cat $@-t >>$@;                                         \
-rm -f $@-t
+    am__expect_failure=yes;;                           \
+  *)                                                   \
+    am__expect_failure=no;;                            \
+esac;                                                  \
+$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
+# The names of the tests, with any registered extension removed.  Or
+# equivalently, the names of the test logs, with the `.log' extension
+# renoved.  This honours runtime overriding of TESTS and TEST_LOGS.
+am__TEST_BASES = $(TEST_LOGS:.log=)
+# This can be used instead of $(MAKE) in recipes requiring a recursive call
+# to make, but which are not intended to be executed by "make -n".  See the
+# GNU make manual for more details.
+am__stealth_MAKE = $(MAKE)
 RECHECK_LOGS = $(TEST_LOGS)
 AM_RECURSIVE_TARGETS = check check-html recheck recheck-html
 TEST_SUITE_LOG = test-suite.log
 TEST_SUITE_HTML = $(TEST_SUITE_LOG:.log=.html)
 am__test_logs1 = $(TESTS:=.log)
 TEST_LOGS = $(am__test_logs1:.pl.log=.log)
+PL_LOG_DRIVER = $(SHELL) $(top_srcdir)/lib/test-driver
 PL_LOG_COMPILE = $(PL_LOG_COMPILER) $(AM_PL_LOG_FLAGS) $(PL_LOG_FLAGS)
 TEST_LOGS_TMP = $(TEST_LOGS:.log=.log-t)
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -325,7 +305,7 @@ am__tdf = diff-in-tests-lists.tmp
 all: all-am
 
 .SUFFIXES:
-.SUFFIXES: .html .log .pl
+.SUFFIXES: .html .log .pl .trs
 $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(top_srcdir)/CheckListOfTests.am $(am__configure_deps)
        @for dep in $?; do \
          case '$(am__configure_deps)' in \
@@ -365,87 +345,123 @@ CTAGS:
 cscope cscopelist:
 
 
+# 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'.
+.log.trs:
+       rm -f $< $@ && $(am__stealth_MAKE) $(AM_MAKEFLAGS) $<
+
 $(TEST_SUITE_LOG): $(TEST_LOGS)
-       @$(am__sh_e_setup);                                             \
-       list='$(TEST_LOGS)';                                            \
-       results=`for f in $$list; do                                    \
-                  test -r $$f && read line < $$f && echo "$$line"      \
-                    || echo FAIL;                                      \
-                done`;                                                 \
-       all=`echo "$$results" | sed '/^$$/d' | wc -l | sed -e 's/^[      ]*//'`; \
-       fail=`echo "$$results" | grep -c '^FAIL'`;                      \
-       pass=`echo "$$results" | grep -c '^PASS'`;                      \
-       skip=`echo "$$results" | grep -c '^SKIP'`;                      \
-       xfail=`echo "$$results" | grep -c '^XFAIL'`;                    \
-       xpass=`echo "$$results" | grep -c '^XPASS'`;                    \
-       failures=`expr $$fail + $$xpass`;                               \
-       all=`expr $$all - $$skip`;                                      \
-       if test "$$all" -eq 1; then tests=test; All=;                   \
-       else tests=tests; All="All "; fi;                               \
-       case fail=$$fail:xpass=$$xpass:xfail=$$xfail in                 \
-         fail=0:xpass=0:xfail=0)                                       \
-           msg="$$All$$all $$tests passed.  ";                         \
-           exit=true;;                                                 \
-         fail=0:xpass=0:xfail=*)                                       \
-           msg="$$All$$all $$tests behaved as expected";               \
-           if test "$$xfail" -eq 1; then xfailures=failure;            \
-           else xfailures=failures; fi;                                \
-           msg="$$msg ($$xfail expected $$xfailures).  ";              \
-           exit=true;;                                                 \
-         fail=*:xpass=0:xfail=*)                                       \
-           msg="$$fail of $$all $$tests failed.  ";                    \
-           exit=false;;                                                \
-         fail=*:xpass=*:xfail=*)                                       \
-           msg="$$failures of $$all $$tests did not behave as expected"; \
-           if test "$$xpass" -eq 1; then xpasses=pass;                 \
-           else xpasses=passes; fi;                                    \
-           msg="$$msg ($$xpass unexpected $$xpasses).  ";              \
-           exit=false;;                                                \
-         *)                                                            \
-           echo >&2 "incorrect case"; exit 4;;                         \
-       esac;                                                           \
-       if test "$$skip" -ne 0; then                                    \
-         if test "$$skip" -eq 1; then                                  \
-           msg="$$msg($$skip test was not run).  ";                    \
-         else                                                          \
-           msg="$$msg($$skip tests were not run).  ";                  \
-         fi;                                                           \
-       fi;                                                             \
+       @$(am__sh_e_setup); $(am__tty_colors); \
+       bases='$(am__TEST_BASES)'; \
+       ws='[   ]'; \
+       redo_bases=`for b in $$bases; do \
+                     test -f $$b.trs && test -r $$b.trs \
+                       && test -f $$b.log && test -r $$b.log \
+                       || echo $$b; \
+                   done`; \
+       if test -n "$$redo_bases"; then \
+         redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
+         redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
+         rm -f $$redo_logs && rm -f $$redo_results \
+           && $(am__stealth_MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
+       fi; \
+       st=0; \
+       for b in $$redo_bases; do \
+         for e in trs log; do \
+           if test ! -f $$b.$$e || test ! -r $$b.$$e; then \
+             echo "fatal: making $@: failed to create $$b.$$e" >&2; \
+             st=1; \
+           fi; \
+         done; \
+       done; \
+       test $$st -eq 0 || exit 1; \
+       results=`for b in $$bases; do echo $$b.trs; done`; \
+       test -n "$$results" || results=/dev/null; \
+       all=`  grep "^$$ws*:test-result:"           $$results | wc -l`; \
+       pass=` grep "^$$ws*:test-result:$$ws*PASS"  $$results | wc -l`; \
+       fail=` grep "^$$ws*:test-result:$$ws*FAIL"  $$results | wc -l`; \
+       skip=` grep "^$$ws*:test-result:$$ws*SKIP"  $$results | wc -l`; \
+       xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
+       xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
+       error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
+       if test `expr $$fail + $$xpass + $$error` -eq 0; then \
+         success=true; \
+       else \
+         success=false; \
+       fi; \
+       br='==================='; br=$$br$$br$$br$$br; \
+       result_count () \
+       { \
+           if test x"$$1" = x"--maybe-color"; then \
+             maybe_colorize=yes; \
+           elif test x"$$1" = x"--no-color"; then \
+             maybe_colorize=no; \
+           else \
+             echo "$@: invalid 'result_count' usage" >&2; exit 4; \
+           fi; \
+           shift; \
+           desc=$$1 count=$$2; \
+           if test $$maybe_colorize = yes && test $$count -gt 0; then \
+             color_start=$$3 color_end=$$std; \
+           else \
+             color_start= color_end=; \
+           fi; \
+           echo "$${color_start}# $$desc $$count$${color_end}"; \
+       }; \
+       create_testsuite_report () \
+       { \
+         result_count $$1 "TOTAL:" $$all   "$$brg"; \
+         result_count $$1 "PASS: " $$pass  "$$grn"; \
+         result_count $$1 "SKIP: " $$skip  "$$blu"; \
+         result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
+         result_count $$1 "FAIL: " $$fail  "$$red"; \
+         result_count $$1 "XPASS:" $$xpass "$$red"; \
+         result_count $$1 "ERROR:" $$error "$$mgn"; \
+       }; \
        {                                                               \
          echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" |       \
            $(am__rst_title);                                           \
-         echo "$$msg";                                                 \
+         create_testsuite_report --no-color;                           \
          echo;                                                         \
          echo ".. contents:: :depth: 2";                               \
          echo;                                                         \
-         for f in $$list; do                                           \
-           test -r $$f && read line < $$f || line=;                    \
-           case $$line in                                              \
-             PASS:*|XFAIL:*);;                                         \
-             *) echo; cat $$f;;                                        \
-           esac;                                                       \
+         for b in $$bases; do                                          \
+           if grep "^$$ws*:copy-in-global-log:$$ws*no$$ws*$$" $$b.trs  \
+                >/dev/null; then :;                                    \
+           elif test ! -r $$b.log; then                                \
+             echo "ERROR: cannot read $$b.log" >&2;                    \
+             echo && echo "WARNING: could not read $$b.log!";          \
+           else                                                        \
+             echo && cat $$b.log;                                      \
+           fi;                                                         \
          done;                                                         \
        } >$(TEST_SUITE_LOG).tmp;                                       \
        mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG);                     \
-       if test "$$failures" -ne 0; then                                \
-         msg="$${msg}See $(subdir)/$(TEST_SUITE_LOG).  ";              \
-         if test -n "$(PACKAGE_BUGREPORT)"; then                       \
-           msg="$${msg}Please report to $(PACKAGE_BUGREPORT).  ";      \
-         fi;                                                           \
-       fi;                                                             \
-       test x"$$VERBOSE" = x || $$exit || cat $(TEST_SUITE_LOG);       \
-       $(am__tty_colors);                                              \
-       if $$exit; then                                                 \
+       if $$success; then                                              \
          col="$$grn";                                                  \
         else                                                           \
          col="$$red";                                                  \
+         test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG);               \
        fi;                                                             \
-       echo "$$msg" | $(am__text_box) "col=$$col" "std=$$std";         \
-       $$exit
+       echo "$${col}$$br$${std}";                                      \
+       echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}";   \
+       echo "$${col}$$br$${std}";                                      \
+       create_testsuite_report --maybe-color;                          \
+       echo "$$col$$br$$std";                                          \
+       if $$success; then :; else                                      \
+         echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}";         \
+         if test -n "$(PACKAGE_BUGREPORT)"; then                       \
+           echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
+         fi;                                                           \
+         echo "$$col$$br$$std";                                        \
+       fi;                                                             \
+       $$success
 
 # Run all the tests.
 check-TESTS:
        @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
+       @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
        @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
        @list='$(TEST_LOGS)';                                           \
        list=`for f in $$list; do                                       \
@@ -478,18 +494,21 @@ check-html:
        $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_HTML) || exit 4;   \
        exit $$rv
 recheck recheck-html:
-       @target=`echo $@ | sed 's,^re,,'`;                              \
-       list='$(TEST_LOGS)';                                            \
-       list=`for f in $$list; do                                       \
-               test -f $$f || continue;                                \
-               if test -r $$f && read line < $$f; then                 \
-                 case $$line in FAIL*|XPASS*) echo $$f;; esac;         \
-               else echo $$f; fi;                                      \
+       @ws='[  ]';                                                     \
+       target=`echo $@ | sed 's,^re,,'`;                               \
+       bases='$(am__TEST_BASES)';                                      \
+       list=`for b in $$bases; do                                      \
+               test ! -f $$b.trs && test ! -f $$b.log && continue;     \
+               grep "^$$ws*:recheck:$$ws*no$$ws*$$" $$b.trs            \
+                 >/dev/null 2>&1 || echo $$b.log;                      \
              done | tr '\012\015' '  '`;                               \
        list=`echo "$$list" | sed 's/ *$$//'`;                          \
        $(MAKE) $(AM_MAKEFLAGS) $$target AM_MAKEFLAGS='$(AM_MAKEFLAGS) TEST_LOGS="'"$$list"'"'
 .pl.log:
-       @p='$<'; $(am__check_pre) $(PL_LOG_COMPILE) "$$tst" $(am__check_post)
+       @p='$<'; $(am__check_pre) $(PL_LOG_DRIVER) --test-name "$$f" \
+       --log-file '$*.log' --trs-file '$*.trs' \
+       $(am__common_driver_flags) $(AM_PL_LOG_DRIVER_FLAGS) $(PL_LOG_DRIVER_FLAGS) -- $(PL_LOG_COMPILE) "$$tst" \
+       $(AM_TESTS_FD_REDIRECT)
 
 distdir: $(DISTFILES)
        @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
@@ -550,6 +569,7 @@ mostlyclean-generic:
        -test -z "$(TEST_LOGS_TMP)" || rm -f $(TEST_LOGS_TMP)
        -test -z "$(TEST_SUITE_HTML)" || rm -f $(TEST_SUITE_HTML)
        -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+       -test -z "$(am__TEST_BASES:=.trs)" || rm -f $(am__TEST_BASES:=.trs)
 
 clean-generic: