* lib/am/check.am (am__rst_section): Tweak to ensure en extra final newline is printed also with NetBSD sed. Issue revealed by a failure of 'test-metadata-global-result.test'. * tests/rst-formatting.test: New test, checking the internal variables '$(am__rst_title)' and '$(am__rst_section)'. * tests/list-of-tests.mk: Add it. --- lib/am/check.am | 4 +- tests/list-of-tests.mk | 1 + tests/rst-formatting.test | 93 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 2 deletions(-) create mode 100755 tests/rst-formatting.test
diff --git a/lib/am/check.am b/lib/am/check.am index 777cb6f..bd9f5c2 100644 --- a/lib/am/check.am +++ b/lib/am/check.am @@ -57,8 +57,8 @@ include inst-vars.am ## (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__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } +am__rst_section = { sed 'p;s/./=/g;' && echo; } # Solaris 10 'make', and several other traditional 'make' implementations, # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it diff --git a/tests/list-of-tests.mk b/tests/list-of-tests.mk index d2ad678..c726bde 100644 --- a/tests/list-of-tests.mk +++ b/tests/list-of-tests.mk @@ -880,6 +880,7 @@ req.test \ reqd.test \ reqd2.test \ repeated-options.test \ +rst-formatting.test \ rulepat.test \ self-check-cleanup.tap \ self-check-configure-help.test \ diff --git a/tests/rst-formatting.test b/tests/rst-formatting.test new file mode 100755 index 0000000..ad80aff --- /dev/null +++ b/tests/rst-formatting.test @@ -0,0 +1,93 @@ +#! /bin/sh +# Copyright (C) 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 +# 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 <http://www.gnu.org/licenses/>. + +# Parallel testsuite harness: check APIs for the registering the +# "global test result" in `*.trs' files, as documented in the automake +# manual. + +am_create_testdir=empty +. ./defs || Exit 1 + +sed -n '/^am__rst_[a-z_][a-z_]* =/p' "$am_amdir"/check.am > Makefile \ + || framework_failure_ "fetching definitions from check.am" + +cat >> Makefile << 'END' +test: + printf '%s\n' "$$in" | $(am__rst_title) > title-got + printf '%s\n' "$$in" | $(am__rst_section) > section-got + cat title-exp + cat title-got + diff title-exp title-got + cat section-exp + cat section-got + diff section-exp section-got +END + +# ------------------------------------------------------------------------- + +cat > title-exp <<'END' +============== + ab cd ef +============== + +END + +cat > section-exp <<'END' +ab cd ef +======== + +END + +env in='ab cd ef' $MAKE test + +# ------------------------------------------------------------------------- + +cat > title-exp <<'END' +============================================================================ + 0123456789012345678901234567890123456789012345678901234567890123456789 +============================================================================ + +END + +cat > section-exp <<'END' +0123456789012345678901234567890123456789012345678901234567890123456789 +====================================================================== + +END + +in=0123456789012345678901234567890123456789012345678901234567890123456789 +env in=$in $MAKE test + +# ------------------------------------------------------------------------- + +cat > title-exp <<'END' +======= + x +======= + +END + +cat > section-exp <<'END' +x += + +END + +env in=x $MAKE test + +# ------------------------------------------------------------------------- + +: -- 1.7.7.3