]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* bin/.cvsignore: Add autoconf.in.
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 10 Dec 2004 07:08:52 +0000 (07:08 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 10 Dec 2004 07:08:52 +0000 (07:08 +0000)
* tests/.cvsignore: Add wrapper.in.

* man/Makefile.am (autoconf.1): Regenerate when `autoconf.as' changes.

* lib/autotest/general.m4 [--trace] (AT_INIT): Do not `set -v'.

* tests/autotest.at: New file.
* tests/suite.at: Include it.
* tests/Makefile.am: Distribute it.

* lib/autotest/general.m4 [--trace] (_AT_CHECK): Do not enable
  shell tracing on a command that could contain multiple lines.
* doc/autoconf.text: Document that fact and its implications.
* lib/m4sugar/m4sh.m4 (AS_ESCAPE_FOR_EXPAND): New macro.
* tests/autotest.at (Multiline backquote command substitution,
  Multiline parameter expansion, Literal multiline command,
  Multiline parenthetical command substitution): Remove XFAIL.

ChangeLog
bin/.cvsignore
doc/autoconf.texi
lib/autotest/general.m4
lib/m4sugar/m4sh.m4
tests/.cvsignore
tests/Makefile.am
tests/autotest.at [new file with mode: 0644]
tests/suite.at

index 085a76ae7252e19406633e38530cb49e8b11e207..9a9a00c0fb34ef8b50a94ef0ab96eeb9e356841c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,27 @@
+2004-12-09  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * bin/.cvsignore: Add autoconf.in.
+       * tests/.cvsignore: Add wrapper.in.
+       * lib/autotest/general.m4: Escape '$' in case pattern.
+
 2004-12-09  Noah Misch  <noah@cs.caltech.edu>
 
        * man/Makefile.am (autoconf.1): Regenerate when `autoconf.as' changes.
 
+       * lib/autotest/general.m4 [--trace] (AT_INIT): Do not `set -v'.
+
+       * tests/autotest.at: New file.
+       * tests/suite.at: Include it.
+       * tests/Makefile.am: Distribute it.
+
+       * lib/autotest/general.m4 [--trace] (_AT_CHECK): Do not enable
+         shell tracing on a command that could contain multiple lines.
+       * doc/autoconf.text: Document that fact and its implications.
+       * lib/m4sugar/m4sh.m4 (AS_ESCAPE_FOR_EXPAND): New macro.
+       * tests/autotest.at (Multiline backquote command substitution,
+         Multiline parameter expansion, Literal multiline command,
+         Multiline parenthetical command substitution): Remove XFAIL.
+
 2004-12-09  Paul Eggert  <eggert@cs.ucla.edu>
 
        * doc/autoconf.texi (Libraries): Clarify problems with AC_CHECK_LIB
index 4fc286e154a1ca1638f33c594af80513f6a12684..5852fdc0e231da1010ffe42d32f4bda82f15c1c0 100644 (file)
@@ -1,3 +1,4 @@
 Makefile
+autoconf.in
 autoheader autoconf autom4te autoreconf autoscan autoupdate ifnames
 autom4te.cache
index 9e35b938b92aa55ebdb3fe797728db42ff0247c0..30653fbf666f7c59f33789db0810c88b68665836 100644 (file)
@@ -15442,6 +15442,29 @@ commands @var{run-if-pass}.
 The @var{commands} @emph{must not} redirect the standard output, nor the
 standard error.
 
+If the @var{commands} may contain a newline, @command{testsuite} will
+not enable shell tracing for them when the user passes @option{-x}.
+Since unquoted, unescaped literal newlines are never necessary to
+achieve particular semantics, escape them.  For example, avoid this:
+
+@display
+cat LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONG |
+  grep fairly-long-in-its-own-right
+echo "A sentence."
+@end display
+
+Write this instead:
+
+@display
+cat LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONG | \
+  grep fairly-long-in-its-own-right ; \
+echo "A sentence."
+@end display
+
+The presence in @var{commands} of any command substitution or a
+parameter expansion yielding multiple lines also inhibits shell tracing,
+but those constructs are rarely so easy to remove.
+
 If @var{status}, or @var{stdout}, or @var{stderr} is @samp{ignore}, then
 the corresponding value is not checked.
 
index 1fbecc00fbff8adf53769be84c06227f5bc831ec..c5abd7190c600fd32aad97c201a00114f53bbd9b 100644 (file)
@@ -272,7 +272,7 @@ do
        ;;
 
     --trace | -x )
-       at_traceon='set -vx'; at_traceoff='set +vx'
+       at_traceon='set -x'; at_traceoff='set +x'
        ;;
 
     [[0-9] | [0-9][0-9] | [0-9][0-9][0-9] | [0-9][0-9][0-9][0-9]])
@@ -1205,7 +1205,10 @@ m4_define([AT_CHECK_NOESCAPE],
 # but we must group COMMANDS as it is not limited to a single command, and
 # then the shells will save the traces in at-stderr. So we have to filter
 # them out when checking stderr, and we must send them into the test suite's
-# stderr to honor -x properly.
+# stderr to honor -x properly. Since only the first line of the trace of a
+# multiline command starts with a `+', and I know of no straightforward way to
+# filter out the unadorned trace lines, we disable shell tracing entirely for
+# commands that could span multiple lines.
 #
 # Limiting COMMANDS to a single command is not good either, since them
 # the user herself would use {} or (), and then we face the same problem.
@@ -1222,10 +1225,35 @@ m4_define([_AT_CHECK],
 [$at_traceoff
 echo "AT_LINE: AS_ESCAPE([$1])"
 echo AT_LINE >"$at_check_line_file"
-( $at_traceon; $1 ) >"$at_stdout" 2>"$at_stder1"
-at_status=$?
-grep '^ *+' "$at_stder1" >&2
-grep -v '^ *+' "$at_stder1" >"$at_stderr"
+
+at_trace_this=
+if test -n "$at_traceon"; then
+    at_lf='
+'
+    at_cmd_expanded="AS_ESCAPE_FOR_EXPAND([$1])"
+    case "$at_cmd_expanded" in
+        *\$\(*\)*)         at_reason='a $(...) command substitution' ;;
+        *\`*\`*)           at_reason='a `...` command substitution' ;;
+        *[[^\\]]"$at_lf"*) at_reason='an embedded newline' ;;
+        *)                 at_reason= ;;
+    esac
+    if test -n "$at_reason"; then
+        echo "Not enabling shell tracing (command contains $at_reason)"
+    else
+        at_trace_this=yes
+    fi
+fi
+
+if test -n "$at_trace_this"; then
+    ( $at_traceon; $1 ) >"$at_stdout" 2>"$at_stder1"
+    at_status=$?
+    grep '^ *+' "$at_stder1" >&2
+    grep -v '^ *+' "$at_stder1" >"$at_stderr"
+else
+    ( $1 ) >"$at_stdout" 2>"$at_stderr"
+    at_status=$?
+fi
+
 at_failed=false
 dnl Check stderr.
 m4_case([$4],
index 2cc29fe9cce5a67bbb79b30e498fffcbe6c5e6a6..827706cba268d32ee6a81a504fb69cd293c1808c 100644 (file)
@@ -483,6 +483,15 @@ m4_define([AS_ESCAPE],
             m4_ifval([$2], [[\([$2]\)]], [[\([\"$`]\)]]),
             [\\\1])])
 
+# AS_ESCAPE_FOR_EXPAND(STRING)
+# ----------------------------
+# Escape characters in STRING that have special meaning to the shell
+# within double quotes, but leave parameter expansions active.
+# These substitutions come from sed_double_backslash in GNU Libtool.
+m4_define([AS_ESCAPE_FOR_EXPAND],
+[m4_bpatsubsts([AS_ESCAPE([$1], [`"\])],
+               [^\(\(\\\\\\\\\)*\\\\\)\$], [\1\\$],
+           [\([^\\]\(\\\\\\\\\)*\\\\\)\$], [\1\\$])])
 
 # _AS_QUOTE_IFELSE(STRING, IF-MODERN-QUOTATION, IF-OLD-QUOTATION)
 # ---------------------------------------------------------------
index 999c31c7019c6d55e75ca2398e8a3f81e011ee79..ad5023858f011256f1b1648a942f173a1825fee8 100644 (file)
@@ -14,3 +14,4 @@ autoreconf
 autom4te
 autoheader
 autoconf
+wrapper.in
index d0cb0404af3a7f2ae503485841a7f0efd416c442..c98a83026cb1fd30ce35705c2aa1e594a15a5f8b 100644 (file)
@@ -87,7 +87,7 @@ TESTSUITE_GENERATED_AT = \
 
 TESTSUITE_HAND_AT = \
        suite.at \
-       m4sugar.at m4sh.at \
+       m4sugar.at m4sh.at autotest.at \
        base.at tools.at torture.at \
        compile.at c.at fortran.at \
        semantics.at \
diff --git a/tests/autotest.at b/tests/autotest.at
new file mode 100644 (file)
index 0000000..2498f17
--- /dev/null
@@ -0,0 +1,138 @@
+#                                                      -*- Autotest -*-
+
+AT_BANNER([Autotest.])
+
+# Copyright (C) 2004 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# AT_CHECK_AT(TITLE, SUITE-CODE, [XFAIL-CONDITION])
+# -------------------------------------------------
+# Create a new test named TITLE that runs a minimal Autotest test suite,
+# SUITE-CODE.  If given, XFAIL-CONDITION is passed to AT_XFAIL_IF.
+m4_define([AT_CHECK_AT],
+[
+AT_SETUP([$1])
+AT_KEYWORDS([autotest])
+AT_XFAIL_IF([$3])
+
+AT_DATA([package.m4],[[
+m4_define([AT_PACKAGE_NAME],      [GNU Nonsense])
+m4_define([AT_PACKAGE_TARNAME],   [nonsense])
+m4_define([AT_PACKAGE_VERSION],   [1.0])
+m4_define([AT_PACKAGE_STRING],    [GNU Nonsense 1.0])
+m4_define([AT_PACKAGE_BUGREPORT], [bug-autoconf@gnu.org])
+]])
+
+AT_DATA([mysuite.at], [$2])
+
+# Do not use `testsuite' as the name of the small test suite, or the
+# log file it generates will overwrite the log that the Autoconf test
+# suite produces for this test case.
+AT_CHECK_AUTOM4TE([--language=autotest -o micro-suite mysuite.at])
+AT_CHECK([./micro-suite], 0, [ignore], [])
+AT_CHECK([./micro-suite -v -x], 0, [ignore], [])
+AT_CLEANUP
+])
+
+# AT_CHECK_AT_TEST(TITLE, SUITE-SNIPPET, [XFAIL-CONDITION])
+# ---------------------------------------------------------
+# Like AT_CHECK_AT, but surrounds SUITE-SNIPPET with a boilerplate
+# AT_INIT, AT_SETUP, and AT_CLEANUP.
+m4_define([AT_CHECK_AT_TEST],
+[AT_CHECK_AT([$1],
+[[
+AT_INIT([artificial test suite])
+AT_SETUP([my only test])
+$2
+AT_CLEANUP
+]], $3)])
+
+# Here documents for these tests contain forbidden macros.
+m4_pattern_allow([^AT_])
+
+## ------------------------------------------------------ ##
+## Newlines and command substitutions in test commandds.  ##
+## ------------------------------------------------------ ##
+
+AT_CHECK_AT_TEST([Truth],
+  [AT_CHECK([:], 0, [], [])])
+
+AT_CHECK_AT_TEST([Fallacy],
+  [AT_CHECK([false], ignore, [], [])])
+
+AT_CHECK_AT_TEST([Literal multiline command],
+  [AT_CHECK([echo Auto'
+'conf], 0, [Auto
+conf
+], [])])
+
+AT_CHECK_AT_TEST([Multiline parameter expansion],
+  [FOO='one
+two'
+   AT_CHECK([echo "$FOO"], 0, [one
+two
+], [])])
+
+AT_CHECK_AT_TEST([Backquote command substition],
+  [AT_CHECK([echo `echo hi`], 0, [hi
+], [])])
+
+AT_CHECK_AT_TEST([Multiline backquote command substition],
+  [AT_DATA([myfile],[foo
+bar
+])
+   AT_CHECK([echo "`cat myfile`"], 0, [foo
+bar
+], [])])
+
+AT_CHECK_AT_TEST([Parenthetical command substition],
+  [AT_CHECK([echo $(echo hi)], 0, [hi
+], [])])
+
+AT_CHECK_AT_TEST([Multiline parenthetical command substition],
+  [AT_DATA([myfile],[foo
+bar
+])
+   AT_CHECK([echo "$(cat myfile)"], 0, [foo
+bar
+], [])])
+
+## ------------------------------- ##
+## Funny characters in test names. ##
+## ------------------------------- ##
+
+# AT_CHECK_AT_TITLE(TITLE, TITLE-TO-TEST, [XFAIL-CONDITION])
+# ----------------------------------------------------------
+# Create a new test named TITLE that runs an Autotest test suite
+# comprised of a trivial test named TITLE-TO-TEST.  XFAIL-CONDITION
+# passes verbatim to AT_CHECK_AT.
+m4_define([AT_CHECK_AT_TITLE],
+[AT_CHECK_AT([$1],
+[[
+AT_INIT([artificial test suite])
+AT_SETUP([$2])
+AT_CHECK([:])
+AT_CLEANUP
+]], [$3])])
+
+m4_define([AT_CHECK_AT_TITLE_CHAR],
+[AT_CHECK_AT_TITLE([$1 in a test title], [A $2 in my name], $3)])
+
+AT_CHECK_AT_TITLE_CHAR([Backquote],    [`], [:])
+AT_CHECK_AT_TITLE_CHAR([Single-quote], ['], [:])
+AT_CHECK_AT_TITLE_CHAR([Double-quote], ["], [:])
+AT_CHECK_AT_TITLE_CHAR([Backslash],    [\])
index e0ca44c339e1935f88d22f8cf1da71120c38f1ba..c16fc1d2cb94d6eb876f68f1d24e2f75b5e0404e 100644 (file)
@@ -30,6 +30,9 @@ m4_include([m4sugar.at])
 # M4sh.m4.
 m4_include([m4sh.at])
 
+# Autotest.
+m4_include([autotest.at])
+
 # Autoconf base macros.
 m4_include([base.at])