tests: use most recent nitc if not supplied
[nit.git] / tests / tests.sh
index 36d501d..5b32a7d 100755 (executable)
@@ -20,9 +20,6 @@
 # Set lang do default to avoid failed tests because of locale
 export LANG=C
 
-# The default nitc compiler
-[ -z "$NITC" ] && NITC=../bin/nitc
-
 usage()
 {
        e=`basename "$0"`
@@ -81,6 +78,19 @@ function process_result()
        fi
 }
 
+find_nitc()
+{
+       recent=`ls -t ../src/nitc ../src/nitc_[0-9] ../bin/nitc ../c_src/nitc 2>/dev/null | head -1`
+       if [[ "x$recent" == "x" ]]; then
+               echo 'Could not find nitc, aborting'
+               exit 1
+       fi
+       echo 'Using nitc from: '$recent
+       NITC=$recent
+}
+
+# The default nitc compiler
+[ -z "$NITC" ] && find_nitc
 
 verbose=false
 stop=false
@@ -99,19 +109,18 @@ done
 # File where error tests are outputed
 # Old ERRLIST is backuped
 ERRLIST=${ERRLIST:-errlist}
+ERRLIST_TARGET=$ERRLIST
 
 if [ $# = 0 ]; then
        usage;
        exit
 fi
 
-# Backup and initiate new ERRLIST
+# Initiate new ERRLIST
 if [ "x$ERRLIST" = "x" ]; then
        ERRLIST=/dev=null
 else
-       if [ -x "$ERRLIST" ]; then
-               mv "$ERRLIST" "${ERRLIST}.bak"
-       fi
+       ERRLIST=$ERRLIST.tmp
        > "$ERRLIST"
 fi
 
@@ -226,6 +235,14 @@ if [ -n "$nos" ]; then
        echo "no sav: $nos"
 fi
 
+# write $ERRLIST
+if [ "x$ERRLIST" != "x" ]; then
+       if [ -x "$ERRLIST_TARGET" ]; then
+               mv "$ERRLIST_TARGET" "${ERRLIST_TARGET}.bak"
+       fi
+       mv $ERRLIST $ERRLIST_TARGET
+fi
+
 if [ -n "$nok" ]; then
        exit 1
 else