autoconf-patches
[Top][All Lists]
Advanced

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

testsuite 01


From: Eric Blake
Subject: testsuite 01
Date: Mon, 5 May 2008 18:24:20 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

I got bit when trying to rerun just failed tests:

$ ./testsuite `cd ./testsuite.dir; echo [0-9]*`
## --------------------------------------- ##
## GNU M4 1.9a.413-359f9-dirty test suite. ##
## --------------------------------------- ##
./testsuite: error: cannot find myself; rerun with an absolute file name

I traced it to the fact that './testsuite 01' causes at_func_test to try to use 
the undefined $at_sed01 rather than $at_sed1.  Any objections to this patch, 
which normalizes away leading 0 up front?  Also, this points out something to 
be careful of - at_func_arith treats leading 0 differently (octal vs. decimal) 
depending on whether the shell supports $(()).

>From cf161a191e197d8cb494ef6834e1393ce81ebd38 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Mon, 5 May 2008 12:16:07 -0600
Subject: [PATCH] Improve behavior of 'tests/testsuite 01'.

* lib/autotest/general.m4 (AT_INIT) <at_func_validate_ranges>:
Alter usage to eval its argument, in order to normalize away
leading zero.  All callers updated.
* tests/autotest.at (Keywords and ranges): Test range
normalization with leading 0.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog               |    9 +++++++++
 lib/autotest/general.m4 |   28 +++++++++++++++++++---------
 tests/autotest.at       |   36 +++++++++++++++++++++++++++++-------
 3 files changed, 57 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 705e71e..5add251 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-05-05  Eric Blake  <address@hidden>
+
+       Improve behavior of 'tests/testsuite 01'.
+       * lib/autotest/general.m4 (AT_INIT) <at_func_validate_ranges>:
+       Alter usage to eval its argument, in order to normalize away
+       leading zero.  All callers updated.
+       * tests/autotest.at (Keywords and ranges): Test range
+       normalization with leading 0.
+
 2008-04-26  Eric Blake  <address@hidden>
 
        Mention Solaris /usr/ucb/tr pitfall.
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index 4ce3df7..1b1605b 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -440,17 +440,27 @@ at_format='m4_bpatsubst(m4_defn([AT_ordinal]),
 # Description of all the test groups.
 at_help_all="AS_ESCAPE(m4_dquote(m4_defn([AT_help_all])))"
 
-# at_func_validate_ranges [N...]
-# ------------------------------
-# validate test group ranges
+# at_func_validate_ranges [NAME...]
+# ---------------------------------
+# Validate and normalize the test group number contained in each NAME.
 at_func_validate_ranges ()
 {
   for at_grp
   do
-    if test $at_grp -lt 1 || test $at_grp -gt AT_ordinal; then
-      AS_ECHO(["invalid test group: $at_grp"]) >&2
+    eval at_value=\$$at_grp
+    if test $at_value -lt 1 || test $at_value -gt AT_ordinal; then
+      AS_ECHO(["invalid test group: $at_value"]) >&2
       exit 1
     fi
+    case $at_value in
+      0*) # We want to treat leading 0 as decimal, like expr and test, but
+         # at_func_arith treats it as octal if it uses $(( )).
+         # With XSI shells, we could avoid the expr fork by using
+         # ${at_value#${at_value%%[1-9]*}}, but it is not worth the effort
+         # when the user can just avoid requesting tests with leading 0.
+         eval $at_grp='`expr $at_value + 0`'
+       ;;
+    esac
   done
 }])])dnl
 m4_divert_push([PARSE_ARGS])dnl
@@ -506,14 +516,14 @@ do
        ;;
 
     [[0-9] | [0-9][0-9] | [0-9][0-9][0-9] | [0-9][0-9][0-9][0-9]])
-       at_func_validate_ranges $at_option
+       at_func_validate_ranges at_option
        at_groups="$at_groups$at_option "
        ;;
 
     # Ranges
     [[0-9]- | [0-9][0-9]- | [0-9][0-9][0-9]- | [0-9][0-9][0-9][0-9]-])
        at_range_start=`echo $at_option |tr -d X-`
-       at_func_validate_ranges $at_range_start
+       at_func_validate_ranges at_range_start
        at_range=`AS_ECHO([" $at_groups_all "]) | \
          sed -e 's/^.* \('$at_range_start' \)/\1/'`
        at_groups="$at_groups$at_range "
@@ -521,7 +531,7 @@ do
 
     [-[0-9] | -[0-9][0-9] | -[0-9][0-9][0-9] | -[0-9][0-9][0-9][0-9]])
        at_range_end=`echo $at_option |tr -d X-`
-       at_func_validate_ranges $at_range_end
+       at_func_validate_ranges at_range_end
        at_range=`AS_ECHO([" $at_groups_all "]) | \
          sed -e 's/\( '$at_range_end'\) .*$/\1/'`
        at_groups="$at_groups$at_range "
@@ -540,7 +550,7 @@ do
          at_range_end=$at_range_start
          at_range_start=$at_tmp
        fi
-       at_func_validate_ranges $at_range_start $at_range_end
+       at_func_validate_ranges at_range_start at_range_end
        at_range=`AS_ECHO([" $at_groups_all "]) | \
          sed -e 's/^.*\( '$at_range_start' \)/\1/' \
              -e 's/\( '$at_range_end'\) .*$/\1/'`
diff --git a/tests/autotest.at b/tests/autotest.at
index 7db8451..5571eef 100644
--- a/tests/autotest.at
+++ b/tests/autotest.at
@@ -677,22 +677,41 @@ AT_SETUP([Keywords and ranges])
 
 AT_CHECK_AT_PREP([k],
 [[AT_INIT
-AT_SETUP(none)
+AT_SETUP(none) #01
 AT_CHECK(:)
 AT_CLEANUP
-AT_SETUP(first)
+AT_SETUP(first) #02
 AT_KEYWORDS(key1)
 AT_CHECK(:)
 AT_CLEANUP
-AT_SETUP(second)
+AT_SETUP(second) #03
 AT_KEYWORDS(key2)
 AT_CHECK(:)
 AT_CLEANUP
-AT_SETUP(both)
+AT_SETUP(both) #04
 AT_KEYWORDS([key1 key2])
 AT_KEYWORDS([key1])
 AT_CHECK(:)
 AT_CLEANUP
+AT_SETUP(test5) #05
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(test6) #06
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(test7) #07
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(test8) #08
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(test9) #09
+AT_CHECK(:)
+AT_CLEANUP
+AT_SETUP(test10) #10
+AT_KEYWORDS([final])
+AT_CHECK(:)
+AT_CLEANUP
 ]])
 dnl check that AT_KEYWORDS does not duplicate words
 AT_CHECK([grep 'key1.*key1' k], [1])
@@ -733,21 +752,24 @@ AT_CHECK_KEYS([-k 'eco.*'], [successful], [1],
 AT_CHECK_KEYS([-k 'fir.*'], [first], [1], [none|second|both], [0])
 
 AT_CHECK_KEYS([1-2], [none|first], [2], [second|both], [0])
+AT_CHECK_KEYS([01-002], [none|first], [2], [second|both], [0])
 AT_CHECK_KEYS([1-3 2-1], [none|first|second], [3], [both], [0])
 AT_CHECK_KEYS([-3], [none|first|second], [3], [both], [0])
 AT_CHECK_KEYS([4-], [both], [1], [none|first|second], [0])
+AT_CHECK_KEYS([010], [test10], [1], [none|first|second|both], [0])
 AT_CHECK_KEYS([-k second 4-], [second|both], [2], [none|first], [0])
 
 AT_CHECK([$CONFIG_SHELL ./k 0], [1], [ignore], [ignore])
 AT_CHECK([$CONFIG_SHELL ./k 0-], [1], [ignore], [ignore])
 AT_CHECK([$CONFIG_SHELL ./k -0], [1], [ignore], [ignore])
-AT_CHECK([$CONFIG_SHELL ./k 5], [1], [ignore], [ignore])
-AT_CHECK([$CONFIG_SHELL ./k 5-], [1], [ignore], [ignore])
-AT_CHECK([$CONFIG_SHELL ./k 1-5], [1], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./k 11], [1], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./k 11-], [1], [ignore], [ignore])
+AT_CHECK([$CONFIG_SHELL ./k 1-11], [1], [ignore], [ignore])
 AT_CHECK([$CONFIG_SHELL ./k -k nonexistent], [0], [ignore])
 
 AT_CHECK_KEYS([--list -k nonexistent], [KEYWORDS], [1], [first|second|both], 
[0])
 AT_CHECK_KEYS([--list 1], [none], [1], [first|second|both], [0])
+AT_CHECK_KEYS([--list 01], [none], [1], [first|second|both], [0])
 AT_CHECK_KEYS([--list -k none -k first], [none|first], [2], [second|both], [0])
 AT_CLEANUP
 
-- 
1.5.5.1







reply via email to

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