From: Paolo Bonzini Date: Thu, 4 Oct 2007 16:53:10 +0000 (+0200) Subject: use shell functions to speed up autotest and produce slimmer testsuites X-Git-Tag: v2.62~229 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b10ac1293d3def649839d65bb76e59cce79007e;p=thirdparty%2Fautoconf.git use shell functions to speed up autotest and produce slimmer testsuites 2007-10-04 Paolo Bonzini * general.m4 (AT_INIT): Add at_check_newline function. (_AT_DECIDE_TRACEABLE): Include at_traceon test, use shell function. (_AT_CHECK): Don't use at_trace_this. Signed-off-by: Paolo Bonzini --- diff --git a/ChangeLog b/ChangeLog index 5a37f4cb..925c1009 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,12 @@ useless expansions inside definition. * tests/m4sugar.at (m4@&t@_split): Add tests. +2007-10-04 Paolo Bonzini + + * general.m4 (AT_INIT): Add at_check_newline function. + (_AT_DECIDE_TRACEABLE): Include at_traceon test, use shell function. + (_AT_CHECK): Don't use at_trace_this. + 2007-10-04 Paolo Bonzini Fix previous commit. diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4 index dfd098c7..31038a1a 100644 --- a/lib/autotest/general.m4 +++ b/lib/autotest/general.m4 @@ -212,6 +212,19 @@ SHELL=${CONFIG_SHELL-/bin/sh} # How were we run? at_cli_args="$[@]" +####################### +### Shell functions ### +####################### + +at_check_newline () +{ + case "$[1]" in + *' +'*) echo 'Not enabling shell tracing (command contains an embedded newline)' ; return 1 ;; + *) return 0 ;; + esac +} + # Load the config file. for at_file in atconfig atlocal do @@ -1337,9 +1350,9 @@ m4_define([AT_CHECK_NOESCAPE], # _AT_DECIDE_TRACEABLE(COMMANDS) # ------------------------------ # Worker for for _AT_CHECK that expands to shell code. If COMMANDS are safe to -# trace with `set -x', the shell code will set `at_trace_this=yes'. Otherwise, +# trace with `set -x', the shell code will evaluate to true. Otherwise, # the shell code will print a message stating an aspect of COMMANDS that makes -# tracing them unsafe. +# tracing them unsafe, and evaluate to false. # # Tracing COMMANDS is not safe if they contain a command that spans multiple # lines. When the test suite user passes `-x' or `--trace', the test suite @@ -1427,16 +1440,12 @@ m4_pushdef([at_reason], ))dnl dnl m4_ifval(m4_defn([at_reason]), -[echo 'Not enabling shell tracing (command contains ]m4_defn([at_reason])[)'], -[m4_bmatch([$1], [\$], -dnl COMMANDS may contain parameter expansions; expand them at runtime. -[case "AS_ESCAPE([$1], [`\"])" in - *' -'*) echo 'Not enabling shell tracing (command contains an embedded newline)' ;; - *) at_trace_this=yes ;; - esac], +[{ echo 'Not enabling shell tracing (command contains ]m4_defn([at_reason])[)'; false; }], +[m4_if(m4_index([$1], [$]), [-1], dnl We know at build time that tracing COMMANDS is always safe. -[at_trace_this=yes])])[]dnl +[test -n "$at_traceon"], +dnl COMMANDS may contain parameter expansions; expand them at runtime. +[test -n "$at_traceon" && at_check_newline "AS_ESCAPE([$1], [`\"])"])])[]dnl m4_popdef([at_lf])[]dnl m4_popdef([at_reason])]) @@ -1479,12 +1488,7 @@ m4_define([_AT_CHECK], AS_ECHO(["$at_srcdir/AT_LINE: AS_ESCAPE([$1])"]) echo AT_LINE >"$at_check_line_file" -at_trace_this= -if test -n "$at_traceon"; then - _AT_DECIDE_TRACEABLE([$1]) -fi - -if test -n "$at_trace_this"; then +if _AT_DECIDE_TRACEABLE([$1]); then ( $at_traceon; $1 ) >"$at_stdout" 2>"$at_stder1" at_status=$? grep '^ *+' "$at_stder1" >&2