autoconf-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Autoconf source repository branch, master, updated. v2.65-90-g


From: Ralf Wildenhues
Subject: [SCM] GNU Autoconf source repository branch, master, updated. v2.65-90-geace0e6
Date: Thu, 17 Jun 2010 20:46:37 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Autoconf source repository".

http://git.sv.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=eace0e6fec4e87e9fc0e931ee191734c6cafb9c5

The branch, master has been updated
       via  eace0e6fec4e87e9fc0e931ee191734c6cafb9c5 (commit)
       via  b426665e77d713bfe4d44b6b27cb1e6e3c942fc6 (commit)
      from  7f65b3b009f562ac0e6e7d84b41d93d12744037b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit eace0e6fec4e87e9fc0e931ee191734c6cafb9c5
Author: Ralf Wildenhues <address@hidden>
Date:   Thu Jun 17 22:44:02 2010 +0200

    Document, test, and fix AT_ARG_OPTION, AT_ARG_OPTION_ARG.
    
    * lib/autotest/general.m4 (_AT_ARG_OPTION): Fix translation of
    hyphens to underscores when turning option names to variables.
    Avoid macro name concatenation garbage with trailing `dnl'.
    (AT_ARG_OPTION, AT_ARG_OPTION_ARG): Overhaul macro description.
    The OPTIONS are space-separated, not comma-separated.  The
    negative form of AT_ARG_OPTION is prefixed with `--no-'.
    * tests/autotest.at (AT@&address@hidden, AT@&address@hidden):
    New tests.
    * NEWS: Update.
    * doc/autoconf.texi (Writing Testsuites): Document AT_ARG_OPTION
    and AT_ARG_OPTION_ARG.
    (testsuite Invocation): Call the thingies passed to the
    testsuite options, not arguments.  Note that the testsuite
    author may add further package-specific options.
    
    Signed-off-by: Ralf Wildenhues <address@hidden>

commit b426665e77d713bfe4d44b6b27cb1e6e3c942fc6
Author: Ralf Wildenhues <address@hidden>
Date:   Thu Jun 17 22:26:30 2010 +0200

    Autotest: enable colored test results.
    
    * lib/autotest/general.m4 (HELP_TUNING_BEGIN): New diversion.
    (HELP_TUNING, HELP_OTHER, HELP_END): Bump diversion numbers.
    (AT_INIT): Accept
    --color and --color=never|auto|always.  If desired, colorize
    test results and testsuite summary on standard output.
    [HELP_TUNING]: Divert content instead to ...
    [HELP_TUNING_BEGIN]: ... this diversion, m4_wrapped until the
    end, when we know whether AT_COLOR_TESTS has been specified.
    (AT_COLOR_TESTS): New macro, set the default for color to auto.
    * doc/autoconf.texi (Writing Testsuites): Document it.
    (testsuite Invocation): Document --color* options.
    * tests/local.at: Call AT_COLOR_TESTS for Autoconf's testsuite.
    * tests/autotest.at (color test results): New test, mirroring
    color.test from Automake.
    * NEWS: Update.
    
    Signed-off-by: Ralf Wildenhues <address@hidden>

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog               |   35 +++++++++
 NEWS                    |    7 ++
 doc/autoconf.texi       |   82 ++++++++++++++++++++-
 lib/autotest/general.m4 |  129 ++++++++++++++++++++++----------
 tests/autotest.at       |  190 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/local.at          |    2 +
 6 files changed, 404 insertions(+), 41 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c5c751f..6e37499 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,38 @@
+2010-06-17  Ralf Wildenhues  <address@hidden>
+
+       Document, test, and fix AT_ARG_OPTION, AT_ARG_OPTION_ARG.
+       * lib/autotest/general.m4 (_AT_ARG_OPTION): Fix translation of
+       hyphens to underscores when turning option names to variables.
+       Avoid macro name concatenation garbage with trailing `dnl'.
+       (AT_ARG_OPTION, AT_ARG_OPTION_ARG): Overhaul macro description.
+       The OPTIONS are space-separated, not comma-separated.  The
+       negative form of AT_ARG_OPTION is prefixed with `--no-'.
+       * tests/autotest.at (AT@&address@hidden, AT@&address@hidden):
+       New tests.
+       * NEWS: Update.
+       * doc/autoconf.texi (Writing Testsuites): Document AT_ARG_OPTION
+       and AT_ARG_OPTION_ARG.
+       (testsuite Invocation): Call the thingies passed to the
+       testsuite options, not arguments.  Note that the testsuite
+       author may add further package-specific options.
+
+       Autotest: enable colored test results.
+       * lib/autotest/general.m4 (HELP_TUNING_BEGIN): New diversion.
+       (HELP_TUNING, HELP_OTHER, HELP_END): Bump diversion numbers.
+       (AT_INIT): Accept
+       --color and --color=never|auto|always.  If desired, colorize
+       test results and testsuite summary on standard output.
+       [HELP_TUNING]: Divert content instead to ...
+       [HELP_TUNING_BEGIN]: ... this diversion, m4_wrapped until the
+       end, when we know whether AT_COLOR_TESTS has been specified.
+       (AT_COLOR_TESTS): New macro, set the default for color to auto.
+       * doc/autoconf.texi (Writing Testsuites): Document it.
+       (testsuite Invocation): Document --color* options.
+       * tests/local.at: Call AT_COLOR_TESTS for Autoconf's testsuite.
+       * tests/autotest.at (color test results): New test, mirroring
+       color.test from Automake.
+       * NEWS: Update.
+
 2010-06-15  Ralf Wildenhues  <address@hidden>
 
        Avoid texinfo bug with backslashes in macro arguments.
diff --git a/NEWS b/NEWS
index 3e1155c..eecb9f6 100644
--- a/NEWS
+++ b/NEWS
@@ -31,6 +31,13 @@ GNU Autoconf NEWS - User visible changes.
 ** In configure scripts, loading CONFIG_SITE no longer searches PATH,
    and problems in loading the configuration site files are diagnosed.
 
+** Autotest testsuites may optionally provide colored test results.
+
+** The previously undocumented Autotest macros AT_ARG_OPTION and
+   AT_ARG_OPTION_ARG have seen bug fixes and are documented now.
+   AT_ARG_OPTION has been changed in that the negative of a long option
+   --OPTION is now --no-OPTION rather than --noOPTION.
+
 * Major changes in Autoconf 2.65 (2009-11-21) [stable]
   Released by Eric Blake, based on git versions 2.64.*.
 
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 6d6555c..f6eb362 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -23408,6 +23408,72 @@ The @var{copyright-notice} shows up in both the head of
 @command{testsuite} and in @samp{testsuite --version}.
 @end defmac
 
address@hidden AT_ARG_OPTION (@var{options}, @var{help-text}, @
+  @ovar{action-if-given}, @ovar{action-if-not-given})
address@hidden
+Accept options from the space-separated list @var{options}, a list that
+has leading dashes removed from the options.  Long options will be
+prefixed with @samp{--}, single-character options with @samp{-}.  The
+first word in this list is the primary @var{option}, any others are
+assumed to be short-hand aliases.  The variable associated with it
+is @address@hidden, with any dashes in @var{option} replaced
+with underscores.
+
+If the user passes @address@hidden to the @command{testsuite},
+the variable will be set to @samp{:}.  If the user does not pass the
+option, or passes @address@hidden, then the variable will be
+set to @samp{false}.
+
address@hidden is run each time the option is encountered; here,
+the variable @code{at_optarg} will be set to @samp{:} or @samp{false} as
+appropriate.  @code{at_optarg} is actually just a copy of
address@hidden@var{option}}.
+
address@hidden will be run once after option parsing is
+complete and if no option from @var{options} was used.
+
address@hidden is added to the end of the list of options shown in
address@hidden --help} (@pxref{AS_HELP_STRING}).
+
+It it recommended that you use a package-specific prefix to @var{options}
+names in order to avoid clashes with future Autotest built-in options.
address@hidden defmac
+
address@hidden AT_ARG_OPTION_ARG (@var{options}, @var{help-text}, @
+  @ovar{action-if-given}, @ovar{action-if-not-given})
address@hidden
+Accept options with arguments from the space-separated list
address@hidden, a list that has leading dashes removed from the options.
+Long options will be prefixed with @samp{--}, single-character options
+with @samp{-}.  The first word in this list is the primary @var{option},
+any others are assumed to be short-hand aliases.  The variable associated
+with it is @address@hidden, with any dashes in @var{option}
+replaced with underscores.
+
+If the user passes @address@hidden@var{arg}} or
address@hidden@var{option} @var{arg}} to the @command{testsuite}, the
+variable will be set to @address@hidden
+
address@hidden is run each time the option is encountered; here,
+the variable @code{at_optarg} will be set to @address@hidden
address@hidden is actually just a copy of @address@hidden
+
address@hidden will be run once after option parsing is
+complete and if no option from @var{options} was used.
+
address@hidden is added to the end of the list of options shown in
address@hidden --help} (@pxref{AS_HELP_STRING}).
+
+It it recommended that you use a package-specific prefix to @var{options}
+names in order to avoid clashes with future Autotest built-in options.
address@hidden defmac
+
address@hidden AT_COLOR_TESTS
address@hidden
+Enable colored test results by default when the output is connected to
+a terminal.
address@hidden defmac
+
 @defmac AT_TESTED (@var{executables})
 @atindex{TESTED}
 Log the file name and answer to @option{--version} of each program in
@@ -23679,7 +23745,7 @@ individual unit tests.
 @section Running @command{testsuite} Scripts
 @cindex @command{testsuite}
 
-Autotest test suites support the following arguments:
+Autotest test suites support the following options:
 
 @table @option
 @item --help
@@ -23798,6 +23864,14 @@ then concurrently running tests will finish before 
exiting.
 Force more verbosity in the detailed output of what is being done.  This
 is the default for debugging scripts.
 
address@hidden --color
address@hidden address@hidden@r{|address@hidden|address@hidden
+Enable colored test results.  Without an argument, or with @samp{always},
+test results will be colored.  With @samp{never}, color mode is turned
+off.  Otherwise, if either the macro @code{AT_COLOR_TESTS} is used by
+the testsuite author, or the argument @samp{auto} is given, then test
+results are colored if standard output is connected to a terminal.
+
 @item --debug
 @itemx -d
 Do not remove the files after a test group was performed ---but they are
@@ -23817,6 +23891,12 @@ during the last non-debugging test run.
 Trigger shell tracing of the test groups.
 @end table
 
+Besides these options accepted by every Autotest testsuite, the
+testsuite author might have added package-specific options
+via the @code{AT_ARG_OPTION} and @code{AT_ARG_OPTION_ARG} macros
+(@pxref{Writing Testsuites}); refer to @command{testsuite --help} and
+the package documentation for details.
+
 
 @node Making testsuite Scripts
 @section Making @command{testsuite} Scripts
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index 5f965fd..57b3fef 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -62,8 +62,10 @@ Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 
2007, 2008,
 #  - HELP_MODES
 #    Modes help text.  Additional modes can be appended as self-contained
 #    cat'd here-docs as generated by AS_HELP_STRING.
+#  - HELP_TUNING_BEGIN
+#    Tuning help text.  This is for Autotest-provided text.
 #  - HELP_TUNING
-#    Tuning help text.  Additional tuning options can be appended as
+#    Additional tuning options' help text can be appended here as
 #    self-contained cat'd here-docs as generated by AS_HELP_STRING.
 #  - HELP_OTHER
 #    User help can be appended to this as self-contained cat'd here-docs.
@@ -104,9 +106,10 @@ m4_define([_m4_divert(PARSE_ARGS)],         201)
 m4_define([_m4_divert(PARSE_ARGS_END)],     202)
 m4_define([_m4_divert(HELP)],               300)
 m4_define([_m4_divert(HELP_MODES)],         301)
-m4_define([_m4_divert(HELP_TUNING)],        302)
-m4_define([_m4_divert(HELP_OTHER)],         303)
-m4_define([_m4_divert(HELP_END)],           304)
+m4_define([_m4_divert(HELP_TUNING_BEGIN)],  302)
+m4_define([_m4_divert(HELP_TUNING)],        303)
+m4_define([_m4_divert(HELP_OTHER)],         304)
+m4_define([_m4_divert(HELP_END)],           305)
 m4_define([_m4_divert(VERSION)],            350)
 m4_define([_m4_divert(VERSION_NOTICES)],    351)
 m4_define([_m4_divert(VERSION_END)],        352)
@@ -423,6 +426,8 @@ m4_define([_AT_FINISH],
 [m4_ifdef([AT_ingroup], [m4_fatal([missing AT_CLEANUP detected])])dnl
 m4_divert_text([DEFAULTS],
 [
+# Whether to enable colored test results.
+at_color=m4_ifdef([AT_color], [AT_color], [no])
 # List of the tested programs.
 at_tested='m4_ifdef([AT_tested],
   [m4_translit(m4_dquote(m4_defn([AT_tested])), [ ], m4_newline)])'
@@ -492,6 +497,19 @@ do
        at_clean=:
        ;;
 
+    --color )
+       at_color=always
+       ;;
+    --color=* )
+       case $at_optarg in
+       no | never | none) at_color=never ;;
+       auto | tty | if-tty) at_color=auto ;;
+       always | yes | force) at_color=always ;;
+       *) at_optname=`echo " $at_option" | sed 's/^ //; s/=.*//'`
+          AS_ERROR([unrecognized argument to $at_optname: $at_optarg]) ;;
+       esac
+       ;;
+
     --debug | -d )
        at_debug_p=:
        ;;
@@ -663,6 +681,17 @@ else
   # Sort the tests, removing duplicates.
   at_groups=`AS_ECHO(["$at_groups"]) | tr ' ' "$as_nl" | sort -nu`
 fi
+
+if test x"$at_color" = xalways \
+   || { test x"$at_color" = xauto && test -t 1; }; then
+  at_red=`printf '\033@<:@0;31m'`
+  at_grn=`printf '\033@<:@0;32m'`
+  at_lgn=`printf '\033@<:@1;32m'`
+  at_blu=`printf '\033@<:@1;34m'`
+  at_std=`printf '\033@<:@m'`
+else
+  at_red= at_grn= at_lgn= at_blu= at_std=
+fi
 m4_divert_pop([PARSE_ARGS_END])dnl
 m4_divert_push([HELP])dnl
 
@@ -697,13 +726,17 @@ Operation modes:
   -l, --list     describes all the tests, or the selected TESTS
 _ATEOF
 m4_divert_pop([HELP_MODES])dnl
-m4_divert_push([HELP_TUNING])dnl
+m4_wrap([m4_divert_push([HELP_TUNING_BEGIN])dnl
 cat <<_ATEOF || at_write_fail=1
 
 dnl extra quoting prevents emacs whitespace mode from putting tabs in output
 Execution tuning:
   -C, --directory=DIR
 [                 change to directory DIR before starting]
+      --color[[=never|auto|always]]
+[                 ]m4_ifdef([AT_color],
+                     [disable colored test results, or enable even without 
terminal],
+                     [enable colored test results on terminal, or always])
   -j, --jobs[[=N]]
 [                 Allow N jobs at once; infinite jobs with no arg (default 1)]
   -k, --keywords=KEYWORDS
@@ -717,7 +750,7 @@ Execution tuning:
 [                 default for debugging scripts]
   -x, --trace    enable tests shell tracing
 _ATEOF
-m4_divert_pop([HELP_TUNING])dnl
+m4_divert_pop([HELP_TUNING_BEGIN])])dnl
 m4_divert_push([HELP_END])dnl
 cat <<_ATEOF || at_write_fail=1
 
@@ -1156,35 +1189,40 @@ _ATEOF
        at_msg="UNEXPECTED PASS"
        at_res=xpass
        at_errexit=$at_errexit_p
+       at_color=$at_red
        ;;
     no:0)
        at_msg="ok"
        at_res=pass
        at_errexit=false
+       at_color=$at_grn
        ;;
     *:77)
        at_msg='skipped ('`cat "$at_check_line_file"`')'
        at_res=skip
        at_errexit=false
+       at_color=$at_blu
        ;;
     no:* | *:99)
        at_msg='FAILED ('`cat "$at_check_line_file"`')'
        at_res=fail
        at_errexit=$at_errexit_p
+       at_color=$at_red
        ;;
     yes:*)
        at_msg='expected failure ('`cat "$at_check_line_file"`')'
        at_res=xfail
        at_errexit=false
+       at_color=$at_lgn
        ;;
   esac
   echo "$at_res" > "$at_job_dir/$at_res"
   # In parallel mode, output the summary line only afterwards.
   if test $at_jobs -ne 1 && test -n "$at_verbose"; then
-    AS_ECHO(["$at_desc_line $at_msg"])
+    AS_ECHO(["$at_desc_line $at_color$at_msg$at_std"])
   else
     # Make sure there is a separator even with long titles.
-    AS_ECHO([" $at_msg"])
+    AS_ECHO([" $at_color$at_msg$at_std"])
   fi
   at_log_msg="$at_group. $at_desc ($at_setup_line): $at_msg"
   case $at_status in
@@ -1485,12 +1523,14 @@ if $at_errexit_p && test $at_unexpected_count != 0; then
     at_result="$at_result $at_were run, one failed"
   fi
   at_result="$at_result unexpectedly and inhibited subsequent tests."
+  at_color=$at_red
 else
   # Don't you just love exponential explosion of the number of cases?
+  at_color=$at_red
   case $at_xpass_count:$at_fail_count:$at_xfail_count in
     # So far, so good.
-    0:0:0) at_result="$at_result $at_were successful." ;;
-    0:0:*) at_result="$at_result behaved as expected." ;;
+    0:0:0) at_result="$at_result $at_were successful." at_color=$at_grn ;;
+    0:0:*) at_result="$at_result behaved as expected." at_color=$at_lgn ;;
 
     # Some unexpected failures
     0:*:0) at_result="$at_result $at_were run,
@@ -1538,10 +1578,10 @@ $at_skip_count tests were skipped." ;;
 esac
 
 if test $at_unexpected_count = 0; then
-  echo "$at_result"
+  echo "$at_color$at_result$at_std"
   echo "$at_result" >&AS_MESSAGE_LOG_FD
 else
-  echo "ERROR: $at_result" >&2
+  echo "${at_color}ERROR: $at_result$at_std" >&2
   echo "ERROR: $at_result" >&AS_MESSAGE_LOG_FD
   {
     echo
@@ -1637,8 +1677,10 @@ m4_ifdef([AT_case_no],[m4_undefine([AT_case_no])])dnl
 m4_ifdef([AT_case_arg],[m4_undefine([AT_case_arg])])dnl
 m4_foreach([AT_option], m4_split(m4_normalize([$1]),[[ \|]+]),
 [m4_define_default([AT_first_option],AT_option)dnl
+m4_define_default([AT_first_option_tr],
+                 [m4_bpatsubst(m4_defn([AT_first_option]), -, [_])])dnl
 m4_append([AT_case],m4_if(m4_len(AT_option),1,[],[-])[-]AT_option, [ | ])dnl
-m4_append([AT_case_no],[--no]AT_option, [ | ])dnl
+m4_append([AT_case_no],[--no-]AT_option, [ | ])dnl
 m4_append([AT_case_arg],
          m4_if(m4_len(AT_option),1,[],[-])[-]AT_option[=*], [ | ])dnl
 ])dnl m4_foreach AT_option
@@ -1651,31 +1693,31 @@ m4_divert_once([PARSE_ARGS_BEGIN],
 ])dnl
 m4_divert_text([PARSE_ARGS_BEGIN],
 [dnl Provide a default value for options without arguments.
-m4_ifvaln([$3],,[at_arg_[]m4_bpatsubst([AT_first_option], -, _)=false])dnl
-at_arg_given_[]m4_bpatsubst([AT_first_option], -, _)=false
+m4_ifvaln([$3],,[at_arg_[]AT_first_option_tr=false])dnl
+at_arg_given_[]AT_first_option_tr=false
 ])dnl m4_divert_text DEFAULTS
 m4_divert_text([PARSE_ARGS],
 [dnl Parse the options and args when necessary.
 m4_ifvaln([$3],
 [    AT_case )
-       at_prev=--m4_bpatsubst([AT_first_option], -, _)
+       at_prev=--AT_first_option_tr
        ;;
     AT_case_arg )
-       at_arg_[]m4_bpatsubst([AT_first_option], -, _)=$at_optarg
-       at_arg_given_[]m4_bpatsubst([AT_first_option], -, _)=:
+       at_arg_[]AT_first_option_tr=$at_optarg
+       at_arg_given_[]AT_first_option_tr=:
        $4
        ;;],
 [    AT_case )
        at_optarg=:
-       at_arg_[]m4_bpatsubst([AT_first_option], -, _)=:
-       at_arg_given_[]m4_bpatsubst([AT_first_option], -, _)=:
-       m4_ifval([$4],[$4])dnl
+       at_arg_[]AT_first_option_tr=:
+       at_arg_given_[]AT_first_option_tr=:
+       m4_ifval([$4],[$4])[]dnl
        ;;
     AT_case_no )
        at_optarg=false
-       at_arg_[]m4_bpatsubst([AT_first_option], -, _)=false
-       at_arg_given_[]m4_bpatsubst([AT_first_option], -, _)=:
-       m4_ifval([$4],[$4])dnl
+       at_arg_[]AT_first_option_tr=false
+       at_arg_given_[]AT_first_option_tr=:
+       m4_ifval([$4],[$4])[]dnl
        ;;])dnl m4_ifvaln $3
 ])dnl m4_divert_text PARSE_ARGS
 m4_ifvaln([$5],
@@ -1686,7 +1728,7 @@ m4_ifvaln([$5],
 ##])dnl m4_divert_once PARSE_ARGS_END
 m4_divert_text([PARSE_ARGS_END],
 [
-AS_IF([$at_arg_given_[]m4_bpatsubst([AT_first_option], -, _)],,[$5])dnl
+AS_IF([$at_arg_given_[]AT_first_option_tr],,[$5])dnl
 ])dnl m4_divert_text PARSE_ARGS_END
 ])dnl m4_ifvaln $5
 ])dnl _AT_ARG_OPTION
@@ -1694,41 +1736,42 @@ AS_IF([$at_arg_given_[]m4_bpatsubst([AT_first_option], 
-, _)],,[$5])dnl
 
 # AT_ARG_OPTION(OPTIONS,HELP-TEXT,[ACTION-IF-GIVEN],[ACTION-IF-NOT-GIVEN])
 # ------------------------------------------------------------------------
-# Accept a set of OPTIONS with arguments.  Add HELP-TEXT to the HELP_OTHER
-# diversion.
+# Accept a list of space-separated OPTIONS, all aliases of the first one.
+# Add HELP-TEXT to the HELP_OTHER diversion.
 #
-# Preceding dashes should not be passed into OPTIONS.  Users will be required
+# Leading dashes should not be passed in OPTIONS.  Users will be required
 # to pass `--' before long options and `-' before single character options.
 #
 # $at_arg_OPTION will be set to `:' if this option is received, `false' if
-# if --noOPTION is received, and `false' by default.
+# if --no-OPTION is received, and `false' by default.
 #
-# Run ACTION-IF-GIVEN each time an option in OPTIONS is encountered with
-# $at_optarg set to `:' or `false' as appropriate.  $at_optarg is actually
-# just a copy of $at_arg_OPTION.
+# Run ACTION-IF-GIVEN each time an option in OPTIONS is encountered; here,
+# $at_optarg will be set to `:' or `false' as appropriate.  $at_optarg is
+# actually just a copy of $at_arg_OPTION.
 #
-# ACTION-IF-NOT-GIVEN will be run once after option parsing is complete
-# if no option from OPTIONS was found.
+# ACTION-IF-NOT-GIVEN will be run once after option parsing is complete and
+# if no option from OPTIONS was used.
 m4_defun([AT_ARG_OPTION],[_AT_ARG_OPTION([$1],[$2],,[$3],[$4])])
 
 
 # AT_ARG_OPTION_ARG(OPTIONS,HELP-TEXT,[ACTION-IF-GIVEN],[ACTION-IF-NOT-GIVEN])
 # ----------------------------------------------------------------------------
-# Accept a set of OPTIONS with arguments, seperated by commas.  Add HELP-TEXT
-# to the HELP_OTHER diversion.
+# Accept a set of space-separated OPTIONS with arguments, all aliases of the
+# first one.  Add HELP-TEXT to the HELP_OTHER diversion.
 #
-# Preceding dashes should not be passed into OPTIONS.  Users will be required
+# Leading dashes should not be passed in OPTIONS.  Users will be required
 # to pass `--' before long options and `-' before single character options.
 #
 # By default, any argument to these options will be assigned to the shell
 # variable $at_arg_OPTION, where OPTION is the first option in OPTIONS with
 # any `-' characters replaced with `_'.
 #
-# Run ACTION-IF-GIVEN each time an option in OPTIONS is encountered with
-# $at_optarg set.  $at_optarg is actually just a copy of $at_arg_OPTION.
+# Run ACTION-IF-GIVEN each time an option in OPTIONS is encountered; here,
+# $at_optarg will be set to the option argument.  $at_optarg is actually just
+# a copy of $at_arg_OPTION.
 #
 # ACTION-IF-NOT-GIVEN will be run once after option parsing is complete
-# if no option from OPTIONS was found.
+# and if no option from OPTIONS was used.
 m4_defun([AT_ARG_OPTION_ARG],[_AT_ARG_OPTION([$1],[$2],1,[$3],[$4])])
 
 
@@ -1754,6 +1797,12 @@ m4_define([AT_COPYRIGHT],
 [m4_default([$2], [m4_newline])([$1])])])# AT_COPYRIGHT
 
 
+# AT_COLOR_TESTS
+# --------------
+# Enable colored test results if standard error is connected to a terminal.
+m4_define([AT_COLOR_TESTS],
+[m4_define([AT_color], [auto])])
+
 # AT_SETUP(DESCRIPTION)
 # ---------------------
 # Start a group of related tests, all to be executed in the same subshell.
diff --git a/tests/autotest.at b/tests/autotest.at
index ad38b7a..fd3787a 100644
--- a/tests/autotest.at
+++ b/tests/autotest.at
@@ -1127,6 +1127,109 @@ AT_CHECK_KEYS([-l], [.{80}], [1], [.{87}], [0])
 
 AT_CLEANUP
 
+
+## ------------- ##
+## AT_ARG_OPTION ##
+## ------------- ##
+
+AT_CHECK_AT([AT@&address@hidden,
+[[
+AT_INIT([artificial test suite])
+AT_ARG_OPTION([frob fro fr f],
+              [AS_HELP_STRING([-f, --frob], [frobnicate the test run])],
+             [frob=$at_optarg], [frob=default])
+AT_ARG_OPTION([opt-with-hyphen],
+              [AS_HELP_STRING([--opt-with-hyphen], [option name with hypen])])
+AT_ARG_OPTION([ping],
+             [AS_HELP_STRING([--ping], [ping on every encounter])],
+             [echo ping])
+AT_SETUP([test argument handling])
+AT_CHECK([test "$frob" = "$FROB"])
+AT_CHECK([test "$at_arg_frob" = "$FROB_ARG"])
+AT_CLEANUP
+AT_SETUP([test hyphen normalization])
+AT_CHECK([test "$at_arg_opt_with_hyphen" = "$expected"])
+AT_CLEANUP
+]],
+[], [], [stdout], [], [],
+[# We already invoked --help.
+AT_CHECK([grep '  -f, --frob.*frobnicate' stdout], [], [ignore])
+for args in \
+  '1 FROB=default FROB_ARG=false' \
+  '1 -f FROB=: FROB_ARG=:' \
+  '1 --fr FROB=: FROB_ARG=:' \
+  '1 --fro FROB=: FROB_ARG=:' \
+  '1 --frob FROB=: FROB_ARG=:' \
+  '1 --no-f FROB=false FROB_ARG=false' \
+  '1 --no-fr FROB=false FROB_ARG=false' \
+  '1 --no-fro FROB=false FROB_ARG=false' \
+  '1 --no-frob FROB=false FROB_ARG=false' \
+  '2 expected=false' \
+  '2 --opt-with-hyphen expected=:' \
+  '2 --no-opt-with-hyphen expected=false'
+do
+  AT_CHECK([$CONFIG_SHELL ./micro-suite -x $args], [], [ignore])
+done
+AT_CHECK([$CONFIG_SHELL ./micro-suite 2 --ping --no-ping --ping 
expected=false],
+        [], [stdout])
+AT_CHECK([grep -c ping stdout], [], [[3
+]])
+], [--help])
+
+
+## ----------------- ##
+## AT_ARG_OPTION_ARG ##
+## ----------------- ##
+
+AT_CHECK_AT([AT@&address@hidden,
+[[
+AT_INIT([artificial test suite])
+AT_ARG_OPTION_ARG([frob fro fr f],
+                 [AS_HELP_STRING([-f, --frob=FOO], [frobnicate FOO])],
+                 [frob=$at_optarg], [frob=default])
+AT_ARG_OPTION_ARG([opt-with-hyphen],
+                 [AS_HELP_STRING([--opt-with-hyphen=ARG],
+                                 [option name with hypen])])
+AT_ARG_OPTION_ARG([ping],
+                 [AS_HELP_STRING([--ping], [ping on every encounter])],
+                 [echo ping])
+AT_SETUP([test argument handling])
+AT_CHECK([test "$frob" = "$FROB"])
+AT_CHECK([test "$at_arg_frob" = "$FROB_ARG"])
+AT_CLEANUP
+AT_SETUP([test hyphen normalization])
+AT_CHECK([test "$at_arg_opt_with_hyphen" = "$expected"])
+AT_CLEANUP
+]],
+[], [], [stdout], [], [],
+[# We already invoked --help.
+AT_CHECK([grep '  -f, --frob.*frobnicate' stdout], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -x --frob], [1], [ignore], [stderr])
+AT_CHECK([grep 'requires an argument' stderr], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite -x --no-frob], [1], [ignore], [stderr])
+AT_CHECK([grep 'invalid option' stderr], [], [ignore])
+for args in \
+  '1 FROB=default FROB_ARG=' \
+  '1 -f bar FROB=bar FROB_ARG=bar' \
+  '1 --fr bar FROB=bar FROB_ARG=bar' \
+  '1 --fro bar FROB=bar FROB_ARG=bar' \
+  '1 --frob bar FROB=bar FROB_ARG=bar' \
+  '1 -f=bar FROB=bar FROB_ARG=bar' \
+  '1 --fr=bar FROB=bar FROB_ARG=bar' \
+  '1 --fro=bar FROB=bar FROB_ARG=bar' \
+  '1 --frob=bar FROB=bar FROB_ARG=bar' \
+  '2 expected=' \
+  '2 --opt-with-hyphen=baz expected=baz'
+do
+  AT_CHECK([$CONFIG_SHELL ./micro-suite -x $args], [], [ignore])
+done
+AT_CHECK([$CONFIG_SHELL ./micro-suite 2 --ping=1 --ping=2 expected=],
+        [], [stdout])
+AT_CHECK([grep -c ping stdout], [], [[2
+]])
+], [--help])
+
+
 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
@@ -1402,6 +1505,93 @@ AT_CHECK([test -s sigpipe-stamp || test ! -f 
micro-suite.dir/7/micro-suite.log],
 
 AT_CLEANUP
 
+
+# --color
+AT_CHECK_AT_TEST([colored test results],
+  [AT_CHECK([:])
+   AT_CLEANUP
+   AT_SETUP([fail])
+   AT_CHECK([exit 1])
+   AT_CLEANUP
+   AT_SETUP([xpass])
+   AT_XFAIL_IF([:])
+   AT_CHECK([:])
+   AT_CLEANUP
+   AT_SETUP([xfail])
+   AT_XFAIL_IF([:])
+   AT_CHECK([exit 1])
+   AT_CLEANUP
+   AT_SETUP([skip])
+   AT_CHECK([exit 77])
+   AT_CLEANUP
+   AT_SETUP([hardfail])
+   AT_XFAIL_IF([:])
+   AT_CHECK([exit 99])
+], [], [], [], [], [], [
+
+TERM=ansi
+export TERM
+
+red=`printf '\033@<:@0;31m'`
+grn=`printf '\033@<:@0;32m'`
+lgn=`printf '\033@<:@1;32m'`
+blu=`printf '\033@<:@1;34m'`
+std=`printf '\033@<:@m'`
+
+# Check that grep can parse nonprinting characters.
+# BSD 'grep' works from a pipe, but not a seekable file.
+# GNU or BSD 'grep -a' works on files, but is not portable.
+AT_CHECK([case `echo "$std" | grep .` in #'' restore font-lock
+           $std) :;;
+           *) Exit 77;;
+         esac], [], [ignore], [],
+        [echo "grep can't parse nonprinting characters" >&2])
+
+if echo 'ab*c' | grep -F 'ab*c' >/dev/null 2>&1; then
+  FGREP="grep -F"
+else
+  FGREP=fgrep
+fi
+
+# No color.
+AT_CHECK([$CONFIG_SHELL ./micro-suite], [1], [stdout], [stderr])
+for color in "$red" "$grn" "$lgn" "$blu"; do
+  AT_CHECK([cat stdout stderr | $FGREP "$color"], [1])
+done
+
+# Color of test group results.
+AT_CHECK([$CONFIG_SHELL ./micro-suite --color=always], [1], [stdout], [stderr])
+AT_CHECK([cat stdout | grep " only " | $FGREP "$grn"], [], [ignore])
+AT_CHECK([cat stdout | grep " fail " | $FGREP "$red"], [], [ignore])
+AT_CHECK([cat stdout | grep " xfail " | $FGREP "$lgn"], [], [ignore])
+AT_CHECK([cat stdout | grep " xpass " | $FGREP "$red"], [], [ignore])
+AT_CHECK([cat stdout | grep " skip " | $FGREP "$blu"], [], [ignore])
+AT_CHECK([cat stdout | grep " hardfail " | $FGREP "$red"], [], [ignore])
+AT_CHECK([cat stderr | grep ERROR | $FGREP "$red"], [], [ignore])
+
+# The summary is green if all tests were successful, light green if all
+# behaved as expected, and red otherwise.
+AT_CHECK([$CONFIG_SHELL ./micro-suite --color=always 1 -k skip],
+        [0], [stdout])
+AT_CHECK([cat stdout | grep 'test.*successful' | $FGREP "$grn"],
+        [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite --color=always 1 -k xfail -k skip],
+        [0], [stdout])
+AT_CHECK([cat stdout | grep 'as expected' | $FGREP "$lgn"], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite --color=always -k fail],
+        [1], [ignore], [stderr])
+AT_CHECK([cat stderr | grep ERROR | $FGREP "$red"], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite --color=always -k xpass],
+        [1], [ignore], [stderr])
+AT_CHECK([cat stderr | grep ERROR | $FGREP "$red"], [], [ignore])
+AT_CHECK([$CONFIG_SHELL ./micro-suite --color=always -k hardfail],
+        [1], [ignore], [stderr])
+AT_CHECK([cat stderr | grep ERROR | $FGREP "$red"], [], [ignore])
+# Reset color on verbose output.
+printf %s\\n "$std"
+], [1])
+
+
 ## ------------------- ##
 ## srcdir propagation. ##
 ## ------------------- ##
diff --git a/tests/local.at b/tests/local.at
index a812c43..39360ef 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -25,6 +25,8 @@ m4_pattern_allow([^m4_(define|shift)$])
 # Programs this package provides
 AT_TESTED([autom4te autoconf autoheader autoupdate autoreconf ifnames])
 
+# Enable colored test output.
+AT_COLOR_TESTS
 
 ## ---------------- ##
 ## Utility macros.  ##


hooks/post-receive
-- 
GNU Autoconf source repository



reply via email to

[Prev in Thread] Current Thread [Next in Thread]