tests.sh: add NIT_TESTING_ID with the same semantic than with nitunit
[nit.git] / tests / tests.sh
index 6330517..d11c60a 100755 (executable)
 export LANG=C
 export LC_ALL=C
 export NIT_TESTING=true
+# Use the pid as a collision prevention
+export NIT_TESTING_ID=$$
 export NIT_SRAND=0
 
 unset NIT_DIR
 
 # Get the first Java lib available
-shopt -s nullglob
-JAVA_HOME=$(dirname $(dirname $(readlink -f $(which javac))))
-
-paths=`echo $JAVA_HOME/jre/lib/*/{client,server}/libjvm.so`
-paths=($paths)
-JNI_LIB_PATH=`dirname ${paths[0]}`
-shopt -u nullglob
+if which_java=$(which javac 2>/dev/null); then
+       JAVA_HOME=$(dirname $(dirname $(readlink -f "$which_java")))
+
+       shopt -s nullglob
+       paths=`echo $JAVA_HOME/jre/lib/*/{client,server}/libjvm.so`
+       paths=($paths)
+       JNI_LIB_PATH=`dirname ${paths[0]}`
+       shopt -u nullglob
+fi
 
 outdir="out"
 compdir="nit_compile"
@@ -90,8 +94,8 @@ saferun()
                esac
        done
        (
-       ulimit -f "$filelimit"
-       ulimit -t "$usertimelimit"
+       ulimit -f "$filelimit" 2> /dev/null
+       ulimit -t "$usertimelimit" 2> /dev/null
        if test -d "$1"; then
                find $1 | sort
        elif test -n "$TIME"; then
@@ -260,7 +264,7 @@ function process_result()
                esac
        done
        OLD=`echo "$OLD" | sed -e 's/   */ /g' -e 's/^ //' -e 's/ $//'`
-       grep 'NOT YET IMPLEMENTED' "$outdir/$pattern.res" >/dev/null
+       istodo  "$outdir/$pattern.res"
        NYI="$?"
        if [ -n "$SAV" ]; then
                if [ -n "$OLD" ]; then
@@ -404,6 +408,20 @@ skip_cc()
        return 1
 }
 
+# Check that the resfile ($1) matches some magic strings in `todo` files.
+istodo()
+{
+       test "$no" = true && return 1
+       for savdir in $savdirs .; do
+               local f="$savdir/todo"
+               test -f "$f" || continue
+               if grep -f "$f" "$1" >/dev/null 2>&1; then
+                       return 0
+               fi
+       done
+       return 1
+}
+
 find_nitc()
 {
        local name="$enginebinname"
@@ -564,7 +582,7 @@ for ii in "$@"; do
 
        tmp=${ii/../AA}
        if [ "x$tmp" = "x$ii" ]; then
-               includes="-I . -I ../lib/standard -I ../lib/standard/collection -I alt"
+               includes="-I . -I ../lib/core -I ../lib/core/collection -I alt"
        else
                includes="-I alt"
        fi