]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
automake: support AM_TESTSUITE_SUMMARY_HEADER override.
authorKarl Berry <karl@freefriends.org>
Sat, 6 Jun 2020 22:42:54 +0000 (15:42 -0700)
committerKarl Berry <karl@freefriends.org>
Sat, 6 Jun 2020 22:42:54 +0000 (15:42 -0700)
This change handles https://bugs.gnu.org/11745.

* lib/am/check.am (AM_TESTSUITE_SUMMARY_HEADER): new variable.
Default value is " for $(PACKAGE_STRING)", including quotes,
to keep the default output the same.
($(TEST_SUITE_LOG)): use it, unquoted.
* doc/automake.texi (Scripts-based Testsuites): document it.
* NEWS: mention it.
* t/testsuite-summary-header.sh: new test.
* t/list-of-tests.mk (handwritten_tests): add it.
* t/ax/testsuite-summary-checks.sh: fix typo.

NEWS
doc/automake.texi
lib/am/check.am
t/ax/testsuite-summary-checks.sh
t/list-of-tests.mk
t/testsuite-summary-header.sh [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 8650db050817c68fb72cb70b0e1c4d9152cb0e3a..f36011c87da97b6e55ab327c367c85fade46aed1 100644 (file)
--- a/NEWS
+++ b/NEWS
 
 New in ?.?.?:
 
+* New features added
+
+  - In the testsuite summary, the "for $(PACKAGE_STRING)" suffix
+    can be overridden with the AM_TESTSUITE_SUMMARY_HEADER variable.
+
 * Bugs fixed
 
   - Broken links in manual fixed or removed, and new script
index 232721e110842995d787e8ba109f25391810b59f..3a6c1815d2352477273e25c0b2f55829e25fc078 100644 (file)
@@ -8940,7 +8940,7 @@ implementation, and can thus only be as good as those are.
 By default, only the exit statuses of the test scripts are considered when
 determining the testsuite outcome.  But Automake allows also the use of
 more complex test protocols, either standard (@pxref{Using the TAP test
-protocol}) or custom (@pxref{Custom Test Drivers}).  Note that you can't
+protocol}) or custom (@pxref{Custom Test Drivers}).  You can't
 enable such protocols when the serial harness is used, though.
 In the rest of this section we are going to concentrate mostly on
 protocol-less tests, since we cover test protocols in a later section
@@ -8998,7 +8998,34 @@ XFAIL: mu.tap 2 # TODO frobnication not yet implemented
 @noindent
 A testsuite summary (expected to report at least the number of run,
 skipped and failed tests) will be printed at the end of the testsuite
-run.
+run.  By default, the first line of the summary has the form:
+
+@example
+Testsuite summary for @var{package-string}
+@end example
+
+@c See automake bug#11745.
+@vindex AM_TESTSUITE_SUMMARY_HEADER
+@noindent
+where @var{package-string} is the name and version of the package.  If
+you have several independent test suites for different parts of the
+package, though, it can be misleading for each suite to imply it is
+for the whole package.  Or, in complex projects, you may wish to add
+the current directory or other information to the testsuite header
+line.  So you can override the @samp{ for @var{package-string}} suffix
+on that line by setting the @code{AM_TESTSUITE_SUMMARY_HEADER}
+variable.  The value of this variable is used unquoted in a shell echo
+command, so you must include any necessary quotes.  For example, the
+default value is
+
+@example
+AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)'
+@end example
+
+@noindent
+including the double quotes (interpreted by the shell) and the leading
+space (since the value is output directly after the @samp{Testsuite
+summary}).  The @code{$(PACKAGE_STRING)} is substituted by @code{make}.
 
 @anchor{Simple tests and color-tests}
 @vindex AM_COLOR_TESTS
index 1c7e9528893ef29fda2bc21d63a1aae0181832f0..4497087428c5fa1160e4a6222831fbb4f9650746 100644 (file)
@@ -243,6 +243,9 @@ am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck)
 am--force-recheck:
        @:
 
+## Exists only to be overridden.  See bug#11745.
+AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)'
+
 $(TEST_SUITE_LOG): $(TEST_LOGS)
        @$(am__set_TESTS_bases); \
 ## Helper shell function, tells whether a path refers to an existing,
@@ -375,7 +378,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
 ## Multi line coloring is problematic with "less -R", so we really need
 ## to color each line individually.
        echo "$${col}$$br$${std}";                                      \
-       echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}";   \
+       echo "$${col}Testsuite summary"$(AM_TESTSUITE_SUMMARY_HEADER)"$${std}"; \
        echo "$${col}$$br$${std}";                                      \
 ## This is expected to go to the console, so it might have to be colorized.
        create_testsuite_report --maybe-color;                          \
index 30dba756063df4ae2ced4258d423d041a59c0e20..0b5967a4895668d6a6c3d01cc1ff818da4a60c6b 100644 (file)
@@ -15,7 +15,7 @@
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 # Check the testsuite summary with the parallel test harness.  This
-# script is meant to be sourced by other test script, so that it can
+# script is meant to be sourced by other test scripts, so that it can
 # be used to check different scenarios (colorized and non-colorized
 # testsuite output, packages with and without bug-report addresses,
 # testsuites in subdirectories, ...)
index 43ea245a9072c38254224ae7ade92d62cae13360..16083137d069db84b015c35ebdb614d701e2c910 100644 (file)
@@ -817,6 +817,7 @@ t/tests-environment-backcompat.sh \
 t/testsuite-summary-color.sh \
 t/testsuite-summary-count.sh \
 t/testsuite-summary-count-many.sh \
+t/testsuite-summary-header.sh \
 t/testsuite-summary-reference-log.sh \
 t/test-driver-acsubst.sh \
 t/test-driver-cond.sh \
diff --git a/t/testsuite-summary-header.sh b/t/testsuite-summary-header.sh
new file mode 100644 (file)
index 0000000..f194086
--- /dev/null
@@ -0,0 +1,91 @@
+#! /bin/sh
+# Copyright (C) 2011-2020 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+# Check that we can override the "Testsuite summary" header line,
+# per bug#11745.
+
+. test-lib.sh
+
+use_colors=no; use_vpath=no
+. testsuite-summary-checks.sh
+
+./configure
+
+# Cut down from do_check in ax/testsuite-summary-checks.sh
+# so that we can pass a make variable setting in $1.
+#
+do_header_check ()
+{
+  cat > summary.exp
+  run_make -O -e IGNORE check "$1"
+  test $am_make_rc -eq 0 || exit 1
+  $PERL "$am_testaux_srcdir"/extract-testsuite-summary.pl stdout >summary.got \
+   || fatal_ "cannot extract testsuite summary"
+  cat summary.exp
+  cat summary.got
+  compare=diff
+  $compare summary.exp summary.got || exit 1
+}
+
+# We don't actually run any tests, only interested in the header line.
+results="\
+# TOTAL: 0
+# PASS:  0
+# SKIP:  0
+# XFAIL: 0
+# FAIL:  0
+# XPASS: 0
+# ERROR: 0"
+#
+success_footer=${br}
+
+# Check the default.
+header="\
+${br}
+Testsuite summary for GNU AutoFoo 7.1
+${br}"
+#
+do_header_check 'junkvar=junkval' <<END
+$header
+$results
+$success_footer
+END
+
+# Elide the "for $(PACKAGE_STRING)".
+header_min="\
+${br}
+Testsuite summary
+${br}"
+#
+do_header_check 'AM_TESTSUITE_SUMMARY_HEADER=""' <<END
+$header_min
+$results
+$success_footer
+END
+
+# Add a suffix.
+header_more="\
+${br}
+Testsuite summary for GNU AutoFoo 7.1 (hi)
+${br}"
+#
+do_header_check 'AM_TESTSUITE_SUMMARY_HEADER=" for $(PACKAGE_STRING) (hi)"' <<END
+$header_more
+$results
+$success_footer
+END
+
+: