Revert "python: Generate python interpreter list"
[automake.git] / lib / am / check.am
blobe0db6511703c4906063c81f15a4b44fb3bfd6759
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 2001-2018 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)
7 ## any later version.
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 <https://www.gnu.org/licenses/>.
17 am__tty_colors_dummy = \
18   mgn= red= grn= lgn= blu= brg= std=; \
19   am__color_tests=no
21 am__tty_colors = { \
22   $(am__tty_colors_dummy); \
23   if test "X$(AM_COLOR_TESTS)" = Xno; then \
24     am__color_tests=no; \
25   elif test "X$(AM_COLOR_TESTS)" = Xalways; then \
26     am__color_tests=yes; \
27 ## If stdout is a non-dumb tty, use colors.  If test -t is not supported,
28 ## then this check fails; a conservative approach.  Of course do not
29 ## redirect stdout here, just stderr.
30   elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \
31     am__color_tests=yes; \
32   fi; \
33   if test $$am__color_tests = yes; then \
34     red='\e[0;31m'; \
35     grn='\e[0;32m'; \
36     lgn='\e[1;32m'; \
37     blu='\e[1;34m'; \
38     mgn='\e[0;35m'; \
39     brg='\e[1m'; \
40     std='\e[m'; \
41   fi; \
44 .PHONY: check-TESTS
46 if !%?SERIAL_TESTS%
48 include inst-vars.am
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 drivers and protocols
57 ## (among them, TAP).
59 am__recheck_rx = ^[     ]*:recheck:[    ]*
60 am__global_test_result_rx = ^[  ]*:global-test-result:[         ]*
61 am__copy_in_global_log_rx = ^[  ]*:copy-in-global-log:[         ]*
63 # A command that, given a newline-separated list of test names on the
64 # standard input, print the name of the tests that are to be re-run
65 # upon "make recheck".
66 am__list_recheck_tests = $(AWK) '{ \
67 ## By default, we assume the test is to be re-run.
68   recheck = 1; \
69   while ((rc = (getline line < ($$0 ".trs"))) != 0) \
70     { \
71       if (rc < 0) \
72         { \
73 ## If we've encountered an I/O error here, there are three possibilities:
75 ##  [1] The '.log' file exists, but the '.trs' does not; in this case,
76 ##      we "gracefully" recover by assuming the corresponding test is
77 ##      to be re-run (which will re-create the missing '.trs' file).
79 ##  [2] Both the '.log' and '.trs' files are missing; this means that
80 ##      the corresponding test has not been run, and is thus *not* to
81 ##      be re-run.
83 ##  [3] We have encountered some corner-case problem (e.g., a '.log' or
84 ##      '.trs' files somehow made unreadable, or issues with a bad NFS
85 ##      connection, or whatever); we don't handle such corner cases.
87           if ((getline line2 < ($$0 ".log")) < 0) \
88             recheck = 0; \
89           break; \
90         } \
91       else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \
92 ## A directive explicitly specifying the test is *not* to be re-run.
93         { \
94           recheck = 0; \
95           break; \
96         } \
97       else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \
98         { \
99 ## A directive explicitly specifying the test *is* to be re-run.
100           break; \
101         } \
102 ## else continue with the next iteration.
103     }; \
104   if (recheck) \
105     print $$0; \
106 ## Don't leak open file descriptors, as this could cause serious
107 ## problems when there are many tests (yes, even on Linux).
108   close ($$0 ".trs"); \
109   close ($$0 ".log"); \
112 # A command that, given a newline-separated list of test names on the
113 # standard input, create the global log from their .trs and .log files.
114 am__create_global_log = $(AWK) ' \
115 function fatal(msg) \
116 { \
117   print "fatal: making $@: " msg | "cat >&2"; \
118   exit 1; \
119 } \
120 function rst_section(header) \
121 { \
122   print header; \
123   len = length(header); \
124   for (i = 1; i <= len; i = i + 1) \
125     printf "="; \
126   printf "\n\n"; \
127 } \
128 { \
129 ## By default, we assume the test log is to be copied in the global log,
130 ## and that its result is simply "RUN" (i.e., we still don't know what
131 ## it outcome was, but we know that at least it has run).
132   copy_in_global_log = 1; \
133   global_test_result = "RUN"; \
134   while ((rc = (getline line < ($$0 ".trs"))) != 0) \
135     { \
136       if (rc < 0) \
137          fatal("failed to read from " $$0 ".trs"); \
138       if (line ~ /$(am__global_test_result_rx)/) \
139         { \
140           sub("$(am__global_test_result_rx)", "", line); \
141           sub("[        ]*$$", "", line); \
142           global_test_result = line; \
143         } \
144       else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \
145         copy_in_global_log = 0; \
146     }; \
147   if (copy_in_global_log) \
148     { \
149       rst_section(global_test_result ": " $$0); \
150       while ((rc = (getline line < ($$0 ".log"))) != 0) \
151       { \
152         if (rc < 0) \
153           fatal("failed to read from " $$0 ".log"); \
154         print line; \
155       }; \
156       printf "\n"; \
157     }; \
158 ## Don't leak open file descriptors, as this could cause serious
159 ## problems when there are many tests (yes, even on Linux).
160   close ($$0 ".trs"); \
161   close ($$0 ".log"); \
164 # Restructured Text title.
165 am__rst_title = { sed 's/.*/   &   /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
167 # Solaris 10 'make', and several other traditional 'make' implementations,
168 # pass "-e" to $(SHELL), and POSIX 2008 even requires this.  Work around it
169 # by disabling -e (using the XSI extension "set +e") if it's set.
170 am__sh_e_setup = case $$- in *e*) set +e;; esac
172 # Default flags passed to test drivers.
173 am__common_driver_flags = \
174   --color-tests "$$am__color_tests" \
175   --enable-hard-errors "$$am__enable_hard_errors" \
176   --expect-failure "$$am__expect_failure"
178 # To be inserted before the command running the test.  Creates the
179 # directory for the log if needed.  Stores in $dir the directory
180 # containing $f, in $tst the test, in $log the log.  Executes the
181 # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
182 # passes TESTS_ENVIRONMENT.  Set up options for the wrapper that
183 # will run the test scripts (or their associated LOG_COMPILER, if
184 # thy have one).
185 am__check_pre =                                         \
186 $(am__sh_e_setup);                                      \
187 $(am__vpath_adj_setup) $(am__vpath_adj)                 \
188 $(am__tty_colors);                                      \
189 srcdir=$(srcdir); export srcdir;                        \
190 case "$@" in                                            \
191   */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;;    \
192     *) am__odir=.;;                                     \
193 esac;                                                   \
194 test "x$$am__odir" = x"." || test -d "$$am__odir"       \
195   || $(MKDIR_P) "$$am__odir" || exit $$?;               \
196 if test -f "./$$f"; then dir=./;                        \
197 elif test -f "$$f"; then dir=;                          \
198 else dir="$(srcdir)/"; fi;                              \
199 tst=$$dir$$f; log='$@';                                 \
200 if test -n '$(DISABLE_HARD_ERRORS)'; then               \
201   am__enable_hard_errors=no;                            \
202 else                                                    \
203   am__enable_hard_errors=yes;                           \
204 fi;                                                     \
205 ## The use of $dir below is required to account for VPATH
206 ## rewriting done by Sun make.
207 case " $(XFAIL_TESTS) " in                              \
208   *[\ \ ]$$f[\ \        ]* | *[\ \      ]$$dir$$f[\ \   ]*) \
209     am__expect_failure=yes;;                            \
210   *)                                                    \
211     am__expect_failure=no;;                             \
212 esac;                                                   \
213 $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
215 # A shell command to get the names of the tests scripts with any registered
216 # extension removed (i.e., equivalently, the names of the test logs, with
217 # the '.log' extension removed).  The result is saved in the shell variable
218 # '$bases'.  This honors runtime overriding of TESTS and TEST_LOGS.  Sadly,
219 # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)",
220 # since that might cause problem with VPATH rewrites for suffix-less tests.
221 # See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'.
222 am__set_TESTS_bases = \
223   bases='$(TEST_LOGS)'; \
224   bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
225 ## Trim away any extra whitespace.  This has already proved useful
226 ## in avoiding weird bug on lesser make implementations.  It also
227 ## works around the GNU make 3.80 bug where trailing whitespace in
228 ## "TESTS = foo.test $(empty)" causes $(TESTS_LOGS)  to erroneously
229 ## expand to "foo.log .log".
230   bases=`echo $$bases`
232 # Recover from deleted '.trs' file; this should ensure that
233 # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create
234 # both 'foo.log' and 'foo.trs'.  Break the recipe in two subshells
235 # to avoid problems with "make -n".
236 .log.trs:
237         rm -f $< $@
238         $(MAKE) $(AM_MAKEFLAGS) $<
240 # Leading 'am--fnord' is there to ensure the list of targets does not
241 # expand to empty, as could happen e.g. with make check TESTS=''.
242 am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck)
243 am--force-recheck:
244         @:
246 $(TEST_SUITE_LOG): $(TEST_LOGS)
247         @$(am__set_TESTS_bases); \
248 ## Helper shell function, tells whether a path refers to an existing,
249 ## regular, readable file.
250         am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
251 ## We need to ensures that all the required '.trs' and '.log' files will
252 ## be present and readable.  The direct dependencies of $(TEST_SUITE_LOG)
253 ## only ensure that all the '.log' files exists; they don't ensure that
254 ## the '.log' files are readable, and worse, they don't ensure that the
255 ## '.trs' files even exist.
256         redo_bases=`for i in $$bases; do \
257                       am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
258                     done`; \
259         if test -n "$$redo_bases"; then \
260 ## Uh-oh, either some '.log' files were unreadable, or some '.trs' files
261 ## were missing (or unreadable).  We need to re-run the corresponding
262 ## tests in order to re-create them.
263           redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
264           redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
265           if $(am__make_dryrun); then :; else \
266 ## Break "rm -f" into two calls to minimize the possibility of exceeding
267 ## command line length limits.
268             rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
269           fi; \
270         fi; \
271 ## Use a trick to to ensure that we don't go into an infinite recursion
272 ## in case a test log in $(TEST_LOGS) is the same as $(TEST_SUITE_LOG).
273 ## Yes, this has already happened in practice.  Sigh!
274         if test -n "$$am__remaking_logs"; then \
275           echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
276                "recursion detected" >&2; \
277 ## Invoking this unconditionally could cause a useless "make all" to
278 ## be invoked when '$redo_logs' expands to empty (automake bug#16302).
279         elif test -n "$$redo_logs"; then \
280           am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
281         fi; \
282         if $(am__make_dryrun); then :; else \
283 ## Sanity check: each unreadable or non-existent test result file should
284 ## has been properly remade at this point, as should the corresponding log
285 ## file.
286           st=0;  \
287           errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
288           for i in $$redo_bases; do \
289             test -f $$i.trs && test -r $$i.trs \
290               || { echo "$$errmsg $$i.trs" >&2; st=1; }; \
291             test -f $$i.log && test -r $$i.log \
292               || { echo "$$errmsg $$i.log" >&2; st=1; }; \
293           done; \
294           test $$st -eq 0 || exit 1; \
295         fi
296 ## We need a new subshell to work portably with "make -n", since the
297 ## previous part of the recipe contained a $(MAKE) invocation.
298         @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
299         ws='[   ]'; \
300 ## List of test result files.
301         results=`for b in $$bases; do echo $$b.trs; done`; \
302         test -n "$$results" || results=/dev/null; \
303 ## Prepare data for the test suite summary.  These do not take into account
304 ## unreadable test results, but they'll be appropriately updated later if
305 ## needed.
306         all=`  grep "^$$ws*:test-result:"           $$results | wc -l`; \
307         pass=` grep "^$$ws*:test-result:$$ws*PASS"  $$results | wc -l`; \
308         fail=` grep "^$$ws*:test-result:$$ws*FAIL"  $$results | wc -l`; \
309         skip=` grep "^$$ws*:test-result:$$ws*SKIP"  $$results | wc -l`; \
310         xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
311         xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
312         error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
313 ## Whether the testsuite was successful or not.
314         if test `expr $$fail + $$xpass + $$error` -eq 0; then \
315           success=true; \
316         else \
317           success=false; \
318         fi; \
319 ## Make $br a line of exactly 76 '=' characters, that will be used to
320 ## enclose the testsuite summary report when displayed on the console.
321         br='==================='; br=$$br$$br$$br$$br; \
322 ## When writing the test summary to the console, we want to color a line
323 ## reporting the count of some result *only* if at least one test
324 ## experienced such a result.  This function is handy in this regard.
325         result_count () \
326         { \
327             if test x"$$1" = x"--maybe-color"; then \
328               maybe_colorize=yes; \
329             elif test x"$$1" = x"--no-color"; then \
330               maybe_colorize=no; \
331             else \
332               echo "$@: invalid 'result_count' usage" >&2; exit 4; \
333             fi; \
334             shift; \
335             desc=$$1 count=$$2; \
336             if test $$maybe_colorize = yes && test $$count -gt 0; then \
337               color_start=$$3 color_end=$$std; \
338             else \
339               color_start= color_end=; \
340             fi; \
341             echo "$${color_start}# $$desc $$count$${color_end}"; \
342         }; \
343 ## A shell function that creates the testsuite summary.  We need it
344 ## because we have to create *two* summaries, one for test-suite.log,
345 ## and a possibly-colorized one for console output.
346         create_testsuite_report () \
347         { \
348           result_count $$1 "TOTAL:" $$all   "$$brg"; \
349           result_count $$1 "PASS: " $$pass  "$$grn"; \
350           result_count $$1 "SKIP: " $$skip  "$$blu"; \
351           result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
352           result_count $$1 "FAIL: " $$fail  "$$red"; \
353           result_count $$1 "XPASS:" $$xpass "$$red"; \
354           result_count $$1 "ERROR:" $$error "$$mgn"; \
355         }; \
356 ## Write "global" testsuite log.
357         {                                                               \
358           echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" |       \
359             $(am__rst_title);                                           \
360           create_testsuite_report --no-color;                           \
361           echo;                                                         \
362           echo ".. contents:: :depth: 2";                               \
363           echo;                                                         \
364           for b in $$bases; do echo $$b; done                           \
365             | $(am__create_global_log);                                 \
366         } >$(TEST_SUITE_LOG).tmp || exit 1;                             \
367         mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG);                     \
368 ## Emit the test summary on the console.
369         if $$success; then                                              \
370           col="$$grn";                                                  \
371          else                                                           \
372           col="$$red";                                                  \
373           test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG);               \
374         fi;                                                             \
375 ## Multi line coloring is problematic with "less -R", so we really need
376 ## to color each line individually.
377         echo "$${col}$$br$${std}";                                      \
378         echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}";   \
379         echo "$${col}$$br$${std}";                                      \
380 ## This is expected to go to the console, so it might have to be colorized.
381         create_testsuite_report --maybe-color;                          \
382         echo "$$col$$br$$std";                                          \
383         if $$success; then :; else                                      \
384           echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}";         \
385           if test -n "$(PACKAGE_BUGREPORT)"; then                       \
386             echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
387           fi;                                                           \
388           echo "$$col$$br$$std";                                        \
389         fi;                                                             \
390 ## Be sure to exit with the proper exit status.  The use of "exit 1" below
391 ## is required to work around a FreeBSD make bug (present only when running
392 ## in concurrent mode).  See automake bug#9245:
393 ##  <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=9245>
394 ## and FreeBSD PR bin/159730:
395 ##  <http://www.freebsd.org/cgi/query-pr.cgi?pr=159730>.
396         $$success || exit 1
398 RECHECK_LOGS = $(TEST_LOGS)
400 ## ------------------------------------------ ##
401 ## Running all tests, or rechecking failures. ##
402 ## ------------------------------------------ ##
404 check-TESTS: %CHECK_DEPS%
405         @list='$(RECHECK_LOGS)';           test -z "$$list" || rm -f $$list
406         @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
407 ## We always have to remove $(TEST_SUITE_LOG), to ensure its rule is run
408 ## in any case even in lazy mode: otherwise, if no test needs rerunning,
409 ## or a prior run plus reruns all happen within the same timestamp (can
410 ## happen with a prior "make TESTS=<subset>"), then we get no log output.
411 ## OTOH, this means that, in the rule for '$(TEST_SUITE_LOG)', we
412 ## cannot use '$?' to compute the set of lazily rerun tests, lest
413 ## we rely on .PHONY to work portably.
414         @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
415         @set +e; $(am__set_TESTS_bases); \
416         log_list=`for i in $$bases; do echo $$i.log; done`; \
417         trs_list=`for i in $$bases; do echo $$i.trs; done`; \
418 ## Remove newlines and normalize whitespace.  Trailing (and possibly
419 ## leading) whitespace is known to cause segmentation faults on
420 ## Solaris 10 XPG4 make.
421         log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
422         $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \
423 ## Be sure to exit with the proper exit status (automake bug#9245).  See
424 ## comments in the recipe of $(TEST_SUITE_LOG) above for more information.
425         exit $$?;
427 ## Recheck must depend on $(check_SCRIPTS), $(check_PROGRAMS), etc.
428 ## It must also depend on the 'all' target.  See automake bug#11252.
429 recheck: all %CHECK_DEPS%
430 ## See comments above in the check-TESTS recipe for why remove
431 ## $(TEST_SUITE_LOG) here.
432         @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
433         @set +e; $(am__set_TESTS_bases); \
434 ## We must only consider tests that had an unexpected outcome (FAIL
435 ## or XPASS) in the earlier run.
436         bases=`for i in $$bases; do echo $$i; done \
437                  | $(am__list_recheck_tests)` || exit 1; \
438         log_list=`for i in $$bases; do echo $$i.log; done`; \
439 ## Remove newlines and normalize whitespace.  Trailing (and possibly
440 ## leading) whitespace is known to cause segmentation faults on
441 ## Solaris 10 XPG4 make.
442         log_list=`echo $$log_list`; \
443 ## Move the '.log' and '.trs' files associated with the tests to be
444 ## re-run out of the way, so that those tests will be re-run by the
445 ## "make test-suite.log" recursive invocation below.
446 ## Two tricky requirements:
447 ##   - we must avoid extra files removal when running under "make -n";
448 ##   - in case the test is a compiled program whose compilation fails,
449 ##     we must ensure that any '.log' and '.trs' file referring to such
450 ##     test are preserved, so that future "make recheck" invocations
451 ##     will still try to re-compile and re-run it (automake bug#11791).
452 ## The tricky recursive make invocation below should cater to such
453 ## requirements.
454         $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \
455                 am__force_recheck=am--force-recheck \
456                 TEST_LOGS="$$log_list"; \
457 ## Be sure to exit with the proper exit status (automake bug#9245).  See
458 ## comments in the recipe of $(TEST_SUITE_LOG) above for more information.
459         exit $$?
461 AM_RECURSIVE_TARGETS += check recheck
463 .PHONY: recheck
465 else %?SERIAL_TESTS%
467 ## Obsolescent serial testsuite driver.
469 check-TESTS: $(TESTS)
470         @failed=0; all=0; xfail=0; xpass=0; skip=0; \
471         srcdir=$(srcdir); export srcdir; \
472 ## Make sure Solaris VPATH-expands all members of this list, even
473 ## the first and the last one; thus the spaces around $(TESTS)
474         list=' $(TESTS) '; \
475         $(am__tty_colors); \
476         if test -n "$$list"; then \
477           for tst in $$list; do \
478             if test -f ./$$tst; then dir=./; \
479 ## Note: Solaris 2.7 seems to expand TESTS using VPATH.  That's
480 ## why we also try 'dir='.
481             elif test -f $$tst; then dir=; \
482             else dir="$(srcdir)/"; fi; \
483             if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \
484 ## Success
485               all=`expr $$all + 1`; \
486               case " $(XFAIL_TESTS) " in \
487               *[\ \     ]$$tst[\ \      ]*) \
488                 xpass=`expr $$xpass + 1`; \
489                 failed=`expr $$failed + 1`; \
490                 col=$$red; res=XPASS; \
491               ;; \
492               *) \
493                 col=$$grn; res=PASS; \
494               ;; \
495               esac; \
496             elif test $$? -ne 77; then \
497 ## Failure
498               all=`expr $$all + 1`; \
499               case " $(XFAIL_TESTS) " in \
500               *[\ \     ]$$tst[\ \      ]*) \
501                 xfail=`expr $$xfail + 1`; \
502                 col=$$lgn; res=XFAIL; \
503               ;; \
504               *) \
505                 failed=`expr $$failed + 1`; \
506                 col=$$red; res=FAIL; \
507               ;; \
508               esac; \
509             else \
510 ## Skipped
511               skip=`expr $$skip + 1`; \
512               col=$$blu; res=SKIP; \
513             fi; \
514             echo "$${col}$$res$${std}: $$tst"; \
515           done; \
516 ## Prepare the banner
517           if test "$$all" -eq 1; then \
518             tests="test"; \
519             All=""; \
520           else \
521             tests="tests"; \
522             All="All "; \
523           fi; \
524           if test "$$failed" -eq 0; then \
525             if test "$$xfail" -eq 0; then \
526               banner="$$All$$all $$tests passed"; \
527             else \
528               if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
529               banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
530             fi; \
531           else \
532             if test "$$xpass" -eq 0; then \
533               banner="$$failed of $$all $$tests failed"; \
534             else \
535               if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
536               banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
537             fi; \
538           fi; \
539 ## DASHES should contain the largest line of the banner.
540           dashes="$$banner"; \
541           skipped=""; \
542           if test "$$skip" -ne 0; then \
543             if test "$$skip" -eq 1; then \
544               skipped="($$skip test was not run)"; \
545             else \
546               skipped="($$skip tests were not run)"; \
547             fi; \
548             test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
549               dashes="$$skipped"; \
550           fi; \
551           report=""; \
552           if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
553             report="Please report to $(PACKAGE_BUGREPORT)"; \
554             test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
555               dashes="$$report"; \
556           fi; \
557           dashes=`echo "$$dashes" | sed s/./=/g`; \
558           if test "$$failed" -eq 0; then \
559             col="$$grn"; \
560           else \
561             col="$$red"; \
562           fi; \
563 ## Multi line coloring is problematic with "less -R", so we really need
564 ## to color each line individually.
565           echo "$${col}$$dashes$${std}"; \
566           echo "$${col}$$banner$${std}"; \
567           test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \
568           test -z "$$report" || echo "$${col}$$report$${std}"; \
569           echo "$${col}$$dashes$${std}"; \
570           test "$$failed" -eq 0; \
571         else :; fi
573 endif %?SERIAL_TESTS%