]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Improve behavior of './testsuite 01'.
authorEric Blake <ebb9@byu.net>
Tue, 6 May 2008 12:17:41 +0000 (06:17 -0600)
committerEric Blake <ebb9@byu.net>
Tue, 6 May 2008 12:17:41 +0000 (06:17 -0600)
* lib/autotest/general.m4 (AT_INIT) <at_func_validate_ranges>:
Alter usage to eval its arguments, 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 <ebb9@byu.net>
ChangeLog
lib/autotest/general.m4
tests/autotest.at

index 705e71eef0e4937ba0c4e322e8111bfa33941c7c..59a311916bf1a82291fd34dfefeba800ab5f3ca7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-05-06  Eric Blake  <ebb9@byu.net>
+
+       Improve behavior of './testsuite 01'.
+       * lib/autotest/general.m4 (AT_INIT) <at_func_validate_ranges>:
+       Alter usage to eval its arguments, 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  <ebb9@byu.net>
 
        Mention Solaris /usr/ucb/tr pitfall.
index 4ce3df7c4fc9ab2e76d863a7e064f284dc65ed45..88d10a31eaa21f055c5ce9b8cfabf1bbe612fb4e 100644 (file)
@@ -363,7 +363,8 @@ at_func_create_debugging_script ()
 
 # at_func_arith
 # -------------
-# Arithmetic evaluation, avoids expr if the shell is sane.
+# Arithmetic evaluation, avoids expr if the shell is sane.  The
+# interpretation of leading zeroes is unspecified.
 #
 # subshell and eval are needed to keep Solaris sh from bailing out:
 if ( eval 'test $(( 1 + 1 )) = 2' ) 2>/dev/null; then
@@ -440,17 +441,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
+# variable NAME.  Leading zeroes are treated as decimal.
 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, ${at_value#${at_value%%[1-9]*}} avoids the
+         # expr fork, but it is not worth the effort to determine if the
+         # shell supports XSI when the user can just avoid leading 0.
+         eval $at_grp='`expr $at_value + 0`' ;;
+    esac
   done
 }])])dnl
 m4_divert_push([PARSE_ARGS])dnl
@@ -506,14 +517,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 +532,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 +551,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/'`
index 7db84514fe117ee7493c249dd7236b820999a544..dc3cfd5249a6f4bd0bb34b67c10ca8a128ab1912 100644 (file)
@@ -677,22 +677,40 @@ 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_CHECK(:)
+AT_CLEANUP
 ]])
 dnl check that AT_KEYWORDS does not duplicate words
 AT_CHECK([grep 'key1.*key1' k], [1])
@@ -733,21 +751,24 @@ AT_CHECK_KEYS([-k 'eco.*'], [successful], [1], [none|first|second|both], [0])
 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 08], [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-011], [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