]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
introduce AT_SKIP_IF and AT_FAIL_IF
authorPaolo Bonzini <bonzini@gnu.org>
Sun, 12 Jul 2009 10:22:39 +0000 (12:22 +0200)
committerPaolo Bonzini <bonzini@gnu.org>
Mon, 13 Jul 2009 19:46:08 +0000 (21:46 +0200)
* 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.

ChangeLog
NEWS
doc/autoconf.texi
lib/autotest/general.m4
tests/autotest.at
tests/local.at

index 67520c05c6411a7da2d936eb05d1383a1bd87bcf..565b9e9e0e3353988e867e34c9ab522065d0b007 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+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.
diff --git a/NEWS b/NEWS
index 93a09c9e0713f20d4464b67a01ecaa49d6fb6b0c..ef67c77cb15631aa0604a9a404a77c8b7bf24ebd 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -23,7 +23,7 @@ GNU Autoconf NEWS - User visible changes.
    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
index 3528f53251052900c4f6e38ad12ff032ac381b0d..0802c2a072ef3be101a856c86cdd38e7eda217c6 100644 (file)
@@ -22653,6 +22653,45 @@ If the current test group fails, log the contents of @var{file}.
 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
index 6032796668d832ce17d513b6e342a9bb0f94dd94..b9beb0e65d112eeeb87c461be8744b765432a643 100644 (file)
@@ -168,6 +168,11 @@ m4_define([AT_LINE],
                         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)
 # ------------------------------------------
@@ -1775,6 +1780,36 @@ m4_divert_push([TEST_SCRIPT])dnl
 ])
 
 
+# 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
@@ -2090,7 +2125,7 @@ m4_define([_AT_CHECK],
 [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
@@ -2107,3 +2142,12 @@ m4_ifvaln([$5$6], [AS_IF($at_failed, [$5], [$6])])]dnl
 [$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
index 438c01dcff43e4f4ddb5596e3b9224ba38f0aaff..0063c4a0c2ec21a007e79b21b2b112b0acffe242 100644 (file)
@@ -169,6 +169,16 @@ AT_SETUP([only test])
 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([:])
@@ -263,6 +273,46 @@ AT_CHECK_AT_TEST([Hard fail],
   [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
@@ -990,8 +1040,8 @@ m4_define([AT_SKIP_PARALLEL_TESTS],
 [# 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'],
index 9beea3ac558c7a1b3dd3deea0e0031d7e6382584..8a81835b4b6e2e62ecbc35271d2927f46c3ac3bd 100644 (file)
@@ -50,8 +50,8 @@ AT_CHECK([$at_diff "$1" "$2"])
 # 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],