tests: generate files in out/ instead of tests/
authorJean Privat <jean@pryen.org>
Tue, 10 Apr 2012 17:46:44 +0000 (13:46 -0400)
committerJean Privat <jean@pryen.org>
Tue, 10 Apr 2012 18:30:31 +0000 (14:30 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

.gitignore
tests/Makefile
tests/nitdoc.args
tests/test_directory_create.nit
tests/test_file_write.nit
tests/test_filterstream.nit
tests/tests.sh

index c2b4611..ffba31a 100644 (file)
@@ -40,5 +40,6 @@ tests/alt
 tests/errlist
 tests/test_nitc_logs
 tests/hello_world
+tests/out
 
 *.stub.nit.[ch]
index 946f6be..d856b73 100644 (file)
@@ -23,6 +23,6 @@ store:
        ./store_save.sh *.nit
 
 clean:
-       rm -r -f -- *.bin *.res *.write *.err *.log alt .nit_compile errlist 2> /dev/null || true
+       rm -r -f -- out/ alt .nit_compile errlist 2> /dev/null || true
 
 distclean: clean
index c8f290f..dbbddd3 100644 (file)
@@ -1 +1 @@
-../lib/*.nit -d nitdoc_args1.write
+../lib/*.nit -d out/nitdoc_args1.write
index d2ab573..f64fed1 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-"test_directory_create.write/tmp_dir".mkdir
-var f =  new OFStream.open("test_directory_create.write/tmp_file")
+"out/test_directory_create.write/tmp_dir".mkdir
+var f =  new OFStream.open("out/test_directory_create.write/tmp_file")
 f.write("test")
 f.close
-f =  new OFStream.open("test_directory_create.write/tmp_dir/tmp_file_2")
+f =  new OFStream.open("out/test_directory_create.write/tmp_dir/tmp_file_2")
 f.write("other test")
 f.close
index c4f8f33..5a8f936 100644 (file)
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-var f = new OFStream.open("test_file_write.write")
+var f = new OFStream.open("out/test_file_write.write")
    f.write("Quatre vingt et un : {421}\n")
    f.write("Une autre ligne\nencore un")
    f.write(['e', '\n'].to_s)
index 9faecb8..59a449d 100644 (file)
@@ -17,8 +17,8 @@
 
 import filter_stream
 
-var filename_1 = "test_filterstream_tmp1.write"
-var filename_2 = "test_filterstream_tmp2.write"
+var filename_1 = "out/test_filterstream_tmp1.write"
+var filename_2 = "out/test_filterstream_tmp2.write"
 
 var output_file_1 = new OFStream.open(filename_1)
 var output_file_2 = new OFStream.open(filename_2)
index a1d0f99..a5bc68c 100755 (executable)
@@ -39,7 +39,7 @@ function process_result()
        SAV=""
        FAIL=""
        if [ -r "sav/$pattern.sav" ]; then
-               diff -u "$pattern.res" "sav/$pattern.sav" > "$pattern.diff.sav.log"
+               diff -u "out/$pattern.res" "sav/$pattern.sav" > "out/$pattern.diff.sav.log"
                if [ "$?" == 0 ]; then
                        SAV=OK
                else
@@ -47,7 +47,7 @@ function process_result()
                fi
        fi
        if [ -r "sav/$pattern.fail" ]; then
-               diff -u "$pattern.res" "sav/$pattern.fail" > "$pattern.diff.fail.log"
+               diff -u "out/$pattern.res" "sav/$pattern.fail" > "out/$pattern.diff.fail.log"
                if [ "$?" == 0 ]; then
                        FAIL=OK
                else
@@ -56,24 +56,24 @@ function process_result()
        fi
        if [ "x$SAV" = "xOK" ]; then
                if [ "x$FAIL" = "x" ]; then
-                       echo "[ok] $pattern.res"
+                       echo "[ok] out/$pattern.res"
                else
-                       echo "[ok] $pattern.res - but sav/$pattern.fail remains!"
+                       echo "[ok] out/$pattern.res - but sav/$pattern.fail remains!"
                fi
                ok="$ok $pattern"
        elif [ "x$FAIL" = "xOK" ]; then
-               echo "[fail] $pattern.res"
+               echo "[fail] out/$pattern.res"
                ok="$ok $pattern"
        elif [ "x$SAV" = "xNOK" ]; then
-               echo "[======= fail $pattern.res sav/$pattern.sav =======]"
-               nok="$nok $ff"
+               echo "[======= fail out/$pattern.res sav/$pattern.sav =======]"
+               nok="$nok $pattern"
                echo "$ii" >> "$ERRLIST"
        elif [ "x$FAIL" = "xNOK" ]; then
-               echo "[======= changed $pattern.res sav/$pattern.fail ======]"
-               nok="$nok $ff"
+               echo "[======= changed out/$pattern.res sav/$pattern.fail ======]"
+               nok="$nok $pattern"
                echo "$ii" >> "$ERRLIST"
        else
-               echo "[=== no sav ===] $pattern.res"
+               echo "[=== no sav ===] out/$pattern.res"
                nos="$nos $pattern"
        fi
 }
@@ -128,6 +128,9 @@ make_alts()
 # The default nitc compiler
 [ -z "$NITC" ] && find_nitc
 
+# Set NIT_DIR if needed
+[ -z "$NIT_DIR" ] && export NIT_DIR=..
+
 verbose=false
 stop=false
 while [ $stop = false ]; do
@@ -163,6 +166,9 @@ fi
 ok=""
 nok=""
 
+# CLEAN the out directory
+rm -rf out/ 2>/dev/null
+mkdir out 2>/dev/null
 
 for ii in "$@"; do
        if [ ! -f $ii ]; then
@@ -179,10 +185,9 @@ for ii in "$@"; do
 
        f=`basename "$ii" .nit`
        for i in `make_alts $ii`; do
-               ff=`basename $i .nit`
-               echo -n "=> $ff: "
-
-               rm -rf "$ff.res" "$ff.err" "$ff.write" "$ff.bin" 2> /dev/null
+               bf=`basename $i .nit`
+               ff="out/$bf"
+               echo -n "=> $bf: "
 
                # Compile
                if [ "x$verbose" = "xtrue" ]; then
@@ -199,7 +204,7 @@ for ii in "$@"; do
                if [ "$ERR" != 0 ]; then
                        echo -n "! "
                        cp "$ff.cmp.err" "$ff.res"
-                       process_result $ff
+                       process_result $bf
                elif [ -x "./$ff.bin" ]; then
                        cp "$ff.cmp.err" "$ff.res"
                        echo -n ". "
@@ -226,7 +231,7 @@ for ii in "$@"; do
                        if [ -s "$ff.err" ]; then
                                cat "$ff.err" >> "$ff.res"
                        fi
-                       process_result $ff
+                       process_result $bf
 
                        if [ -f "$f.args" ]; then
                                fargs=$f.args
@@ -234,6 +239,7 @@ for ii in "$@"; do
                                while read line; do
                                        ((cptr=cptr+1))
                                        args=$line
+                                       bff=$bf"_args"$cptr
                                        fff=$ff"_args"$cptr
                                        rm -rf "$fff.res" "$fff.err" "$fff.write" 2> /dev/null
                                        if [ "x$verbose" = "xtrue" ]; then
@@ -258,13 +264,13 @@ for ii in "$@"; do
                                        if [ -s "$fff.err" ]; then
                                                cat "$fff.err" >> "$fff.res"
                                        fi
-                                       process_result $fff
+                                       process_result $bff
                                done < $fargs
                        fi
                else
                        echo -n "! "
                        echo "Compilation error" > "$ff.res"
-                       process_result $ff
+                       process_result $bf
                fi
        done
 done