syntax: while/loop exit type evolution
[nit.git] / tests / tests.sh
index 78188fd..2dfc5e8 100755 (executable)
@@ -132,29 +132,40 @@ for ii in "$@"; do
                echo "File '$ii' does not exist."
                continue
        fi
+
+       tmp=${ii/../AA}
+       if [ "x$tmp" = "x$ii" ]; then
+               oincludes="-I . -I ../lib/standard -I ../lib/standard/collection"
+       else
+               oincludes=""
+       fi
+
        for alt in "" `sed -n 's/.*#!*\(alt[0-9]*\)#.*/\1/p' "$ii" | sort -u`; do
                f=`basename "$ii" .nit`
                d=`dirname "$ii"`
                ff="$f"
                i="$ii"
+               includes="$oincludes"
+
                if [ "x$alt" != "x" ]; then
                        test -d alt || mkdir -p alt
                        i="alt/${f}_$alt.nit"
                        ff="${ff}_$alt"
                        sed "s/#$alt#//g;/#!$alt#/d" "$ii" > "$i"
+                       includes="$includes -I alt"
                fi
                ff="$ff$MARK"
 
                echo -n "=> $i: "
 
-               rm "$ff.res" "$ff.err" "$ff.write" "$ff.bin" 2> /dev/null
+               rm -rf "$ff.res" "$ff.err" "$ff.write" "$ff.bin" 2> /dev/null
 
                # Compile
                if [ "x$verbose" = "xtrue" ]; then
                        echo ""
-                       echo $NITC $OPT -o "$ff.bin" "$i" -I . -I alt -I ../lib/standard
+                       echo $NITC $OPT -o "$ff.bin" "$i" "$includes"
                fi
-               $NITC $OPT -o "$ff.bin" "$i" -I . -I alt -I ../lib/standard 2> "$ff.cmp.err" > "$ff.compile.log"
+               $NITC $OPT -o "$ff.bin" "$i" $includes 2> "$ff.cmp.err" > "$ff.compile.log"
                ERR=$?
                if [ "x$verbose" = "xtrue" ]; then
                        cat "$ff.compile.log"
@@ -171,12 +182,12 @@ for ii in "$@"; do
                        args=""
                        if [ "x$verbose" = "xtrue" ]; then
                                echo ""
-                               echo "./$ff.bin" $args
+                               echo "NIT_NO_STACK=1 ./$ff.bin" $args
                        fi
                        if [ -f "$f.inputs" ]; then
-                               "./$ff.bin" $args < "$f.inputs" > "$ff.res" 2>"$ff.err"
+                               NIT_NO_STACK=1 "./$ff.bin" $args < "$f.inputs" > "$ff.res" 2>"$ff.err"
                        else
-                               "./$ff.bin" $args > "$ff.res" 2>"$ff.err"
+                               NIT_NO_STACK=1 "./$ff.bin" $args > "$ff.res" 2>"$ff.err"
                        fi
                        if [ "x$verbose" = "xtrue" ]; then
                                cat "$ff.res"
@@ -184,6 +195,8 @@ for ii in "$@"; do
                        fi
                        if [ -f "$ff.write" ]; then
                                cat "$ff.write" >> "$ff.res"
+                       elif [ -d "$ff.write" ]; then
+                               ls -F $ff.write >> "$ff.res"
                        fi
                        if [ -s "$ff.err" ]; then
                                cat "$ff.err" >> "$ff.res"
@@ -193,20 +206,19 @@ for ii in "$@"; do
                        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
+                                               echo "NIT_NO_STACK=1 ./$ff.bin" $args
                                        fi
                                        echo -n "==> args #"$cptr " "
                                        if [ -f "$f.inputs" ]; then
-                                               "./$ff.bin" $args < "$f.inputs" > "$fff.res" 2>"$fff.err"
+                                               NIT_NO_STACK=1 "./$ff.bin" $args < "$f.inputs" > "$fff.res" 2>"$fff.err"
                                        else
-                                               sh -c "./$ff.bin  ''$args > $fff.res 2>$fff.err"
+                                               sh -c "NIT_NO_STACK=1 ./$ff.bin  ''$args > $fff.res 2>$fff.err"
                                        fi
                                        if [ "x$verbose" = "xtrue" ]; then
                                                cat "$fff.res"
@@ -214,12 +226,14 @@ for ii in "$@"; do
                                        fi
                                        if [ -f "$fff.write" ]; then
                                                cat "$fff.write" >> "$fff.res"
+                                       elif [ -d "$fff.write" ]; then
+                                               ls -F $fff.write >> "$fff.res"
                                        fi
                                        if [ -s "$fff.err" ]; then
                                                cat "$fff.err" >> "$fff.res"
                                        fi
                                        process_result $fff
-                               done
+                               done < $fargs
                        fi
                else
                        echo -n "! "