* NEWS: Mention AT_SKIP_IF and AT_FAIL_IF.
* doc/autoconf.texi (Autotest): Document them.
* lib/autotest/general.m4 (_AT_LINE_ESCAPED, AT_SKIP_IF,
AT_FAIL_IF, _AT_CHECK_EXIT): New.
(AT_CHECK): Use _AT_LINE_ESCAPED.
* tests/autotest.st: Add tests for AT_SKIP_IF and AT_FAIL_IF.
Use AT_SKIP_IF.
* tests/local.st: Use AT_SKIP_IF.
+2009-07-13 Paolo Bonzini <bonzini@gnu.org>
+
+ Introduce AT_SKIP_IF and AT_FAIL_IF
+ * NEWS: Mention AT_SKIP_IF and AT_FAIL_IF.
+ * doc/autoconf.texi (Autotest): Document them.
+ * lib/autotest/general.m4 (_AT_LINE_ESCAPED, AT_SKIP_IF,
+ AT_FAIL_IF, _AT_CHECK_EXIT): New.
+ (AT_CHECK): Use _AT_LINE_ESCAPED.
+ * tests/autotest.st: Add tests for AT_SKIP_IF and AT_FAIL_IF.
+ Use AT_SKIP_IF.
+ * tests/local.st: Use AT_SKIP_IF.
+
2009-07-13 Paolo Bonzini <bonzini@gnu.org>
Use m4 -g when available.
ignore-nolog, stdout-nolog, and stderr-nolog.
** The following documented autotest macros are new:
- AT_CHECK_UNQUOTED
+ AT_CHECK_UNQUOTED AT_FAIL_IF AT_SKIP_IF
** The following documented m4sugar macros are new:
m4_argn m4_copy_force m4_default_nblank m4_default_nblank_quoted
Several identical calls within one test group have no additional effect.
@end defmac
+@defmac AT_FAIL_IF (@var{shell-condition})
+@atindex{FAIL_IF}
+Make the test group fail, skipping the rest of its execution if
+@var{shell-condition} is true. @var{shell-condition} is a shell expression
+such as a @code{test} command. Tests before @command{AT_FAIL_IF}
+will be executed and may still cause the test group to be skipped.
+You can instantiate this macro many times from within the same test group.
+
+You should use this macro only for very simple failure conditions. If the
+@var{shell-condition} could emit any kind of output you should instead
+use @command{AT_CHECK} like
+@example
+AT_CHECK([@var{shell-condition} || exit 99])
+@end example
+@noindent
+so that such output is properly recorded in the @file{testsuite.log}
+file.
+@end defmac
+
+@defmac AT_SKIP_IF (@var{shell-condition})
+@atindex{SKIP_IF}
+Determine whether the test should be skipped because it requires
+features that are unsupported on the machine under test.
+@var{shell-condition} is a shell expression such as a @code{test}
+command. Tests before @command{AT_SKIP_IF} will be executed
+and may still cause the test group to fail. You can instantiate this
+macro many times from within the same test group.
+
+You should use this macro only for very simple skip conditions. If the
+@var{shell-condition} could emit any kind of output you should instead
+use @command{AT_CHECK} like
+@example
+AT_CHECK([@var{shell-condition} || exit 77])
+@end example
+@noindent
+so that such output is properly recorded in the @file{testsuite.log}
+file.
+@end defmac
+
@defmac AT_XFAIL_IF (@var{shell-condition})
@atindex{XFAIL_IF}
Determine whether the test is expected to fail because it is a known
m4_bregexp(/__file__, [/\([^/]*\)$], [[\1]]))])])dnl
m4_defn([_AT_LINE_base]):__line__])
+# _AT_LINE_ESCAPED
+# ----------------
+# Same as AT_LINE, but already escaped for the shell.
+m4_define([_AT_LINE_ESCAPED], ["AS_ESCAPE(m4_dquote(AT_LINE))"])
+
# _AT_NORMALIZE_TEST_GROUP_NUMBER(SHELL-VAR)
# ------------------------------------------
])
+# AT_FAIL_IF(SHELL-EXPRESSION)
+# -----------------------------
+# Make the test die with hard failure if SHELL-EXPRESSION evaluates to
+# true (exitcode = 0).
+_AT_DEFINE_SETUP([AT_FAIL_IF],
+[dnl
+dnl Try to limit the amount of conditionals that we emit.
+m4_case([$1],
+ [], [],
+ [false], [],
+ [:], [_AT_CHECK_EXIT([], [99])],
+ [true], [_AT_CHECK_EXIT([], [99])],
+ [_AT_CHECK_EXIT([$1], [99])])])
+
+
+# AT_SKIP_IF(SHELL-EXPRESSION)
+# -----------------------------
+# Skip the rest of the group if SHELL-EXPRESSION evaluates to true
+# (exitcode = 0).
+_AT_DEFINE_SETUP([AT_SKIP_IF],
+[dnl
+dnl Try to limit the amount of conditionals that we emit.
+m4_case([$1],
+ [], [],
+ [false], [],
+ [:], [_AT_CHECK_EXIT([], [77])],
+ [true], [_AT_CHECK_EXIT([], [77])],
+ [_AT_CHECK_EXIT([$1], [77])])])
+
+
# AT_XFAIL_IF(SHELL-EXPRESSION)
# -----------------------------
# Set up the test to be expected to fail if SHELL-EXPRESSION evaluates to
[m4_define([AT_ingroup])]dnl
[{ set +x
AS_ECHO(["$at_srcdir/AT_LINE: AS_ESCAPE([[$1]])"])
-_AT_DECIDE_TRACEABLE([$1]) "AS_ESCAPE(m4_dquote(AT_LINE))"
+_AT_DECIDE_TRACEABLE([$1]) _AT_LINE_ESCAPED
( $at_check_trace; [$1]
) >>"$at_stdout" 2>>"$at_stderr"
at_status=$? at_failed=false
[$at_failed && at_fn_log_failure AT_capture_files
$at_traceon; }
])# _AT_CHECK
+
+# _AT_CHECK_EXIT(COMMANDS, [EXIT-STATUS-IF-PASS])
+# -----------------------------------------------
+# Minimal version of _AT_CHECK for AT_SKIP_IF and AT_FAIL_IF.
+m4_define([_AT_CHECK_EXIT],
+[m4_define([AT_ingroup])]dnl
+[AS_ECHO(_AT_LINE_ESCAPED) >"$at_check_line_file"
+m4_ifval([$1], [($1) \
+ && ])at_fn_check_skip $2 "$at_srcdir/AT_LINE"])# _AT_CHECK_EXIT
AT_CHECK([:])
]], [missing AT@&t@_CLEANUP detected])
+AT_CHECK_AT_SYNTAX([AT@&t@_FAIL_IF without AT@&t@_SETUP],
+[[AT_INIT([incomplete test suite])
+AT_FAIL_IF([:])
+]], [AT@&t@_FAIL_IF: missing AT@&t@_SETUP detected])
+
+AT_CHECK_AT_SYNTAX([AT@&t@_SKIP_IF without AT@&t@_SETUP],
+[[AT_INIT([incomplete test suite])
+AT_SKIP_IF([:])
+]], [AT@&t@_SKIP_IF: missing AT@&t@_SETUP detected])
+
AT_CHECK_AT_SYNTAX([AT@&t@_CHECK without AT@&t@_SETUP],
[[AT_INIT([incomplete test suite])
AT_CHECK([:])
[AT_CHECK([grep '2 failed unexpectedly' micro-suite.log], [], [ignore])
AT_CHECK([grep ok micro-suite.log], [1])])
+AT_CHECK_AT_TEST([AT@&t@_FAIL_IF],
+ [AT_FAIL_IF([:])
+ AT_CLEANUP
+ AT_SETUP
+ AT_FAIL_IF([false])
+ AT_CLEANUP
+ AT_SETUP
+ AT_FAIL_IF([test x = y])
+ AT_CLEANUP
+ AT_SETUP
+ AT_FAIL_IF([bah])
+ AT_CLEANUP
+ AT_SETUP
+ AT_FAIL_IF([test x = x])
+ AT_CLEANUP
+ AT_SETUP
+ AT_FAIL_IF([test $foo = x])],
+ [], [1], [stdout], [ignore], [],
+ [AT_CHECK([grep '1 5 failed' stdout], [], [ignore], [ignore])])
+
+AT_CHECK_AT_TEST([AT@&t@_SKIP_IF],
+ [AT_SKIP_IF([:])
+ AT_CLEANUP
+ AT_SETUP
+ AT_SKIP_IF([false])
+ AT_CLEANUP
+ AT_SETUP
+ AT_SKIP_IF([test x = y])
+ AT_CLEANUP
+ AT_SETUP
+ AT_SKIP_IF([bah])
+ AT_CLEANUP
+ AT_SETUP
+ AT_SKIP_IF([test x = x])
+ AT_CLEANUP
+ AT_SETUP
+ AT_SKIP_IF([test $foo = x])],
+ [], [], [], [], [],
+ [AT_CHECK([grep '2.*skipped' micro-suite.log], [], [ignore], [ignore])])
+
AT_CHECK_AT_TEST([Syntax error],
[AT_CHECK([:])
AT_CLEANUP
[# Per BUGS, we have not yet figured out how to run parallel tests cleanly
# under dash and some ksh variants. For now, only run this test under
# limited conditions; help is appreciated in widening this test base.
-AT_CHECK([${CONFIG_SHELL-$SHELL} -c 'test -n "${BASH_VERSION+set}]]dnl
-[[${ZSH_VERSION+set}${TEST_PARALLEL_AUTOTEST+set}"' || exit 77])
+AT_SKIP_IF([${CONFIG_SHELL-$SHELL} -c 'test -z "${BASH_VERSION+set}]]dnl
+[[${ZSH_VERSION+set}${TEST_PARALLEL_AUTOTEST+set}"'])
# The parallel scheduler requires mkfifo and job control to work.
AT_CHECK([mkfifo fifo || exit 77])
AT_CHECK([${CONFIG_SHELL-$SHELL} -c '(set -m && set +m) || exit 77'],
# If the shell handles `-n' well, use it to check the syntax of PROGRAM;
# otherwise, do nothing.
m4_define([AT_CHECK_SHELL_SYNTAX],
-[AS_IF([test "$ac_cv_sh_n_works" = yes],
- [AT_CHECK([/bin/sh -n $1])])])
+[AT_SKIP_IF([test "$ac_cv_sh_n_works" != yes])
+AT_CHECK([/bin/sh -n $1])])
m4_define([AT_CHECK_PERL_SYNTAX],
[AT_CHECK([autom4te_perllibdir=$abs_top_srcdir/lib $PERL -c "$abs_top_builddir"/bin/$1],