]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Avoid long lines in testsuite script.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Mon, 2 Aug 2010 20:42:55 +0000 (22:42 +0200)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Fri, 27 Aug 2010 18:03:58 +0000 (20:03 +0200)
* lib/autotest/general.m4 (AT_INIT): Remove definition of
AT_groups_all.  Initialize at_groups from at_help_all, with
newlines instead of spaces separating test groups numbers.
Adjust all code to newlines.
* NEWS: Update.
* tests/autotest.at (Huge testsuite): New test.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
ChangeLog
NEWS
lib/autotest/general.m4
tests/autotest.at

index 02308674209c913de9997fba21e69466ac2718e0..6accc2f6f5f1250fe702999e03f155edc158523f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2010-08-27  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
+       Avoid long lines in testsuite script.
+       * lib/autotest/general.m4 (AT_INIT): Remove definition of
+       AT_groups_all.  Initialize at_groups from at_help_all, with
+       newlines instead of spaces separating test groups numbers.
+       Adjust all code to newlines.
+       * NEWS: Update.
+       * tests/autotest.at (Huge testsuite): New test.
+
        Try to update config.cache atomically; respect symlinks.
        * lib/autoconf/general.m4 (AC_CACHE_SAVE): Use `mv -f' to update
        the cache file if it is a regular file and not a symlink.  Move
diff --git a/NEWS b/NEWS
index 79ed028b5c583947aaddcc806da6c7e344b041ff..bfe55e649d82c2c21cc4c36b5d701772f9f9031e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -22,6 +22,9 @@ GNU Autoconf NEWS - User visible changes.
    runs do not leave behind broken cache files.  It is still unspecified
    which subset or union of results is cached though.
 
+** Autotest testsuites should not contain long text lines any more, and be
+   portable even when very many test groups are used.
+
 
 * Major changes in Autoconf 2.67 (2010-07-21) [stable]
   Released by Eric Blake, based on git versions 2.66.*.
index e639ce6de34b2e2a49ca6e2e88a3aa4b11eaa885..cdc82b9a870356f09a8153ea234a6c6e1b07bba8 100644 (file)
@@ -202,7 +202,6 @@ m4_define([AT_INIT],
    [m4_expand([: $1])]))]
 [m4_define([AT_ordinal], 0)]
 [m4_define([AT_banner_ordinal], 0)]
-[m4_define([AT_groups_all], [])]
 [m4_define([AT_help_all], [])]
 [m4_map_args([_m4_popdef], _AT_DEFINE_INIT_LIST)]
 [m4_wrap([_AT_FINISH])]
@@ -226,11 +225,10 @@ at_cli_args="$[@]"
 
 m4_divert_push([BANNERS])dnl
 
-# Should we print banners?  at_groups is space-separated for entire test,
-# newline-separated if only a subset of the testsuite is run.
-case $at_groups in
-  *' '*' '* | *"$as_nl"*"$as_nl"* )
-      at_print_banners=: ;;
+# Should we print banners?  Yes if more than one test is run.
+case $at_groups in #(
+  *$as_nl* )
+      at_print_banners=: ;; #(
   * ) at_print_banners=false ;;
 esac
 # Text for banner N, set to a single space once printed.
@@ -435,14 +433,14 @@ 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)])'
-# 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.
 # Used to normalize the test group numbers so that `ls' lists them in
 # numerical order.
 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])))"
+# List of the all the test groups.
+at_groups_all=`AS_ECHO(["$at_help_all"]) | sed 's/;.*//'`
 
 AS_FUNCTION_DESCRIBE([at_fn_validate_ranges], [NAME...],
 [Validate and normalize the test group number contained in each
@@ -535,24 +533,24 @@ do
 
     [[0-9] | [0-9][0-9] | [0-9][0-9][0-9] | [0-9][0-9][0-9][0-9]])
        at_fn_validate_ranges at_option
-       AS_VAR_APPEND([at_groups], ["$at_option "])
+       AS_VAR_APPEND([at_groups], ["$at_option$as_nl"])
        ;;
 
     # 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_fn_validate_ranges at_range_start
-       at_range=`AS_ECHO([" $at_groups_all "]) | \
-         sed -e 's/^.* \('$at_range_start' \)/\1/'`
-       AS_VAR_APPEND([at_groups], ["$at_range "])
+       at_range=`AS_ECHO(["$at_groups_all"]) | \
+         sed -ne '/^'$at_range_start'$/,$p'`
+       AS_VAR_APPEND([at_groups], ["$at_range$as_nl"])
        ;;
 
     [-[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_fn_validate_ranges at_range_end
-       at_range=`AS_ECHO([" $at_groups_all "]) | \
-         sed -e 's/\( '$at_range_end'\) .*$/\1/'`
-       AS_VAR_APPEND([at_groups], ["$at_range "])
+       at_range=`AS_ECHO(["$at_groups_all"]) | \
+         sed -ne '1,/^'$at_range_end'$/p'`
+       AS_VAR_APPEND([at_groups], ["$at_range$as_nl"])
        ;;
 
     [[0-9]-[0-9] | [0-9]-[0-9][0-9] | [0-9]-[0-9][0-9][0-9]] | \
@@ -569,10 +567,9 @@ do
          at_range_start=$at_tmp
        fi
        at_fn_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/'`
-       AS_VAR_APPEND([at_groups], ["$at_range "])
+       at_range=`AS_ECHO(["$at_groups_all"]) | \
+         sed -ne '/^'$at_range_start'$/,/^'$at_range_end'$/p'`
+       AS_VAR_APPEND([at_groups], ["$at_range$as_nl"])
        ;;
 
     # Directory selection.
@@ -627,11 +624,9 @@ do
          at_groups_selected=`AS_ECHO(["$at_groups_selected"]) |
              grep -i $at_invert ["^[1-9][^;]*;.*[; ]$at_keyword[ ;]"]`
        done
-       # Smash the newlines.
-       at_groups_selected=`AS_ECHO(["$at_groups_selected"]) | sed 's/;.*//' |
-         tr "$as_nl" ' '
-       `
-       AS_VAR_APPEND([at_groups], ["$at_groups_selected "])
+       # Smash the keywords.
+       at_groups_selected=`AS_ECHO(["$at_groups_selected"]) | sed 's/;.*//'`
+       AS_VAR_APPEND([at_groups], ["$at_groups_selected$as_nl"])
        ;;
     --recheck)
        at_recheck=:
@@ -679,11 +674,11 @@ else
        s/^[ ]*\([1-9][0-9]*\):.*/\1/p
       }
       /^## Detailed failed tests/q
-      '] "$at_suite_log" | tr "$as_nl" ' '`
-    AS_VAR_APPEND([at_groups], ["$at_oldfails"])
+      '] "$at_suite_log"`
+    AS_VAR_APPEND([at_groups], ["$at_oldfails$as_nl"])
   fi
   # Sort the tests, removing duplicates.
-  at_groups=`AS_ECHO(["$at_groups"]) | tr ' ' "$as_nl" | sort -nu`
+  at_groups=`AS_ECHO(["$at_groups"]) | sort -nu | sed '/^$/d'`
 fi
 
 if test x"$at_color" = xalways \
@@ -777,21 +772,13 @@ AT_TESTSUITE_NAME test groups:
       KEYWORDS
 
 _ATEOF
-  # Passing at_groups is tricky.  We cannot use it to form a literal string
-  # or regexp because of the limitation of AIX awk.  And Solaris' awk
-  # doesn't grok more than 99 fields in a record, so we have to use `split'.
-  # at_groups needs to be space-separated for this script to work.
-  case $at_groups in
-    *"$as_nl"* )
-      at_groups=`AS_ECHO(["$at_groups"]) | tr "$as_nl" ' '` ;;
-  esac
-  AS_ECHO(["$at_groups$as_nl$at_help_all"]) |
-    awk 'BEGIN { FS = ";" }
-        NR == 1 {
-          for (n = split ($ 0, a, " "); n; n--)
-            selected[[a[n]]] = 1
+  # Pass an empty line as separator between selected groups and help.
+  AS_ECHO(["$at_groups$as_nl$as_nl$at_help_all"]) |
+    awk 'NF == 1 && FS != ";" {
+          selected[[$ 1]] = 1
           next
         }
+        /^$/ { FS = ";" }
         NF > 0 {
           if (selected[[$ 1]]) {
             printf " %3d: %-18s %s\n", $ 1, $ 2, $ 3
@@ -1392,8 +1379,7 @@ dnl cause changed test semantics; e.g., a sleep will be interrupted.
 
   echo
   # Turn jobs into a list of numbers, starting from 1.
-  at_joblist=`AS_ECHO([" $at_groups_all "]) | \
-    sed 's/\( '$at_jobs'\) .*/\1/'`
+  at_joblist=`AS_ECHO(["$at_groups"]) | sed -n 1,${at_jobs}p`
 
   set X $at_joblist
   shift
@@ -1844,7 +1830,6 @@ m4_define([AT_line], AT_LINE)
 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_GROUPS])dnl
 [#AT_START_]AT_ordinal
 at_fn_group_banner AT_ordinal 'm4_defn([AT_line])' \
index 811417bcc63622e9cb7299193ae96c01b6671d9d..fc636e9e5e33877910a9d3efcc1c56ddcb6f2987 100644 (file)
@@ -811,6 +811,20 @@ AT_CHECK([:])
 ])
 
 
+## ---------------- ##
+## Huge testsuite.  ##
+## ---------------- ##
+
+# Ensure we don't hit line length limits with large test suites.
+
+AT_CHECK_AT_TEST([Huge testsuite],
+[m4_for([nnn], [1], [1999], [],
+[AT_CLEANUP
+AT_SETUP([test ]nnn)
+])
+], [], [], [], [ignore], [], [], [1999])
+
+
 ## ----------------- ##
 ## Debugging a test. ##
 ## ----------------- ##