[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Autotest function usage
From: |
Ralf Wildenhues |
Subject: |
Autotest function usage |
Date: |
Wed, 17 Oct 2007 20:34:04 +0200 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
Hello Eric, autoconf patchers,
now that Autotest uses one shell function per test, that means for users
who have to put up with a broken zsh 4.2.x, tests may go wrong unnoticed
because we execute tests from within a shell function:
AT_CHECK([command || exit 77], ...)
is then broken, as the pipeline will be executed in a subshell (the
whole test is executed in a subshell even).
Now, I don't mind if Autotest uses shell functions at all, nor do I mind
pestering those zsh-only users to (pester their distributors to) get a
decent shell; but I certainly mind getting wrong answers, even after an
initial warning. One way would be to force a hard error for Autotest,
but I think we can avoid the above problems without too much hassle.
The second patch below removes the wrapping of each test in a function,
and sources the code from outside at_func_test. This slight repetitive
code increase is however offset by reduced indenting in the per-function
code at the end. :-)
Further, I noted that there was a glitch in the sed script to extract
the single tests, that caused `./testsuite 1' to extract all tests
numbered with a leading digit of 1: 1, 10-19, 100-199, ...
I would be interested to know what performance impact these changes
have on w32 (after all, the idea to free the memory after the function
tests are used has not been implemented yet). There is a 14% win on
GNU/Linux:
pre patch:
time (./testsuite -1 >/dev/null)
real 0m1.973s
user 0m1.320s
sys 0m0.636s
time (./testsuite -10 >/dev/null)
real 0m9.712s
user 0m6.120s
sys 0m3.780s
post patch:
time (./testsuite 1 >/dev/null)
real 0m1.692s
user 0m1.180s
sys 0m0.460s
time (./testsuite -10 >/dev/null)
real 0m8.350s
user 0m5.508s
sys 0m2.980s
With these patches, and CONFIG_SHELL=/bin/zsh, the testsuite only fails
`Configuring subdirectories', because `configure --silent' still outputs
the warnings about broken shell function support. I don't mind this
failure (one could think about outputting on stderr). Of course, that
doesn't mean that all tests work correctly now. ;-)
OK to apply these two patches?
Cheers,
Ralf
---
* lib/autotest/general.m4 (at_func_test): Fix test extraction script.
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index ce8abc8..52fa8ef 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -295,7 +295,7 @@ at_func_diff_devnull ()
# then invoke it.
at_func_test ()
{
- if sed -n
'/address@hidden:@AT_START_'$[1]$'/,/address@hidden:@AT_STOP_'$[1]$'/p'
"$at_myself" \
+ if sed -n
'/address@hidden:@AT_START_'$[1]'$/,/address@hidden:@AT_STOP_'$[1]'$/p'
"$at_myself" \
> "$at_test_source" && . "$at_test_source" ; then
at_func_test_$[1] || {
AS_ECHO(["$as_me: unable to execute test group: $[1]"]) >&2
Autotest: do not use shell functions for individual tests.
* lib/autotest/general.m4 (AT_INIT) <at_func_test>: Merely
extract the source test source, do not invoke it.
(AT_SETUP, AT_CLEANUP): Source test code outside shell function.
* tests/autotest.at (Fallacy): Actually let the inner suite fail,
expect exit status of 1.
* tests/autotest.at (Skip): New test, for bogus zsh exit status.
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index 52fa8ef..9c95afd 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -291,20 +291,11 @@ at_func_diff_devnull ()
# at_func_test NUMBER
# -------------------
-# Parse out at_func_test_NUMBER from the tail of this file, source it,
-# then invoke it.
+# Parse out test NUMBER from the tail of this file.
at_func_test ()
{
- if sed -n
'/address@hidden:@AT_START_'$[1]'$/,/address@hidden:@AT_STOP_'$[1]'$/p'
"$at_myself" \
- > "$at_test_source" && . "$at_test_source" ; then
- at_func_test_$[1] || {
- AS_ECHO(["$as_me: unable to execute test group: $[1]"]) >&2
- at_failed=:
- }
- else
- AS_ECHO(["$as_me: unable to parse test group: $[1]"]) >&2
- at_failed=:
- fi
+ sed -n
'/address@hidden:@AT_START_'$[1]'$/,/address@hidden:@AT_STOP_'$[1]'$/p'
"$at_myself" \
+ > "$at_test_source"
}
# Load the config file.
@@ -1295,12 +1286,10 @@ m4_append([AT_groups_all], [ ]m4_defn([AT_ordinal]))
m4_divert_push([TEST_FUNCTIONS])dnl
[#AT_START_]AT_ordinal
@%:@ AT_ordinal. m4_defn([AT_line]): m4_defn([AT_description])
-at_func_test_[]AT_ordinal ()
-{
- at_setup_line='m4_defn([AT_line])'
- at_desc="AS_ESCAPE(m4_dquote(m4_defn([AT_description])))"
- $at_quiet AS_ECHO_N([m4_format(["%3d: $at_desc%*s"], AT_ordinal,
- m4_max(0, m4_eval(47 - m4_qlen(m4_defn([AT_description])))), [])])
+at_setup_line='m4_defn([AT_line])'
+at_desc="AS_ESCAPE(m4_dquote(m4_defn([AT_description])))"
+$at_quiet AS_ECHO_N([m4_format(["%3d: $at_desc%*s"], AT_ordinal,
+ m4_max(0, m4_eval(47 - m4_qlen(m4_defn([AT_description])))), [])])
m4_divert_push([TEST_SCRIPT])dnl
])
@@ -1345,21 +1334,24 @@ m4_define([AT_CLEANUP],
m4_defn([AT_ordinal]);m4_defn([AT_line]);m4_defn([AT_description]);m4_ifdef([AT_keywords],
[m4_defn([AT_keywords])]);
)dnl
m4_divert_pop([TEST_SCRIPT])dnl Back to TEST_FUNCTIONS
- AT_xfail
- echo "# -*- compilation -*-" >> "$at_group_log"
- (
- AS_ECHO(["AT_ordinal. m4_defn([AT_line]): testing $1..."])
- $at_traceon
+AT_xfail
+echo "# -*- compilation -*-" >> "$at_group_log"
+(
+ AS_ECHO(["AT_ordinal. m4_defn([AT_line]): testing $1..."])
+ $at_traceon
m4_undivert([TEST_SCRIPT])dnl Insert the code here
- $at_traceoff
- $at_times_p && times >"$at_times_file"
- ) AS_MESSAGE_LOG_FD>&1 2>&1 | eval $at_tee_pipe
- at_status=`cat "$at_status_file"`
-}
+ $at_traceoff
+ $at_times_p && times >"$at_times_file"
+) AS_MESSAGE_LOG_FD>&1 2>&1 | eval $at_tee_pipe
+at_status=`cat "$at_status_file"`
[#AT_STOP_]AT_ordinal
m4_divert_pop([TEST_FUNCTIONS])dnl Back to KILL.
m4_divert_text([TESTS],
-[ AT_ordinal ) at_func_test AT_ordinal ;;])
+[ AT_ordinal )
+ if at_func_test AT_ordinal && . "$at_test_source"; then :; else
+ AS_ECHO(["$as_me: unable to parse test group: $[1]"]) >&2
+ at_failed=:
+ fi ;;])
])# AT_CLEANUP
diff --git a/tests/autotest.at b/tests/autotest.at
index 2a339e1..1f03a8f 100644
--- a/tests/autotest.at
+++ b/tests/autotest.at
@@ -98,7 +98,14 @@ AT_CHECK_AT_TEST([Truth],
[AT_CHECK([:], 0, [], [])])
AT_CHECK_AT_TEST([Fallacy],
- [AT_CHECK([false], ignore, [], [])])
+ [AT_CHECK([false], [], [], [])],
+ [], [1], [], [ignore],
+ [AT_CHECK([grep failed micro-suite.log], [], [ignore])])
+
+AT_CHECK_AT_TEST([Skip],
+ [AT_CHECK([exit 77], 0, [], [])],
+ [], [], [], [],
+ [AT_CHECK([grep skipped micro-suite.log], [], [ignore])])
AT_CHECK_AT_TEST([Literal multiline command],
[AT_CHECK([echo Auto'
- Autotest function usage,
Ralf Wildenhues <=