autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Faster AT_CHECK, one less XFAIL


From: Eric Blake
Subject: Faster AT_CHECK, one less XFAIL
Date: Thu, 20 Nov 2008 19:19:04 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.18) Gecko/20081105 Thunderbird/2.0.0.18 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Now that m4_expand is more robust, I switched AT_CHECK to start using it.
 I had to fix a bit of fallout - a grand total of two tests (one with
unbalanced '(', and one that intentionally mucked with the internals of
m4_split/m4_expand); not a bad track record.  It gives a lot more
assurance that m4_expand is ready for prime-time usage.  And it fixes a
LONG-standing XFAIL!  I'm pushing this now, so it can give m4_expand even
more stress testing.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkkmGpgACgkQ84KuGfSFAYAKCACggk1M8NWSgwrgkT1b/uS1sTvX
Ju4AnRe/NhEaVbX9Vluq8P1fj6V/syQ2
=9jFN
-----END PGP SIGNATURE-----
>From 79042ea34671407b95a40feb4ba0963f5aad9ff7 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 20 Nov 2008 17:23:52 -0700
Subject: [PATCH] Fix XFAIL related to AT_CHECK.

* lib/autotest/general.m4 (AT_CHECK, AT_CHECK_UNQUOTED): Expand
first argument once.
(_AT_CHECK): Don't re-expand commands.
* tests/autotest.at (Multiline command from M4 expansion): Remove
XFAIL.
* tests/tools.at (autoupdating AU_ALIAS): Quote unbalanced paren.
* NEWS: Document the fallout.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog               |   11 +++++++++++
 NEWS                    |    7 +++++++
 lib/autotest/general.m4 |   14 +++++---------
 tests/autotest.at       |    5 +----
 tests/tools.at          |    2 +-
 5 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8b2986d..0d0ce65 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2008-11-20  Eric Blake  <address@hidden>
 
+       Fix XFAIL related to AT_CHECK.
+       * lib/autotest/general.m4 (AT_CHECK, AT_CHECK_UNQUOTED): Expand
+       first argument once.
+       (_AT_CHECK): Don't re-expand commands.
+       * tests/autotest.at (Multiline command from M4 expansion): Remove
+       XFAIL.
+       * tests/tools.at (autoupdating AU_ALIAS): Quote unbalanced paren.
+       * NEWS: Document the fallout.
+
+2008-11-20  Eric Blake  <address@hidden>
+
        Reduce forks in AC_DEFINE.
        * lib/autoconf/general.m4 (_AC_DEFINE_Q_PRINT): New macro.
        (_AC_DEFINE_Q): Use it to avoid forks for all AC_DEFINE and most
diff --git a/NEWS b/NEWS
index 297b3ea..01dbd3e 100644
--- a/NEWS
+++ b/NEWS
@@ -29,6 +29,13 @@ GNU Autoconf NEWS - User visible changes.
 ** The following m4sugar macros are documented now:
    m4_copy  m4_dumpdefs  m4_rename
 
+** The m4sugar macro m4_expand has been taught to handle unterminated
+   comments and shell case statements.  As a result, it is used in
+   more places, such as AC_DEFINE and AT_CHECK.  Most uses should not
+   behave any differently; however, it may be necessary to add
+   double-quoting around unbalanced `(' where single-quoting used to
+   be sufficient.
+
 ** The following documented m4sh macros are new:
    AS_LINENO_PREPARE  AS_ME_PREPARE  AS_SET_STATUS  AS_VAR_APPEND
    AS_VAR_ARITH  AS_VAR_COPY
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index ebde0b3..fc48c1f 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -1743,7 +1743,7 @@ $2[]_ATEOF
 # This may cause spurious failures when the test suite is run with `-x'.
 #
 _AT_DEFINE_SETUP([AT_CHECK],
-[_AT_CHECK([$1],[$2],[$3],[$4],[$5],[$6],1)])
+[_AT_CHECK(m4_expand([$1]),[$2],[$3],[$4],[$5],[$6],1)])
 
 # AT_CHECK_NOESCAPE(COMMANDS, [STATUS = 0], STDOUT, STDERR,
 #                   [RUN-IF-FAIL], [RUN-IF-PASS])
@@ -1751,7 +1751,7 @@ _AT_DEFINE_SETUP([AT_CHECK],
 # Like AT_CHECK, but do not AS_ESCAPE shell metacharacters in the STDOUT
 # and STDERR arguments before running the comparison.
 _AT_DEFINE_SETUP([AT_CHECK_NOESCAPE],
-[_AT_CHECK([$1],[$2],[$3],[$4],[$5],[$6])])
+[_AT_CHECK(m4_expand([$1]),[$2],[$3],[$4],[$5],[$6])])
 
 
 # _AT_DECIDE_TRACEABLE(COMMANDS)
@@ -1827,10 +1827,6 @@ _AT_DEFINE_SETUP([AT_CHECK_NOESCAPE],
 # just described, the test suite preemptively disables tracing for 31 of those,
 # and 268 contain parameter expansions that require runtime evaluation.  The
 # balance are always safe to trace.
-#
-# _AT_CHECK expands COMMANDS, but the Autoconf language does not provide a way
-# to safely expand arbitrary COMMANDS in an argument list, so the below tests
-# examine COMMANDS unexpanded.
 m4_define([_AT_DECIDE_TRACEABLE],
 dnl Utility macro.
 dnl
@@ -1919,17 +1915,17 @@ m4_define([AT_DIFF_STDOUT()],
 # with parallel jobs.
 m4_define([_AT_CHECK],
 [{ $at_traceoff
-AS_ECHO(["$at_srcdir/AT_LINE: AS_ESCAPE([$1])"])
+AS_ECHO(["$at_srcdir/AT_LINE: AS_ESCAPE([[$1]])"])
 echo AT_LINE >"$at_check_line_file"
 
 : >"$at_stdout"
 if _AT_DECIDE_TRACEABLE([$1]); then
   : >"$at_stder1"
-  ( $at_traceon; $1 ) >>"$at_stdout" 2>>"$at_stder1"
+  ( $at_traceon; [$1] ) >>"$at_stdout" 2>>"$at_stder1"
   at_fn_filter_trace $?
 else
   : >"$at_stderr"
-  ( :; $1 ) >>"$at_stdout" 2>>"$at_stderr"
+  ( :; [$1] ) >>"$at_stdout" 2>>"$at_stderr"
 fi
 at_status=$?
 at_failed=false
diff --git a/tests/autotest.at b/tests/autotest.at
index 631c0c8..820e7e3 100644
--- a/tests/autotest.at
+++ b/tests/autotest.at
@@ -310,15 +310,12 @@ AT_CHECK_AT_TEST([Invalid brace-enclosed parameter 
expansion],
 ## M4 macros in test commands.  ##
 ## ---------------------------- ##
 
-# The last paragaph in the comment above _AT_DECIDE_TRACEABLE illustrates why
-# this test fails (except with Korn shell-style quoting $'foo\nbar').
 AT_CHECK_AT_TEST([Multiline command from M4 expansion],
   [m4_define([GNU], ['foo
 bar'])
    AT_CHECK([echo GNU], 0, [foo
 bar
-], [])], [case `( set -x; echo 'foo
-bar') 2>&1` in *\$\'foo\\nbar\'*) false;; *) :;; esac])
+], [])])
 
 AT_CHECK_AT_TEST([Double-M4-quoted command],
   [m4_define([GNU], ['foo
diff --git a/tests/tools.at b/tests/tools.at
index 5cd64cf..3fa0fdb 100644
--- a/tests/tools.at
+++ b/tests/tools.at
@@ -786,7 +786,7 @@ AC_OUTPUT
 AT_CHECK_AUTOUPDATE
 AT_CHECK_AUTOCONF
 AT_CHECK_CONFIGURE
-AT_CHECK([grep 'AC_HEADER_STDC(' configure.ac], 1, [ignore], [ignore])
+AT_CHECK([grep 'AC_HEADER_STDC[(]' configure.ac], 1, [ignore], [ignore])
 AT_CHECK([grep 'AC_HEADER_STDC' configure.ac], 0, [ignore], [ignore])
 
 AT_CLEANUP
-- 
1.6.0.4


>From 03118f36d9b01cf61a7fa267707c488bf3bff1e6 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 20 Nov 2008 17:06:22 -0700
Subject: [PATCH] Speed up AT_CHECK.

* lib/autotest/general.m4 (AT_CHECK, AT_CHECK_UNQUOTED): Expand
third and fourth arguments once.
(_AT_CHECK): Don't re-expand expected output.  Rearrange code for
fewer scans of arguments.
(AT_CHECK): Update caller.
(AT_INIT) <at_fn_filter_trace>: Drop parameter.
* tests/m4sugar.at (m4@&address@hidden): Protect test with
quadrigraphs.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog               |   10 +++++++++
 lib/autotest/general.m4 |   48 ++++++++++++++++++++++------------------------
 tests/m4sugar.at        |    2 +-
 3 files changed, 34 insertions(+), 26 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0d0ce65..b14c98d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2008-11-20  Eric Blake  <address@hidden>
 
+       Speed up AT_CHECK.
+       * lib/autotest/general.m4 (AT_CHECK, AT_CHECK_UNQUOTED): Expand
+       third and fourth arguments once.
+       (_AT_CHECK): Don't re-expand expected output.  Rearrange code for
+       fewer scans of arguments.
+       (AT_CHECK): Update caller.
+       (AT_INIT) <at_fn_filter_trace>: Drop parameter.
+       * tests/m4sugar.at (m4@&address@hidden): Protect test with
+       quadrigraphs.
+
        Fix XFAIL related to AT_CHECK.
        * lib/autotest/general.m4 (AT_CHECK, AT_CHECK_UNQUOTED): Expand
        first argument once.
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index fc48c1f..c485f69 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -274,15 +274,14 @@ at_fn_check_newline ()
   esac
 }
 
-AS_FUNCTION_DESCRIBE([at_fn_filter_trace], [EXIT-CODE],
-[Split the contents of file "$at_stder1" into the "set -x" trace (on
-stderr) and the other lines (on file "$at_stderr").  Return the exit
-code EXIT-CODE.])
+AS_FUNCTION_DESCRIBE([at_fn_filter_trace], [],
+[Remove the lines in the file "$at_stderr" generated by "set -x" and print
+them to stderr.])
 at_fn_filter_trace ()
 {
+  mv "$at_stderr" "$at_stder1"
   grep '^ *+' "$at_stder1" >&2
   grep -v '^ *+' "$at_stder1" >"$at_stderr"
-  return $[1]
 }
 
 AS_FUNCTION_DESCRIBE([at_fn_log_failure], [FILE-LIST],
@@ -1743,7 +1742,8 @@ $2[]_ATEOF
 # This may cause spurious failures when the test suite is run with `-x'.
 #
 _AT_DEFINE_SETUP([AT_CHECK],
-[_AT_CHECK(m4_expand([$1]),[$2],[$3],[$4],[$5],[$6],1)])
+[_AT_CHECK(m4_expand([$1]), [$2], m4_expand([AS_ESCAPE([$3])]),
+  m4_expand([AS_ESCAPE([$4])]), [$5], [$6])])
 
 # AT_CHECK_NOESCAPE(COMMANDS, [STATUS = 0], STDOUT, STDERR,
 #                   [RUN-IF-FAIL], [RUN-IF-PASS])
@@ -1751,7 +1751,8 @@ _AT_DEFINE_SETUP([AT_CHECK],
 # Like AT_CHECK, but do not AS_ESCAPE shell metacharacters in the STDOUT
 # and STDERR arguments before running the comparison.
 _AT_DEFINE_SETUP([AT_CHECK_NOESCAPE],
-[_AT_CHECK(m4_expand([$1]),[$2],[$3],[$4],[$5],[$6])])
+[_AT_CHECK(m4_expand([$1]), [$2], m4_expand([$3]),
+  m4_expand([$4]), [$5], [$6])])
 
 
 # _AT_DECIDE_TRACEABLE(COMMANDS)
@@ -1878,12 +1879,10 @@ m4_define([AT_DIFF_STDOUT()],
          [at_fn_diff_devnull "$at_stdout" || at_failed=:])
 
 # _AT_CHECK(COMMANDS, [STATUS = 0], STDOUT, STDERR,
-#           [RUN-IF-FAIL], [RUN-IF-PASS], SHELL_ESCAPE_IO)
-# ---------------------------------------------------------
-# Worker for AT_CHECK & AT_CHECK_NOESCAPE.  The final SHELL-ESCAPE-IO
-# argument determines whether the STDOUT & STDERR arguments will be escaped or
-# not.
-#
+#           [RUN-IF-FAIL], [RUN-IF-PASS])
+# -------------------------------------------------
+# Worker for AT_CHECK and AT_CHECK_UNQUOTED, with COMMANDS, STDOUT, and
+# STDERR pre-expanded.
 #
 # Implementation Details
 # ----------------------
@@ -1918,26 +1917,25 @@ m4_define([_AT_CHECK],
 AS_ECHO(["$at_srcdir/AT_LINE: AS_ESCAPE([[$1]])"])
 echo AT_LINE >"$at_check_line_file"
 
-: >"$at_stdout"
 if _AT_DECIDE_TRACEABLE([$1]); then
-  : >"$at_stder1"
-  ( $at_traceon; [$1] ) >>"$at_stdout" 2>>"$at_stder1"
-  at_fn_filter_trace $?
+  at_check_trace=$at_traceon at_check_filter=at_fn_filter_trace
 else
-  : >"$at_stderr"
-  ( :; [$1] ) >>"$at_stdout" 2>>"$at_stderr"
+  at_check_trace=: at_check_filter=:
 fi
-at_status=$?
-at_failed=false
+: >"$at_stdout"; : >"$at_stderr"
+( $at_check_trace; [$1]
+) >>"$at_stdout" 2>>"$at_stderr"
+at_status=$? at_failed=false
+$at_check_filter
 m4_ifdef([AT_DIFF_STDERR($4)], [m4_indir([AT_DIFF_STDERR($4)])],
-  [echo >>"$at_stderr"; AS_ECHO(["m4_ifval([$7],[AS_ESCAPE([$4])],[$4])"]) | \
+  [echo >>"$at_stderr"; AS_ECHO([["$4"]]) | \
   $at_diff - "$at_stderr" || at_failed=:])
 m4_ifdef([AT_DIFF_STDOUT($3)], [m4_indir([AT_DIFF_STDOUT($3)])],
-  [echo >>"$at_stdout"; AS_ECHO(["m4_ifval([$7],[AS_ESCAPE([$3])],[$3])"]) | \
+  [echo >>"$at_stdout"; AS_ECHO([["$3"]]) | \
   $at_diff - "$at_stdout" || at_failed=:])
 m4_if([$2], [ignore], [at_fn_check_skip],
   [at_fn_check_status m4_default([$2], [0])]) $at_status "$at_srcdir/AT_LINE"
-AS_IF($at_failed, [$5], [$6])
-$at_failed && at_fn_log_failure AT_capture_files
+m4_ifvaln([$5$6], [AS_IF($at_failed, [$5], [$6])])]dnl
+[$at_failed && at_fn_log_failure AT_capture_files
 $at_traceon; }
 ])# _AT_CHECK
diff --git a/tests/m4sugar.at b/tests/m4sugar.at
index 708067b..e3387f6 100644
--- a/tests/m4sugar.at
+++ b/tests/m4sugar.at
@@ -507,7 +507,7 @@ m4_split([a )}@&t@>=- b -=<@&address@hidden( c])
 [foo=``], [bar='']
 [foo=''], [bar=``]
 [a], [], [B], [], [c]
-[a], [)}>=-], [b], [-=<{(], [c]
+[a], [)}>=@&address@hidden, [b], [-@&address@hidden<{(], [c]
 ]])
 
 AT_CLEANUP
-- 
1.6.0.4


reply via email to

[Prev in Thread] Current Thread [Next in Thread]