[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Faster AT_CHECK, one less XFAIL
From: |
Eric Blake |
Subject: |
Re: Faster AT_CHECK, one less XFAIL |
Date: |
Thu, 20 Nov 2008 22:11:07 -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
According to Eric Blake on 11/20/2008 7:19 PM:
> 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.
And as long as I'm playing with autotest, this shaves off half a meg from
autoconf's testsuite (17%). It also fixes an echo usage bug if you name
one of your files 'tests/-name.at'; conveniently hidden by the fact that
it was 'echo AT_LINE' with no -, \, $ or ` until after you expand the m4
macro, and thus easy to miss when grepping for problematic echo.
- --
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
iEYEARECAAYFAkkmQuoACgkQ84KuGfSFAYBdMQCfV0QBLe3/PkWXM+Z9ilqPOvRf
PH8AoKOZzRlDKUwq+8IWmwdwzZO2C73y
=s8N+
-----END PGP SIGNATURE-----
>From abe172f4ba8d375a8b078534e9cef1e084ff59ab Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 20 Nov 2008 21:59:23 -0700
Subject: [PATCH] Factor more common code out of AT_CHECK into shell function.
* lib/autotest/general.m4 (_AT_CHECK): Avoid echo bug if AT_LINE
starts with -. Move preparations...
(AT_INIT) <at_fn_check_prepare_trace>
<at_fn_check_prepare_notrace, at_fn_check_prepare_dynamic>:
...into these new shell functions.
<at_fn_check_newline>: Inline into only caller.
(_AT_DECIDE_TRACEABLE): Use them to condense testsuite size.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 11 +++++++
lib/autotest/general.m4 | 74 +++++++++++++++++++++++++++++------------------
2 files changed, 57 insertions(+), 28 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 24b8091..8381688 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2008-11-20 Eric Blake <address@hidden>
+ Factor more common code out of AT_CHECK into shell function.
+ * lib/autotest/general.m4 (_AT_CHECK): Avoid echo bug if AT_LINE
+ starts with -. Move preparations...
+ (AT_INIT) <at_fn_check_prepare_trace>
+ <at_fn_check_prepare_notrace, at_fn_check_prepare_dynamic>:
+ ...into these new shell functions.
+ <at_fn_check_newline>: Inline into only caller.
+ (_AT_DECIDE_TRACEABLE): Use them to condense testsuite size.
+
+2008-11-20 Eric Blake <address@hidden>
+
Handle version numbers as decimal, even if they start with 0.
* lib/m4sugar/m4sugar.m4 (_m4_version_unletter): Avoid
interpreting leading zeros as octal.
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index c485f69..4800701 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -261,16 +261,43 @@ at_fn_banner ()
AS_ECHO(["$as_nl$at_banner_text$as_nl"])
} # at_fn_banner
-AS_FUNCTION_DESCRIBE([at_fn_check_newline], [COMMAND],
-[Test if COMMAND includes a newline and, if so, print a message and return
-exit code 1.])
-at_fn_check_newline ()
+AS_FUNCTION_DESCRIBE([at_fn_check_prepare_notrace], [LINE],
+[Perform AT_CHECK preparations for the command at LINE for an
+untraceable command, or when tracing is disabled.])
+at_fn_check_prepare_notrace ()
{
- case "$[1]" in
- *'
-'*) echo 'Not enabling shell tracing (command contains an embedded newline)'
- return 1 ;;
- *) return 0 ;;
+ AS_ECHO(["$[1]"]) >"$at_check_line_file"
+ at_check_trace=: at_check_filter=:
+ : >"$at_stdout"; : >"$at_stderr"
+}
+
+AS_FUNCTION_DESCRIBE([at_fn_check_prepare_trace], [LINE],
+[Perform AT_CHECK preparations for the command at LINE for a traceable
+command.])
+at_fn_check_prepare_trace ()
+{
+ if test -n "$at_traceon"; then
+ AS_ECHO(["$[1]"]) >"$at_check_line_file"
+ at_check_trace=$at_traceon at_check_filter=at_fn_filter_trace
+ : >"$at_stdout"; : >"$at_stderr"
+ else
+ at_fn_check_prepare_notrace "$[1]"
+ fi
+}
+
+AS_FUNCTION_DESCRIBE([at_fn_check_prepare_dynamic], [COMMAND LINE],
+[Decide if COMMAND at LINE is traceable at runtime, and call the
+appropriate prepation function.])
+at_fn_check_prepare_dynamic ()
+{
+ case "$at_traceon:$[1]" in
+ :*$as_nl*)
+ at_fn_check_prepare_notrace "$[2]" ;;
+ *$as_nl*)
+ echo 'Not enabling shell tracing (command contains an embedded newline)'
+ at_fn_check_prepare_notrace "$[2]" ;;
+ *)
+ at_fn_check_prepare_trace "$[2]" ;;
esac
}
@@ -1841,19 +1868,17 @@ m4_cond([m4_eval(m4_index([$1], [`]) >= 0)], [1],
[[a ${...} parameter expansion]],
[m4_eval(m4_index([$1], m4_newline) >= 0)], [1],
[[an embedded newline]],
- []dnl No reason.
-))dnl
-dnl
-m4_ifval(m4_defn([at_reason]),
-[{ echo 'Not enabling shell tracing (command contains ]m4_defn([at_reason])[)'
- false; }],
-[m4_if(m4_index([$1], [$]), [-1],
+ []))]dnl No reason.
+[m4_if(m4_index(_m4_defn([at_reason]), [a]), [0],]dnl
+dnl We know at build time that tracing COMMANDS is never safe.
+[[echo 'Not enabling shell tracing (command contains ]m4_defn([at_reason])[)'
+at_fn_check_prepare_notrace],
+ m4_index([$1], [$]), [-1],]dnl
dnl We know at build time that tracing COMMANDS is always safe.
-[test -n "$at_traceon"],
+[[at_fn_check_prepare_trace],]dnl
dnl COMMANDS may contain parameter expansions; expand them at runtime.
-[test -n "$at_traceon" \
- && at_fn_check_newline "AS_ESCAPE([$1], [`\"])"])])[]dnl
-m4_popdef([at_reason])])
+[[at_fn_check_prepare_dynamic "AS_ESCAPE([$1], [`\"])"])])]dnl
+[_m4_popdef([at_reason])])
# AT_DIFF_STDERR/AT_DIFF_STDOUT
@@ -1915,14 +1940,7 @@ m4_define([AT_DIFF_STDOUT()],
m4_define([_AT_CHECK],
[{ $at_traceoff
AS_ECHO(["$at_srcdir/AT_LINE: AS_ESCAPE([[$1]])"])
-echo AT_LINE >"$at_check_line_file"
-
-if _AT_DECIDE_TRACEABLE([$1]); then
- at_check_trace=$at_traceon at_check_filter=at_fn_filter_trace
-else
- at_check_trace=: at_check_filter=:
-fi
-: >"$at_stdout"; : >"$at_stderr"
+_AT_DECIDE_TRACEABLE([$1]) "AS_ESCAPE(m4_dquote(AT_LINE))"
( $at_check_trace; [$1]
) >>"$at_stdout" 2>>"$at_stderr"
at_status=$? at_failed=false
--
1.6.0.4