tests: allow multiple lines in argument files
authorJean-Sebastien Gelinas <calestar@gmail.com>
Thu, 23 Jul 2009 16:37:03 +0000 (12:37 -0400)
committerJean Privat <jean@pryen.org>
Tue, 28 Jul 2009 13:38:29 +0000 (09:38 -0400)
Signed-off-by: Jean-Sebastien Gelinas <calestar@gmail.com>
Signed-off-by: Jean Privat <jean@pryen.org>

14 files changed:
tests/sav/shootout_ackermann.sav
tests/sav/shootout_ackermann_args1.sav [new file with mode: 0644]
tests/sav/shootout_binarytrees.sav
tests/sav/shootout_binarytrees_args1.sav [new file with mode: 0644]
tests/sav/shootout_mandelbrot.sav
tests/sav/shootout_mandelbrot_args1.sav [new file with mode: 0644]
tests/sav/shootout_pidigits.sav [new file with mode: 0644]
tests/sav/shootout_pidigits_args1.sav [new file with mode: 0644]
tests/sav/test_args.sav
tests/sav/test_args_args1.sav [new file with mode: 0644]
tests/sav/test_args_args2.sav [new file with mode: 0644]
tests/sav/test_args_args3.sav [new file with mode: 0644]
tests/test_args.args
tests/tests.sh

diff --git a/tests/sav/shootout_ackermann_args1.sav b/tests/sav/shootout_ackermann_args1.sav
new file mode 100644 (file)
index 0000000..6d42236
--- /dev/null
@@ -0,0 +1 @@
+Ack(3,4): 125
index c8f333d..72654db 100644 (file)
@@ -1,6 +1,4 @@
-stretch tree of depth 11        check: -1
-2048    trees of depth 4        check: -2048
-512     trees of depth 6        check: -512
-128     trees of depth 8        check: -128
-32      trees of depth 10       check: -32
-long lived tree of depth 10     check: -1
+stretch tree of depth 7         check: -1
+128     trees of depth 4        check: -128
+32      trees of depth 6        check: -32
+long lived tree of depth 6      check: -1
diff --git a/tests/sav/shootout_binarytrees_args1.sav b/tests/sav/shootout_binarytrees_args1.sav
new file mode 100644 (file)
index 0000000..c8f333d
--- /dev/null
@@ -0,0 +1,6 @@
+stretch tree of depth 11        check: -1
+2048    trees of depth 4        check: -2048
+512     trees of depth 6        check: -512
+128     trees of depth 8        check: -128
+32      trees of depth 10       check: -32
+long lived tree of depth 10     check: -1
index 2c6ff6b..63e1706 100644 (file)
Binary files a/tests/sav/shootout_mandelbrot.sav and b/tests/sav/shootout_mandelbrot.sav differ
diff --git a/tests/sav/shootout_mandelbrot_args1.sav b/tests/sav/shootout_mandelbrot_args1.sav
new file mode 100644 (file)
index 0000000..2c6ff6b
Binary files /dev/null and b/tests/sav/shootout_mandelbrot_args1.sav differ
diff --git a/tests/sav/shootout_pidigits.sav b/tests/sav/shootout_pidigits.sav
new file mode 100644 (file)
index 0000000..7d94ead
--- /dev/null
@@ -0,0 +1,5 @@
+Assert 'not_empty'  failed in abstract_collection::IndexedCollectionRead::(abstract_collection::Collection::first) (../lib/standard/abstract_collection.nit:292)
+,---- Stack trace -- - -  -
+| abstract_collection::IndexedCollectionRead::(abstract_collection::Collection::first) (../lib/standard/abstract_collection.nit:288)
+| shootout_pidigits::Sys::(kernel::Sys::main) (./shootout_pidigits.nit:138)
+`------------------- - -  -
diff --git a/tests/sav/shootout_pidigits_args1.sav b/tests/sav/shootout_pidigits_args1.sav
new file mode 100644 (file)
index 0000000..6225592
--- /dev/null
@@ -0,0 +1,100 @@
+3140000000     :10
+0000000000     :20
+0000000000     :30
+1100000000     :40
+0000000000     :50
+0000000000     :60
+1100000000     :70
+0000000000     :80
+0000000000     :90
+1100000000     :100
+0000000000     :110
+0000000000     :120
+1100000000     :130
+0000000000     :140
+0000000000     :150
+1100000000     :160
+0000000000     :170
+0000000000     :180
+1100000000     :190
+0000000000     :200
+0000000000     :210
+1100000000     :220
+0000000000     :230
+0000000000     :240
+1100000000     :250
+0000000000     :260
+0000000000     :270
+1100000000     :280
+0000000000     :290
+0000000000     :300
+1100000000     :310
+0000000000     :320
+0000000000     :330
+1100000000     :340
+0000000000     :350
+0000000000     :360
+1100000000     :370
+0000000000     :380
+0000000000     :390
+1100000000     :400
+0000000000     :410
+0000000000     :420
+1100000000     :430
+0000000000     :440
+0000000000     :450
+1100000000     :460
+0000000000     :470
+0000000000     :480
+1100000000     :490
+0000000000     :500
+0000000000     :510
+1100000000     :520
+0000000000     :530
+0000000000     :540
+1100000000     :550
+0000000000     :560
+0000000000     :570
+1100000000     :580
+0000000000     :590
+0000000000     :600
+1100000000     :610
+0000000000     :620
+0000000000     :630
+1100000000     :640
+0000000000     :650
+0000000000     :660
+1100000000     :670
+0000000000     :680
+0000000000     :690
+1100000000     :700
+0000000000     :710
+0000000000     :720
+1100000000     :730
+0000000000     :740
+0000000000     :750
+1100000000     :760
+0000000000     :770
+0000000000     :780
+1100000000     :790
+0000000000     :800
+0000000000     :810
+1100000000     :820
+0000000000     :830
+0000000000     :840
+1100000000     :850
+0000000000     :860
+0000000000     :870
+1100000000     :880
+0000000000     :890
+0000000000     :900
+1100000000     :910
+0000000000     :920
+0000000000     :930
+1100000000     :940
+0000000000     :950
+0000000000     :960
+1100000000     :970
+0000000000     :980
+0000000000     :990
+1100000000     :1000
index b40d0b8..d985eb5 100644 (file)
@@ -1,4 +1,2 @@
-nb args: 2
+nb args: 0
 args:
-       first
-       second
diff --git a/tests/sav/test_args_args1.sav b/tests/sav/test_args_args1.sav
new file mode 100644 (file)
index 0000000..b40d0b8
--- /dev/null
@@ -0,0 +1,4 @@
+nb args: 2
+args:
+       first
+       second
diff --git a/tests/sav/test_args_args2.sav b/tests/sav/test_args_args2.sav
new file mode 100644 (file)
index 0000000..8334bd9
--- /dev/null
@@ -0,0 +1,4 @@
+nb args: 2
+args:
+       first only
+       second
diff --git a/tests/sav/test_args_args3.sav b/tests/sav/test_args_args3.sav
new file mode 100644 (file)
index 0000000..7a507d5
--- /dev/null
@@ -0,0 +1,14 @@
+nb args: 12
+args:
+       this
+       is
+       some
+       king
+       of
+       test,
+       long
+       and
+       with
+       some
+       weird
+       char$
index 45f9997..67b514b 100644 (file)
@@ -1 +1,3 @@
 first second
+"first only" second
+this is some king of test, long and with some weird char$
index 8fccfbd..36d501d 100755 (executable)
@@ -34,6 +34,54 @@ Usage: $e [options] modulenames
 END
 }
 
+# As argument: the pattern used for the file
+function process_result()
+{
+       # Result
+       pattern=$1
+       SAV=""
+       FAIL=""
+       if [ -r "sav/$pattern.sav" ]; then
+               diff -u "$pattern.res" "sav/$pattern.sav" > "$pattern.diff.sav.log"
+               if [ "$?" == 0 ]; then
+                       SAV=OK
+               else
+                       SAV=NOK
+               fi
+       fi
+       if [ -r "sav/$pattern.fail" ]; then
+               diff -u "$pattern.res" "sav/$pattern.fail" > "$pattern.diff.fail.log"
+               if [ "$?" == 0 ]; then
+                       FAIL=OK
+               else
+                       FAIL=NOK
+               fi
+       fi
+       if [ "x$SAV" = "xOK" ]; then
+               if [ "x$FAIL" = "x" ]; then
+                       echo "[ok] $pattern.res"
+               else
+                       echo "[ok] $pattern.res - but sav/$pattern.fail remains!"
+               fi
+               ok="$ok $pattern"
+       elif [ "x$FAIL" = "xOK" ]; then
+               echo "[fail] $pattern.res"
+               ok="$ok $pattern"
+       elif [ "x$SAV" = "xNOK" ]; then
+               echo "[======= fail $pattern.res sav/$pattern.sav =======]"
+               nok="$nok $ff"
+               echo "$ii" >> "$ERRLIST"
+       elif [ "x$FAIL" = "xNOK" ]; then
+               echo "[======= changed $pattern.res sav/$pattern.fail ======]"
+               nok="$nok $ff"
+               echo "$ii" >> "$ERRLIST"
+       else
+               echo "[=== no sav ===] $pattern.res"
+               nos="$nos $pattern"
+       fi
+}
+
+
 verbose=false
 stop=false
 while [ $stop = false ]; do
@@ -103,14 +151,11 @@ for ii in "$@"; do
                if [ "$ERR" != 0 ]; then
                        echo -n "! "
                        cp "$ff.cmp.err" "$ff.res"
+                       process_result $ff
                elif [ -x "./$ff.bin" ]; then
                        echo -n ". "
                        # Execute
-                       if [ -f "$f.args" ]; then
-                               args=`cat "$f.args"`
-                       else
-                               args=""
-                       fi
+                       args=""
                        if [ "x$verbose" = "xtrue" ]; then
                                echo ""
                                echo "./$ff.bin" $args
@@ -130,51 +175,43 @@ for ii in "$@"; do
                        if [ -s "$ff.err" ]; then
                                cat "$ff.err" >> "$ff.res"
                        fi
-               else
-                       echo -n "! "
-                       echo "Compilation error" > "$ff.res"
-               fi
+                       process_result $ff
 
-               # Result
-               SAV=""
-               FAIL=""
-               if [ -r "sav/$ff.sav" ]; then
-                       diff -u "$ff.res" "sav/$ff.sav" > "$ff.diff.sav.log"
-                       if [ "$?" == 0 ]; then
-                               SAV=OK
-                       else
-                               SAV=NOK
-                       fi
-               fi
-               if [ -r "sav/$ff.fail" ]; then
-                       diff -u "$ff.res" "sav/$ff.fail" > "$ff.diff.fail.log"
-                       if [ "$?" == 0 ]; then
-                               FAIL=OK
-                       else
-                               FAIL=NOK
-                       fi
-               fi
-               if [ "x$SAV" = "xOK" ]; then
-                       if [ "x$FAIL" = "x" ]; then
-                               echo "[ok] $ff.res"
-                       else
-                               echo "[ok] $ff.res - but sav/$ff.fail remains!"
+                       if [ -f "$f.args" ]; then
+                               fargs=$f.args
+                               cptr=0
+                               cat $fargs |
+                               while read line; do
+                                       ((cptr=cptr+1))
+                                       args=$line
+                                       fff=$ff"_args"$cptr
+                                       if [ "x$verbose" = "xtrue" ]; then
+                                               echo ""
+                                               echo "./$ff.bin" $args
+                                       fi
+                                       echo -n "==> args #"$cptr " "
+                                       if [ -f "$f.inputs" ]; then
+                                               "./$ff.bin" $args < "$f.inputs" > "$fff.res" 2>"$fff.err"
+                                       else
+                                               sh -c "./$ff.bin  ''$args > $fff.res 2>$fff.err"
+                                       fi
+                                       if [ "x$verbose" = "xtrue" ]; then
+                                               cat "$fff.res"
+                                               cat >&2 "$fff.err"
+                                       fi
+                                       if [ -f "$fff.write" ]; then
+                                               cat "$fff.write" >> "$fff.res"
+                                       fi
+                                       if [ -s "$fff.err" ]; then
+                                               cat "$fff.err" >> "$fff.res"
+                                       fi
+                                       process_result $fff
+                               done
                        fi
-                       ok="$ok $ff"
-               elif [ "x$FAIL" = "xOK" ]; then
-                       echo "[fail] $ff.res"
-                       ok="$ok $ff"
-               elif [ "x$SAV" = "xNOK" ]; then
-                       echo "[======= fail $ff.res sav/$ff.sav =======]"
-                       nok="$nok $ff"
-                       echo "$ii" >> "$ERRLIST"
-               elif [ "x$FAIL" = "xNOK" ]; then
-                       echo "[======= changed $ff.res sav/$ff.fail ======]"
-                       nok="$nok $ff"
-                       echo "$ii" >> "$ERRLIST"
                else
-                       echo "[=== no sav ===] $ff.res"
-                       nos="$nos $ff"
+                       echo -n "! "
+                       echo "Compilation error" > "$ff.res"
+                       process_result $ff
                fi
        done
 done