Merge branch 'maint'
authorStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 22 Jun 2012 22:16:26 +0000 (00:16 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 22 Jun 2012 22:16:26 +0000 (00:16 +0200)
* maint:
  tests: avoid one last `...` command substitution in 'test-init.sh'
  maintcheck: guard against `...` for command substitution in test cases
  tests: more uses of $(...) over `...` for command substitution
  cosmetics: quote `like this', not 'like this', in a couple of tests
  readme: clarify/extend few entries in 't/README'
  readme: better separation of entries in 't/README'
  readme: subsections "Do" and "Do not" in 't/README' merged
  tests: new requirement 'grep-nonprint'
  cosmetics: fix description of an expected error message in a test
  tests: assume automake quotes 'like this', not `like this'

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
1  2 
syntax-checks.mk
t/ax/tap-summary-aux.sh
t/ax/test-init.sh
t/parallel-tests-no-color-in-log.sh
t/parallel-tests-reset-term.sh
t/vtexi4.sh

diff --combined syntax-checks.mk
@@@ -39,6 -39,7 +39,6 @@@ ams := $(shell find $(srcdir) -name '*.
  # guaranteed to work on my machine.
  syntax_check_rules = \
  $(sc_tests_plain_check_rules) \
 -sc_test_names \
  sc_diff_automake_in_automake \
  sc_diff_aclocal_in_automake \
  sc_perl_syntax \
@@@ -55,9 -56,9 +55,10 @@@ sc_perl_at_uscore_in_scalar_context 
  sc_perl_local \
  sc_AMDEP_TRUE_in_automake_in \
  sc_tests_make_without_am_makeflags \
 +$(sc_obsolete_requirements_rules) \
  sc_tests_obsolete_variables \
  sc_tests_here_document_format \
+ sc_tests_command_subst \
  sc_tests_Exit_not_exit \
  sc_tests_automake_fails \
  sc_tests_required_after_defs \
@@@ -74,6 -75,69 +75,6 @@@ sc_unquoted_DESTDIR 
  sc_tabs_in_texi \
  sc_at_in_texi
  
 -## Look for test whose names can cause spurious failures when used as
 -## first argument to AC_INIT (chiefly because they might contain an
 -## m4/m4sugar builtin or macro name).
 -m4_builtins = \
 -  __gnu__ \
 -  __unix__ \
 -  bpatsubst \
 -  bregexp \
 -  builtin \
 -  changecom \
 -  changequote \
 -  changeword \
 -  debugfile \
 -  debugmode \
 -  decr \
 -  define \
 -  defn \
 -  divert \
 -  divnum \
 -  dnl \
 -  dumpdef \
 -  errprint \
 -  esyscmd \
 -  eval \
 -  format \
 -  ifdef \
 -  ifelse \
 -  include \
 -  incr \
 -  index \
 -  indir \
 -  len \
 -  m4exit \
 -  m4wrap \
 -  maketemp \
 -  mkstemp \
 -  patsubst \
 -  popdef \
 -  pushdef \
 -  regexp \
 -  shift \
 -  sinclude \
 -  substr \
 -  symbols \
 -  syscmd \
 -  sysval \
 -  traceoff \
 -  traceon \
 -  translit \
 -  undefine \
 -  undivert
 -sc_test_names:
 -      @m4_builtin_rx=`echo $(m4_builtins) | sed 's/ /|/g'`; \
 -       m4_macro_rx="\\<($$m4_builtin_rx)\\>|\\<_?(A[CUMHS]|m4)_"; \
 -       if { \
 -         for t in $(xtests); do echo $$t; done \
 -           | LC_ALL=C grep -E "$$m4_macro_rx"; \
 -       }; then \
 -         echo "the names of the tests above can be problematic" 1>&2; \
 -         echo "Avoid test names that contain names of m4 macros" 1>&2; \
 -         exit 1; \
 -       fi
 -
  ## These check avoids accidental configure substitutions in the source.
  ## There are exactly 9 lines that should be modified from automake.in to
  ## automake, and 10 lines that should be modified from aclocal.in to
@@@ -238,19 -302,6 +239,19 @@@ sc_tests_obsolete_variables
          exit 1; \
        else :; fi
  
 +## Look out for obsolete requirements specified in the test cases.
 +sc_obsolete_requirements_rules = sc_no_texi2dvi-o sc_no_makeinfo-html
 +modern-requirement.texi2dvi-o = texi2dvi
 +modern-requirement.makeinfo-html = makeinfo
 +
 +$(sc_obsolete_requirements_rules): sc_no_% :
 +      @if grep -E 'required=.*\b$*\b' $(xtests); then \
 +        echo "Requirement '$*' is obsolete and shouldn't" \
 +             "be used anymore." >&2; \
 +        echo "You should use '$(modern-requirement.$*)' instead." >&2; \
 +        exit 1; \
 +      fi
 +
  ## Tests should never call some programs directly, but only through the
  ## corresponding variable (e.g., '$MAKE', not 'make').  This will allow
  ## the programs to be overridden at configure time (for less brittleness)
@@@ -291,6 -342,33 +292,33 @@@ sc_tests_here_document_format
          exit 1; \
        fi
  
+ ## Our test case should use the $(...) POSIX form for command substitution,
+ ## rather than the older `...` form.
+ ## The point of ignoring text on here-documents is that we want to exempt
+ ## Makefile.am rules, configure.ac code and helper shell script created and
+ ## used by out shell scripts, because Autoconf (as of version 2.69) does not
+ ## yet ensure that $CONFIG_SHELL will be set to a proper POSIX shell.
+ sc_tests_command_subst:
+       @found=false; \
+       scan () { \
+         sed -n -e '/^#/d' \
+                -e '/<<.*END/,/^END/b' -e '/<<.*EOF/,/^EOF/b' \
+                -e 's/\\`/\\{backtick}/' \
+                -e "s/[^\\]'\([^']*\`[^']*\)*'/'{quoted-text}'/g" \
+                -e '/`/p' $$*; \
+       }; \
+       for file in $(xtests); do \
+         res=`scan $$file`; \
+         if test -n "$$res"; then \
+           echo "$$file:$$res"; \
+           found=true; \
+         fi; \
+       done; \
+       if $$found; then \
+         echo 'Use $$(...), not `...`, for command substitutions.' >&2; \
+         exit 1; \
+       fi
  ## Tests should never call exit directly, but use Exit.
  ## This is so that the exit status is transported correctly across the 0 trap.
  ## Ignore comments and our testsuite's own self tests.
diff --combined t/ax/tap-summary-aux.sh
@@@ -29,7 -29,7 +29,7 @@@ fetch_tap_drive
  
  cat > configure.ac <<END
  AC_INIT([GNU AutoTAP], [5.12], [bug-automake@gnu.org])
 -AM_INIT_AUTOMAKE([parallel-tests])
 +AM_INIT_AUTOMAKE
  AC_CONFIG_FILES([Makefile])
  AC_OUTPUT
  END
@@@ -82,13 -82,13 +82,13 @@@ do_check (
  }
  
  if test $use_colors = yes; then
-   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'
+   red="$esc[0;31m"
+   grn="$esc[0;32m"
+   lgn="$esc[1;32m"
+   blu="$esc[1;34m"
+   mgn="$esc[0;35m"
+   brg="$esc[1m"
+   std="$esc[m"
    echo AUTOMAKE_OPTIONS = color-tests >> Makefile.am
  else
    red= grn= lgn= blu= mgn= brg= std=
diff --combined t/ax/test-init.sh
@@@ -26,10 -26,13 +26,13 @@@ set -
  # Test scripts can override it if they need to (but this should
  # be done carefully).
  if test -z "$me"; then
-   # Guard against failure to spawn sed (seen on MSYS), or empty $argv0.
-   me=`echo "$argv0" | sed -e 's,.*[\\/],,;s/\.sh$//;s/\.tap$//'` \
-     && test -n "$me" \
-     || { echo "$argv0: failed to define \$me" >&2; exit 99; }
+   # Strip all directory components.
+   me=${argv0##*/}
+   # Strip test suffix.
+   case $me in
+     *.tap) me=${me%.tap};;
+      *.sh) me=${me%.sh} ;;
+   esac
  fi
  
  
@@@ -63,6 -66,8 +66,8 @@@ tab=' 
  # A newline character.
  nl='
  '
+ # A literal escape character.  Used by test checking colored output.
+ esc='\e'
  
  # As autoconf-generated configure scripts do, ensure that IFS
  # is defined initially, so that saving and restoring $IFS works.
          *) FC=$F77 FCFLAGS=$FFLAGS; export FC FCFLAGS;;
        esac
        ;;
+     grep-nonprint)
+       # Check that grep can parse nonprinting characters correctly.
+       # BSD 'grep' works from a pipe, but not a seekable file.
+       # GNU or BSD 'grep -a' works on files, but is not portable.
+       case $(echo "$esc" | grep .)$(echo "$esc" | grep "$esc") in
+         "$esc$esc") ;;
+         *) skip_ "grep can't handle nonprinting characters correctly";;
+       esac
+       ;;
      javac)
        # The Java compiler from JDK 1.5 (and presumably earlier versions)
        # cannot handle the '-version' option by itself: it bails out
        makedepend -f- \
          || skip_all_ "required program 'makedepend' not available"
        ;;
 -    makeinfo-html)
 -      # Make sure we have makeinfo, and it understands '--html'.
 -      echo "$me: running makeinfo --html --version"
 -      makeinfo --html --version \
 -        || skip_all_ "cannot find a makeinfo program that groks" \
 -                     "the '--html' option"
 -      ;;
      mingw)
        uname_s=$(uname -s || echo UNKNOWN)
        echo "$me: system name: $uname_s"
          skip_all_ "TeX is required, but it wasn't found by configure"
        fi
        ;;
 -    texi2dvi-o)
 -      # Texi2dvi supports '-o' since Texinfo 4.1.
 -      echo "$me: running texi2dvi -o /dev/null --version"
 -      texi2dvi -o /dev/null --version \
 -        || skip_all_ "required program 'texi2dvi' not available"
 -      ;;
      lex)
        test x"$LEX" = x"false" && skip_all_ "lex not found or disabled"
        export LEX
@@@ -1011,9 -1038,9 +1025,9 @@@ els
      {
        echo "AC_INIT([$me], [1.0])"
        if test x"$am_serial_tests" = x"yes"; then
 -        echo "AM_INIT_AUTOMAKE"
 +        echo "AM_INIT_AUTOMAKE([serial-tests])"
        else
 -        echo "AM_INIT_AUTOMAKE([parallel-tests])"
 +        echo "AM_INIT_AUTOMAKE"
        fi
        echo "AC_CONFIG_FILES([Makefile])"
      } >configure.ac || framework_failure_ "creating configure.ac skeleton"
  
  # Colorized output from the testsuite report shouldn't end up in log files.
  
+ required='grep-nonprint'
  . ./defs || Exit 1
  
- esc='\e'
- # Check that grep can parse nonprinting characters.
- # BSD 'grep' works from a pipe, but not a seekable file.
- # GNU or BSD 'grep -a' works on files, but is not portable.
- case `echo "$esc" | $FGREP "$esc"` in
-   "$esc") ;;
- # Creative quoting below to please maintainer-check.
-   *) echo "$me: f""grep can't parse nonprinting characters" >&2; Exit 77;;
- esac
  TERM=ansi; export TERM
  
  cat >>configure.ac <<END
@@@ -37,7 -27,7 +27,7 @@@ EN
  
  cat >Makefile.am <<'END'
  LOG_COMPILER = $(SHELL)
 -AUTOMAKE_OPTIONS = color-tests parallel-tests
 +AUTOMAKE_OPTIONS = color-tests
  TESTS = pass fail skip xpass xfail error
  XFAIL_TESTS = xpass xfail
  END
@@@ -57,6 -47,8 +47,8 @@@ $AUTOMAKE --add-missin
  ./configure
  mv config.log config-log # Avoid possible false positives below.
  AM_COLOR_TESTS=always $MAKE -e check && Exit 1
- $FGREP "$esc" *.log && Exit 1
+ # Not a useless use of cat; see above comments "grep-nonprinting"
+ # requirement in 'test-init.sh'.
+ cat *.log | grep "$esc" && Exit 1
  
  :
  # You should have received a copy of the GNU General Public License
  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  
 -# Check that the parallel-tests driver correctly handle overrides of the
 +# Check that the testsuite harness correctly handle overrides of the
  # TERM variable by either TESTS_ENVIRONMENT and AM_TESTS_ENVIRONMENT.
  
+ required='grep-nonprint'
  . ./defs || Exit 1
  
- esc='\e['
  TERM=ansi; export TERM
  
- # Check that grep can parse nonprinting characters.
- # BSD 'grep' works from a pipe, but not a seekable file.
- # GNU or BSD 'grep -a' works on files, but is not portable.
- case `echo "$esc" | $FGREP "$esc"` in
-   "$esc") ;;
-   *) skip_ "$FGREP can't parse nonprinting characters" ;;
- esac
  cat >> configure.ac << 'END'
  AC_OUTPUT
  END
@@@ -67,9 -58,9 +58,9 @@@ $AUTOMAKE -
  ./configure
  
  mkcheck TESTS_ENVIRONMENT='TERM=dumb'
- cat stdout | grep "PASS.*foobar" | $FGREP "$esc"
+ cat stdout | grep "PASS.*foobar" | grep "$esc\\["
  
  mkcheck AM_TESTS_ENVIRONMENT='TERM=dumb'
- cat stdout | grep "PASS.*foobar" | $FGREP "$esc"
+ cat stdout | grep "PASS.*foobar" | grep "$esc\\["
  
  :
diff --combined t/vtexi4.sh
@@@ -21,7 -21,7 +21,7 @@@
  # for more vers*.texi files, and does not require makeinfo, tex and
  # texi2dvi.
  
- required='makeinfo tex texi2dvi'
 -required='makeinfo tex texi2dvi-o grep-nonprint'
++required='makeinfo tex texi2dvi grep-nonprint'
  . ./defs || Exit 1
  
  test $(LC_ALL=C date '+%u') -gt 0 && test $(LC_ALL=C date '+%u') -lt 8 \
@@@ -31,9 -31,6 +31,6 @@@
    || skip_ "'date' is not POSIX-compliant enough"
  day=$(echo "$day" | sed 's/^0//')
  
- (echo '\ex\a' | grep x) \
-   || skip_ "grep doesn't work on input that is not pure text"
  cat > configure.ac << END
  AC_INIT([$me], [123.456])
  AM_INIT_AUTOMAKE
@@@ -51,7 -48,7 +48,7 @@@ cat > Makefile.am << 'END
  include defs.am
  info_TEXINFOS = foo.texi
  test-grepinfo:
- ## Not useless uses of cat: we only tested that grep worked on
+ ## Not useless uses of cat: we only tested that grep works on
  ## non-text input when that's given from a pipe.
        cat $(srcdir)/foo.info | grep 'GREPVERSION=$(my_version_rx)='
        cat $(srcdir)/foo.info | grep 'GREPEDITION=$(my_version_rx)='