autoconf-patches
[Top][All Lists]
Advanced

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

AT_TESTED issues


From: Eric Blake-1
Subject: AT_TESTED issues
Date: Thu, 18 Oct 2007 09:15:03 -0700 (PDT)

I noticed a couple of bugs with AT_TESTED.  First, the testsuite would run 
$at_program --version without redirecting input; some (broken) programs then 
try to run interactively if the inherited stdin is a tty, which hangs the 
testsuite.  (hmm, maybe we should run the entire testsuite with stdin 
redirected, similarly to how configure does things?)

Next, the code for AT_TESTED was trying to create a newline-separated list
of 
programs, and the documentation claimed that the list is tolerant of 
duplicates.  But in autoconf's case, the list came out with just spaces. 
Also, 
it was possible to inject duplicates, wasting time by running --version 
multiple times on those duplicates, and violating the docs.  AT_KEYWORDS
also 
permitted duplicates, but at least it wasn't spawning extra processes.

Two patches here - the first is a cleanup patch (moving function
declarations 
to after testsuite --version handling, to speed up --version; and cleaning
up 
80-column lines), the second fixes the AT_TESTED bug by making
m4_append_uniq 
smarter about duplicate avoidance, and adding m4_append_uniq_w to make the 
idiom of whitespace separated lists of unique words easier.

2007-10-18  Eric Blake  <address@hidden>

        Fix AT_TESTED, AT_KEYWORDS.
        * lib/m4sugar/m4sugar.m4 (m4_append_uniq): Warn if separator
        occurs in string, as duplicates may be added.
        (_m4_append_uniq): New helper macro.
        (m4_append_uniq_w): New macro.
        * lib/autotest/general.m4 (AT_TESTED, AT_KEYWORDS): Fix
        duplication bug by using new macro.
        (AT_INIT) <at_tested>: Restore newline separators.  Invoke tested
        programs with stdin redirected, so programs that don't
        understand --version won't try to behave interactively.
        * tests/autotest.at (Tested programs): Catch this bug.
        * tests/m4sugar.at (m4@&address@hidden): Test new macro.
        * tests/local.at (AT_TESTED): Add m4, perl.
        * doc/autoconf.texi (Text processing Macros): Document
        m4_append_uniq_w, and update text on m4_append.
        * NEWS: Document the addition.

>From 78fd34e4f7e0aa871e5bcc4150bdea70cb6c9c8a Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Wed, 17 Oct 2007 20:59:01 -0600
Subject: [PATCH] Function cleanup.

* lib/autotest/general.m4 (_AT_CREATE_DEBUGGING_SCRIPT): Convert
from m4 macro...
(AT_INIT) <at_func_create_debugging_script>: ...to shell
function.
(AT_INIT): Defer function declarations until after --help,
--version.  Format functions consistently, trying to fit in 80
columns.
(TEST_FUNCTIONS): Based on recent changes, rename...
(TEST_GROUPS): ...to this.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog               |   11 ++++
 lib/autotest/general.m4 |  126
++++++++++++++++++++++++++++-------------------
 2 files changed, 87 insertions(+), 50 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7e46203..ce8951d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2007-10-17  Eric Blake  <address@hidden>
 
+       Function cleanup.
+       * lib/autotest/general.m4 (_AT_CREATE_DEBUGGING_SCRIPT): Convert
+       from m4 macro...
+       (AT_INIT) <at_func_create_debugging_script>: ...to shell
+       function.
+       (AT_INIT): Defer function declarations until after --help,
+       --version.  Format functions consistently, trying to fit in 80
+       columns.
+       (TEST_FUNCTIONS): Based on recent changes, rename...
+       (TEST_GROUPS): ...to this.
+
        Reject FreeBSD m4.
        * m4/m4.m4 (AC_PROG_GNU_M4): Also check for frozen file support.
        * configure: Regenerate.
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index f94b10c..599c63d 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -99,6 +99,7 @@
 #    Like DEFAULTS but run after argument processing for purposes of
 #    optimization.  Do anything else that needs to be done to prepare for
 #    tests.  Sets up verbose and log file descriptors.  Sets and logs PATH.
+#    Declares functions shared among the tests.
 #  - TESTS
 #    The core of the test suite.
 #  - TESTS_END
@@ -108,10 +109,10 @@
 #    The collector for code for each test, the ``normal'' diversion, but
 #    undiverted into other locations before final output.
 #
-#  - TEST_FUNCTIONS
-#    Series of functions for each test group.  The functions deliberately
-#    occur after the end of the shell script, so that the shell need not
-#    spend time parsing functions it will not execute.
+#  - TEST_GROUPS
+#    Contents of each test group.  The tests deliberately occur after the
+#    end of the shell script, so that the shell need not spend time parsing
+#    commands it will not execute.
 
 m4_define([_m4_divert(DEFAULTS)],           100)
 m4_define([_m4_divert(PARSE_ARGS_BEGIN)],   200)
@@ -129,7 +130,7 @@ m4_define([_m4_divert(PREPARE_TESTS)],      400)
 m4_define([_m4_divert(TESTS)],              401)
 m4_define([_m4_divert(TESTS_END)],          402)
 m4_define([_m4_divert(TEST_SCRIPT)],        403)
-m4_define([_m4_divert(TEST_FUNCTIONS)],     500)
+m4_define([_m4_divert(TEST_GROUPS)],     500)
 
 
 # AT_LINE
@@ -178,21 +179,6 @@ m4_define([_AT_NORMALIZE_TEST_GROUP_NUMBER],
   done'
 ])
 
-# _AT_CREATE_DEBUGGING_SCRIPT
-# ---------------------------
-# Create the debugging script $at_group_dir/run which will reproduce the
-# current test group.
-m4_define([_AT_CREATE_DEBUGGING_SCRIPT],
-[{
-           echo "#! /bin/sh"
-           echo 'test "${ZSH_VERSION+set}" = set && alias -
g '\''${1+"address@hidden"}'\''='\''"address@hidden"'\'''
-           AS_ECHO(["cd '$at_dir'"])
-           AS_ECHO(["exec \${CONFIG_SHELL-$SHELL} $[0] -v -d $at_debug_args 
$at_group \${1+\"address@hidden"}"])
-           echo 'exit 1'
-         } >$at_group_dir/run
-         chmod +x $at_group_dir/run
-])# _AT_CREATE_DEBUGGING_SCRIPT
-
 
 # AT_INIT([TESTSUITE-NAME])
 # -------------------------
@@ -219,24 +205,29 @@ SHELL=${CONFIG_SHELL-/bin/sh}
 # How were we run?
 at_cli_args="address@hidden"
 
+m4_divert_push([PREPARE_TESTS])dnl
 ## --------------- ##
 ## Shell functions ##
 ## --------------- ##
 
 # at_func_check_newline COMMAND
-# Test if COMMAND includes a newline and, if so, print a message and return 
exit code 1
+# -----------------------------
+# Test if COMMAND includes a newline and, if so, print a message and return
+# exit code 1
 at_func_check_newline ()
 {
   case "$[1]" in
  *'
-'*) echo 'Not enabling shell tracing (command contains an embedded
newline)' ; 
return 1 ;;
+'*) echo 'Not enabling shell tracing (command contains an embedded
newline)'
+    return 1 ;;
  *) return 0 ;;
   esac
 }
 
 # at_func_filter_trace EXIT-CODE
-# Split the contents of file "$at_stder1" into the "set -x" trace (on
stderr) 
and
-# the other lines (on file "$at_stderr").  Return the exit code EXIT-CODE.
+# ------------------------------
+# Split the contents of file "$at_stder1" into the "set -x" trace (on
stderr)
+# and the other lines (on file "$at_stderr").  Return the exit code
EXIT-CODE.
 at_func_filter_trace ()
 {
   grep '^ *+' "$at_stder1" >&2
@@ -245,6 +236,7 @@ at_func_filter_trace ()
 }
 
 # at_func_log_failure FILE-LIST
+# -----------------------------
 # Copy the files in the list on stdout with a "> " prefix, and exit the
shell
 # with a failure exit code.
 at_func_log_failure ()
@@ -256,6 +248,7 @@ at_func_log_failure ()
 }
 
 # at_func_check_skip EXIT-CODE
+# ----------------------------
 # Check whether EXIT-CODE is the special exit code 77, and if so exit the
shell
 # with that same exit code.
 at_func_check_skip ()
@@ -266,12 +259,14 @@ at_func_check_skip ()
 }
 
 # at_func_check_status EXPECTED EXIT-CODE LINE
-# Check whether EXIT-CODE is the expected exit code, and if so do nothing.  
Else,
-# if it is 77 exit the shell with that same exit code; if it is anything
else
-# print an error message and fail the test.
+# --------------------------------------------
+# Check whether EXIT-CODE is the expected exit code, and if so do nothing.
+# Otherwise, if it is 77 exit the shell with that same exit code; if it is
+# anything else print an error message and fail the test.
 at_func_check_status ()
 {
-  dnl This order ensures that we don't `skip' if we are precisely checking
$? 
= 77.
+dnl This order ensures that we don't `skip' if we are precisely checking
+dnl $? = 77.
   case $[2] in
     $[1] ) ;;
     77) echo 77 > "$at_status_file"; exit 77;;
@@ -281,6 +276,7 @@ at_func_check_status ()
 }
 
 # at_func_diff_devnull FILE
+# -------------------------
 # Emit a diff between /dev/null and FILE.  Uses "test -s" to avoid useless
 # diff invocations.
 at_func_diff_devnull ()
@@ -298,6 +294,29 @@ at_func_test ()
        > "$at_test_source"
 }
 
+# at_func_create_debugging_script
+# -------------------------------
+# Create the debugging script $at_group_dir/run which will reproduce the
+# current test group.
+at_func_create_debugging_script ()
+{
+  {
+    echo "#! /bin/sh"
+    echo 'test "${ZSH_VERSION+set}" = set dnl
+&& alias -g '\''${1+"address@hidden"}'\''='\''"address@hidden"'\'''
+    AS_ECHO(["cd '$at_dir'"])
+    AS_ECHO(["exec \${CONFIG_SHELL-$SHELL} $[0] -v -d ]dnl
+[$at_debug_args $at_group \${1+\"address@hidden"}"])
+    echo 'exit 1'
+  } >$at_group_dir/run
+  chmod +x $at_group_dir/run
+}
+
+## ---------------------- ##
+## End of shell functions ##
+## ---------------------- ##
+m4_divert_pop([PREPARE_TESTS])dnl back to DEFAULTS
+
 # Load the config file.
 for at_file in atconfig atlocal
 do
@@ -922,7 +941,7 @@ _ATEOF
 
          # Cleanup the group directory, unless the user wants the files.
          if $at_debug_p ; then
-           _AT_CREATE_DEBUGGING_SCRIPT
+           at_func_create_debugging_script
          elif test -d "$at_group_dir"; then
            find "$at_group_dir" -type d ! -perm -700 -exec chmod u+rwx \{\} \;
            rm -fr "$at_group_dir"
@@ -936,7 +955,7 @@ _ATEOF
 
          # Upon failure, keep the group directory for autopsy, and
          # create the debugging script.
-         _AT_CREATE_DEBUGGING_SCRIPT
+         at_func_create_debugging_script
          $at_errexit && break
          ;;
       esac
@@ -1023,9 +1042,11 @@ $at_xpass_count passed unexpectedly." ;;
 
     # No expected failures, but failures and xpasses
     *:1:0) at_result="$at_result $at_were run,
-$at_unexpected_count did not behave as expected ($at_fail_count unexpected 
failure)." ;;
+$at_unexpected_count did not behave as expected dnl
+($at_fail_count unexpected failure)." ;;
     *:*:0) at_result="$at_result $at_were run,
-$at_unexpected_count did not behave as expected ($at_fail_count unexpected 
failures)." ;;
+$at_unexpected_count did not behave as expected dnl
+($at_fail_count unexpected failures)." ;;
 
     # All of them.
     *:*:1) at_result="$at_result $at_were run,
@@ -1098,7 +1119,8 @@ else
   AS_BOX([$as_me.log was created.])
 
   echo
-  AS_ECHO(["Please send \`${at_testdir+${at_testdir}/}$as_me.log' and all 
information you think might help:
+  AS_ECHO(["Please send \`${at_testdir+${at_testdir}/}$as_me.log' ]dnl
+[and all information you think might help:
 
    To: <AT_PACKAGE_BUGREPORT>
    Subject: @<:@AT_PACKAGE_STRING@:>@ $as_me:dnl
@@ -1151,7 +1173,8 @@ m4_foreach([AT_option], m4_split(m4_normalize([$1]),[[
\|]
+]),
 [m4_define_default([AT_first_option],AT_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_arg],m4_if(m4_len(AT_option),1,[],[-])[-]AT_option[=*],
[ 
| ])dnl
+m4_append([AT_case_arg],
+          m4_if(m4_len(AT_option),1,[],[-])[-]AT_option[=*], [ | ])dnl
 ])dnl m4_foreach AT_option
 dnl keep track so we or the user may process ACTION-IF-NOT-GIVEN
 m4_divert_once([PARSE_ARGS_BEGIN],
@@ -1283,7 +1306,7 @@ m4_define([AT_xfail], [at_xfail=no])
 m4_define([AT_description], m4_expand([$1]))
 m4_define([AT_ordinal], m4_incr(AT_ordinal))
 m4_append([AT_groups_all], [ ]m4_defn([AT_ordinal]))
-m4_divert_push([TEST_FUNCTIONS])dnl
+m4_divert_push([TEST_GROUPS])dnl
 [#AT_START_]AT_ordinal
 @%:@ AT_ordinal. m4_defn([AT_line]): m4_defn([AT_description])
 at_setup_line='m4_defn([AT_line])'
@@ -1331,9 +1354,10 @@ m4_define([AT_CAPTURE_FILE],
 # Complete a group of related tests.
 m4_define([AT_CLEANUP],
 [m4_append([AT_help_all],
-m4_defn([AT_ordinal]);m4_defn([AT_line]);m4_defn([AT_description]);m4_ifdef
([AT_keywords], [m4_defn([AT_keywords])]);
+m4_defn([AT_ordinal]);m4_defn([AT_line]);m4_defn([AT_description]);dnl
+m4_ifdef([AT_keywords], [m4_defn([AT_keywords])]);
 )dnl
-m4_divert_pop([TEST_SCRIPT])dnl Back to TEST_FUNCTIONS
+m4_divert_pop([TEST_SCRIPT])dnl Back to TEST_GROUPS
 AT_xfail
 echo "#                             -*- compilation -*-" >> "$at_group_log"
 (
@@ -1345,7 +1369,7 @@ m4_undivert([TEST_SCRIPT])dnl Insert the code here
 ) 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_pop([TEST_GROUPS])dnl Back to KILL.
 m4_divert_text([TESTS],
 [  AT_ordinal )
     if at_func_test AT_ordinal && . "$at_test_source"; then :; else
@@ -1462,10 +1486,10 @@ m4_define([AT_CHECK_NOESCAPE],
 # + foo
 # bar
 #
-# In a subset of cases, one could filter such extended shell traces from 
stderr.
-# Since test commands spanning several lines are rare, I chose instead to 
simply
-# not trace COMMANDS that could yield multiple trace lines.  Distinguishing 
such
-# COMMANDS became the task at hand.
+# In a subset of cases, one could filter such extended shell traces from
+# stderr.  Since test commands spanning several lines are rare, I chose
+# instead to simply not trace COMMANDS that could yield multiple trace
lines.
+# Distinguishing such COMMANDS became the task at hand.
 #
 # These features may cause a shell command to span multiple lines:
 #
@@ -1492,12 +1516,12 @@ m4_define([AT_CHECK_NOESCAPE],
 #   'bar
 #   echo "$var"
 # Parameter expansions appear in COMMANDS with much greater frequency than
do
-# newlines and command substitutions, so disabling tracing for all such 
COMMANDS
-# would much more substantially devalue `testsuite -x'.  To determine which
-# parameter expansions yield multiple lines, we escape all ``', `"', and
`\' in
-# a copy of COMMANDS and expand that string within double quotes at
runtime.  
If
-# the result of that expansion contains multiple lines, the test suite
disables
-# tracing for the command in question.
+# newlines and command substitutions, so disabling tracing for all such
+# COMMANDS would much more substantially devalue `testsuite -x'.  To
determine
+# which parameter expansions yield multiple lines, we escape all ``', `"',
+# and `\' in a copy of COMMANDS and expand that string within double quotes
+# at runtime.  If the result of that expansion contains multiple lines, the
+# test suite disables tracing for the command in question.
 #
 # This method leads the test suite to expand some parameters that the shell
 # itself will never expand due to single-quotes or backslash escapes.  This
is
@@ -1532,12 +1556,14 @@ m4_cond([m4_eval(m4_index([$1], [`]) >= 0)], [1],
 ))dnl
 dnl
 m4_ifval(m4_defn([at_reason]),
-[{ echo 'Not enabling shell tracing (command contains ]m4_defn([at_reason])
[)'; false; }],
+[{ 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.
 [test -n "$at_traceon"],
 dnl COMMANDS may contain parameter expansions; expand them at runtime.
-[test -n "$at_traceon" && at_func_check_newline "AS_ESCAPE([$1],
[`\"])"])])[]
dnl
+[test -n "$at_traceon" \
+  && at_func_check_newline "AS_ESCAPE([$1], [`\"])"])])[]dnl
 m4_popdef([at_reason])])
 
 
-- 
1.5.3.2


>From 5b6f53e441646f612384c1b1c305cc22b44cf928 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 18 Oct 2007 09:05:09 -0600
Subject: [PATCH] Fix AT_TESTED, AT_KEYWORDS.

* lib/m4sugar/m4sugar.m4 (m4_append_uniq): Warn if separator
occurs in string, as duplicates may be added.
(_m4_append_uniq): New helper macro.
(m4_append_uniq_w): New macro.
* lib/autotest/general.m4 (AT_TESTED, AT_KEYWORDS): Fix
duplication bug by using new macro.
(AT_INIT) <at_tested>: Restore newline separators.  Invoke tested
programs with stdin redirected, so programs that don't
understand --version won't try to behave interactively.
* tests/autotest.at (Tested programs): Catch this bug.
* tests/m4sugar.at (m4@&address@hidden): Test new macro.
* tests/local.at (AT_TESTED): Add m4, perl.
* doc/autoconf.texi (Text processing Macros): Document
m4_append_uniq_w, and update text on m4_append.
* NEWS: Document the addition.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog               |   19 +++++++++++++++++++
 NEWS                    |   10 ++++++----
 doc/autoconf.texi       |   16 ++++++++++++++++
 lib/autotest/general.m4 |   13 +++++++------
 lib/m4sugar/m4sugar.m4  |   17 ++++++++++++++++-
 tests/autotest.at       |   17 +++++++++++++++--
 tests/local.at          |    3 +++
 tests/m4sugar.at        |   15 +++++++++++++++
 8 files changed, 97 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ce8951d..483e6db 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2007-10-18  Eric Blake  <address@hidden>
+
+       Fix AT_TESTED, AT_KEYWORDS.
+       * lib/m4sugar/m4sugar.m4 (m4_append_uniq): Warn if separator
+       occurs in string, as duplicates may be added.
+       (_m4_append_uniq): New helper macro.
+       (m4_append_uniq_w): New macro.
+       * lib/autotest/general.m4 (AT_TESTED, AT_KEYWORDS): Fix
+       duplication bug by using new macro.
+       (AT_INIT) <at_tested>: Restore newline separators.  Invoke tested
+       programs with stdin redirected, so programs that don't
+       understand --version won't try to behave interactively.
+       * tests/autotest.at (Tested programs): Catch this bug.
+       * tests/m4sugar.at (m4@&address@hidden): Test new macro.
+       * tests/local.at (AT_TESTED): Add m4, perl.
+       * doc/autoconf.texi (Text processing Macros): Document
+       m4_append_uniq_w, and update text on m4_append.
+       * NEWS: Document the addition.
+
 2007-10-17  Eric Blake  <address@hidden>
 
        Function cleanup.
diff --git a/NEWS b/NEWS
index 082961e..ec81291 100644
--- a/NEWS
+++ b/NEWS
@@ -120,12 +120,14 @@ GNU Autoconf NEWS - User visible changes.
      m4_pushdef([m4_append], [m4_define([$1],
           m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
    Additionally, m4_append_uniq now takes optional parameters that can
-   be used to take action depending on whether anything was appended.
+   be used to take action depending on whether anything was appended,
+   and warns if a non-empty separator occurs within the string being
+   appended, since that can lead to duplicates.
 
 ** The following m4sugar macros are new:
-   m4_apply  m4_combine  m4_cond  m4_count  m4_dquote_elt  m4_echo
-   m4_expand  m4_ignore  m4_make_list  m4_max  m4_min  m4_newline
-   m4_shift2  m4_shift3  m4_unquote
+   m4_append_uniq_w  m4_apply  m4_combine  m4_cond  m4_count
+   m4_dquote_elt  m4_echo  m4_expand  m4_ignore  m4_make_list  m4_max
+   m4_min  m4_newline  m4_shift2  m4_shift3  m4_unquote
 
 ** Warnings are now generated by default when an installer invokes
    'configure' with an unknown --enable-* or --with-* option.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 446f89f..184f474 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -10911,6 +10911,8 @@ to grow strings without duplicating substrings.  
Additionally,
 @code{m4_append_uniq} takes two optional parameters as of Autoconf 2.62;
 @var{if-uniq} is expanded if @var{string} was appended, and
 @var{if-duplicate} is expanded if @var{string} was already present.
+Also, @code{m4_append_uniq} warns if @var{separator} is not empty, but
+occurs within @var{string}, since that can lead to duplicates.
 
 @example
 m4_define([active], [ACTIVE])dnl
@@ -10945,6 +10947,20 @@ m4_dquote(list2)
 @end example
 @end defmac
 
address@hidden m4_append_uniq_w (@var{macro-name}, @var{strings})
address@hidden
+This macro was introduced in Autoconf 2.62.  It is similar to
address@hidden, but treats @var{strings} as a whitespace
+separated list of words to append, and only appends unique words.
address@hidden is updated with a single space between new words.
address@hidden
+m4_append_uniq_w([numbers], [1 1 2])dnl
+m4_append_uniq_w([numbers], [ 2 3 ])dnl
+numbers
address@hidden 2 3
address@hidden example
address@hidden defmac
+
 @defmac m4_combine (@ovar{separator}, @var{prefix-list}, @ovar{infix}, @
   @var{suffix-1}, @dots{})
 @msindex{combine}
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index 599c63d..9335874 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -396,7 +396,8 @@ m4_divert_pop([DEFAULTS])dnl
 m4_wrap([m4_divert_text([DEFAULTS],
 [
 # List of the tested programs.
-at_tested='m4_ifdef([AT_tested], [AT_tested])'
+at_tested='m4_ifdef([AT_tested],
+  [m4_translit(m4_dquote(m4_defn([AT_tested])), [ ], m4_newline)])'
 # List of the all the test groups.
 at_groups_all='AT_groups_all'
 # As many question marks as there are digits in the last test group number.
@@ -779,7 +780,7 @@ do
   if test -f "$as_dir/$at_program"; then
     {
       AS_ECHO(["$at_srcdir/AT_LINE: $as_dir/$at_program --version"])
-      "$as_dir/$at_program" --version
+      "$as_dir/$at_program" --version </dev/null
       echo
     } >&AS_MESSAGE_LOG_FD 2>&1
   else
@@ -1174,7 +1175,7 @@ m4_foreach([AT_option], m4_split(m4_normalize([$1]),[[
\|]
+]),
 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_arg],
-          m4_if(m4_len(AT_option),1,[],[-])[-]AT_option[=*], [ | ])dnl
+         m4_if(m4_len(AT_option),1,[],[-])[-]AT_option[=*], [ | ])dnl
 ])dnl m4_foreach AT_option
 dnl keep track so we or the user may process ACTION-IF-NOT-GIVEN
 m4_divert_once([PARSE_ARGS_BEGIN],
@@ -1279,8 +1280,7 @@
m4_defun([AT_ARG_OPTION_ARG],[_AT_ARG_OPTION([$1],[$2],1,
[$3],[$4])])
 # must correspond to the version of the package.  PATH should be
 # already preset so the proper executable will be selected.
 m4_define([AT_TESTED],
-[m4_append_uniq([AT_tested], [$1], [
-])])
+[m4_append_uniq_w([AT_tested], [$1])])
 
 
 # AT_COPYRIGHT(TEXT)
@@ -1336,8 +1336,9 @@ m4_case([$1],
 # AT_KEYWORDS(KEYWORDS)
 # ---------------------
 # Declare a list of keywords associated to the current test group.
+# The list is stored in lower case, since the -k option is
case-insensitive.
 m4_define([AT_KEYWORDS],
-[m4_append_uniq([AT_keywords], [$1], [ ])])
+[m4_append_uniq_w([AT_keywords], m4_tolower([[$1]]))])
 
 
 # AT_CAPTURE_FILE(FILE)
diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4
index a1be414..b7ca5ea 100644
--- a/lib/m4sugar/m4sugar.m4
+++ b/lib/m4sugar/m4sugar.m4
@@ -1896,13 +1896,28 @@ m4_define([m4_append],
 # --------------------------------------------------------------------
 # Like `m4_append', but append only if not yet present.  Additionally,
 # expand IF-UNIQ if STRING was appended, or IF-DUP if STRING was already
-# present.
+# present.  Also, warn if SEPARATOR is not empty and occurs within STRING,
+# as the algorithm no longer guarantees uniqueness.
 m4_define([m4_append_uniq],
+[m4_ifval([$3], [m4_if(m4_index([$2], [$3]), [-1], [],
+                       [m4_warn([syntax],
+                               [$0: `$2' contains `$3'])])])_$0($@)])
+m4_define([_m4_append_uniq],
 [m4_ifdef([$1],
          [m4_if(m4_index([$3]m4_builtin([defn], [$1])[$3], [$3$2$3]), [-1],
                 [m4_append([$1], [$2], [$3])$4], [$5])],
          [m4_append([$1], [$2], [$3])$4])])
 
+# m4_append_uniq_w(MACRO-NAME, STRINGS)
+# -------------------------------------
+# For each of the words in the whitespace separated list STRINGS, append
+# only the unique strings to the definition of MACRO-NAME.
+#
+# Avoid overhead of m4_defn by using m4_builtin.
+m4_define([m4_append_uniq_w],
+[m4_foreach_w([m4_Word], [$2],
+              [_m4_append_uniq([$1], m4_builtin([defn], [m4_Word]), [
])])])
+
 
 # m4_text_wrap(STRING, [PREFIX], [FIRST-PREFIX], [WIDTH])
 # -------------------------------------------------------
diff --git a/tests/autotest.at b/tests/autotest.at
index 1f03a8f..e3a4662 100644
--- a/tests/autotest.at
+++ b/tests/autotest.at
@@ -90,6 +90,17 @@ AT_CHECK_AT_TEST([Empty test], [])
 # And finally, an empty check should not cause a syntax error.
 AT_CHECK_AT_TEST([Empty check], [AT_CHECK])
 
+# Check for tested programs.  autoconf should only appear once.
+AT_CHECK_AT([Tested programs],
+[[AT_INIT([programs test suite])
+AT_TESTED([autoconf autom4te])
+AT_TESTED([autoconf])
+]], [], [], [], [],
+[AT_CHECK([[sed -n 's|.*/\([^ /]* --version\)|\1|p' micro-suite.log]], [],
+[[autoconf --version
+autom4te --version
+]])])
+
 ## ----------------------------------------------------- ##
 ## Newlines and command substitutions in test commands.  ##
 ## ----------------------------------------------------- ##
@@ -381,12 +392,14 @@ AT_KEYWORDS(key2)
 AT_CHECK(:)
 AT_CLEANUP
 AT_SETUP(both)
-AT_KEYWORDS(key1)
-AT_KEYWORDS(key2)
+AT_KEYWORDS([key1 key2])
+AT_KEYWORDS([key1])
 AT_CHECK(:)
 AT_CLEANUP
 ]])
 AT_CHECK_AUTOM4TE([--language=autotest -o k k.at])
+dnl check that AT_KEYWORDS does not duplicate words
+AT_CHECK([grep 'key1.*key1' k], [1])
 
 # AT_CHECK_EGREP(PATTERN, STATUS, COUNT)
 m4_define([AT_CHECK_EGREP],
diff --git a/tests/local.at b/tests/local.at
index 4aa686f..298dfba 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -22,7 +22,10 @@ m4_version_prereq([2.57])
 m4_pattern_allow([^AS_EXIT$])
 m4_pattern_allow([^m4_(define|shift)$])
 
+# Programs this package provides
 AT_TESTED([autom4te autoconf autoheader autoupdate autoreconf ifnames])
+# Programs this package depends on
+AT_TESTED([m4 perl])
 
 
 ## ---------------- ##
diff --git a/tests/m4sugar.at b/tests/m4sugar.at
index dc91fbb..9b1dc0e 100644
--- a/tests/m4sugar.at
+++ b/tests/m4sugar.at
@@ -230,6 +230,9 @@ m4_append([list], [two], [[, ]])dnl
 m4_append([list], [three], [[, ]])dnl
 list
 m4_dquote(list)
+m4_append_uniq_w([numbers], [1 1 2])dnl
+m4_append_uniq_w([numbers], [ 2 3 ])dnl
+numbers
 ]],
 [[This is an ACTIVE symbol.
 This is an active symbol.
@@ -248,6 +251,18 @@ one, two, three, two
 [one],[two],[three],[two]
 one, two, three
 [one, two, three]
+1 2 3
+]])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_append_uniq([str], [a], [ ])
+m4_append_uniq([str], [a b], [ ])
+m4_divert([0])dnl
+str
+]])
+
+AT_CHECK_M4SUGAR([-o-], 0, [[a a b
+]], [[script.4s:2: warning: m4@&address@hidden: `a b' contains ` '
 ]])
 
 AT_CLEANUP
-- 
1.5.3.2


-- 
View this message in context: 
http://www.nabble.com/AT_TESTED-issues-tf4648107.html#a13278128
Sent from the Gnu - Autoconf - Patches mailing list archive at Nabble.com.





reply via email to

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