]> git.draconx.ca Git - cdecl99.git/blobdiff - tests/crossparse-c-random.sh
Batch up crossparse tests to improve performance.
[cdecl99.git] / tests / crossparse-c-random.sh
index 8fb1b633039d96d2bc39e66fcb9ed2014b5cb5d8..9fc45fb4b7d6415028d8b8197fa0e545e6e04815 100755 (executable)
@@ -14,19 +14,52 @@ randomdecl=test/randomdecl$EXEEXT
 crossparse=test/crossparse$EXEEXT
 test -x $randomdecl || exit 77
 
+# Slow case: run tests one at a time to determine exactly which one failed.
+first_failed() {
+       ff_count=0
+
+       while test $# -gt 0
+       do
+               $crossparse "$1" 2>/dev/null || break
+               ff_count=`expr $ff_count + 1`
+               shift
+       done
+
+       echo "$ff_count"
+}
+
 proc() {
        result=pass
        count=0
 
+       set x
        while read decl
        do
-               count=`expr $count + 1`
-               $crossparse "$decl" || { result=fail
-                       printf 'original input: %s\n' "$decl" 1>&2
-                       break
+               set "$@" "$decl"
+
+               # Accumulate tests in $@ and run them in batches to avoid
+               # significant startup costs.
+               if test $# -gt 25; then
+                       shift
+                       $crossparse "$@" || { result=fail
+                               tmp_count=`first_failed "$@"`
+                               count=`expr $count + $tmp_count`
+                               break
                        }
+                       count=`expr $count + $#`
+                       set x
+               fi
        done
 
+       shift
+       if test $# -gt 0 && test x"$result" = x"pass"; then
+               tmp_count=$#
+               $crossparse "$@" || { result=fail
+                       tmp_count=`first_failed "$@"`
+               }
+               count=`expr $count + $tmp_count`
+       fi
+
        echo "result=$result"
        echo "count=$count"
 }