+ todos="$todos $pattern"
+ elif [ "x$NYI" = "x0" ]; then
+ echo "[todo] $outdir/$pattern.res -> not yet implemented"
+ echo >>$xml "<skipped/>"
+ todos="$todos $pattern"
+ elif [ -n "$SOSO" ]; then
+ echo "[======= soso $outdir/$pattern.res $SOSO =======]"
+ echo >>$xml "<error message='`xmlesc "soso $outdir/$pattern.res $SOSO"`'/>"
+ echo >>$xml "<system-out><![CDATA["
+ cat -v -- "$outdir/$pattern.diff.sav.log" | head >>$xml -n 50
+ echo >>$xml "]]></system-out>"
+ nok="$nok $pattern"
+ echo "$ii" >> "$ERRLIST"
+ elif [ -n "$SOSOF" ]; then
+ echo "[======= fixme soso $outdir/$pattern.res $SOSOF =======]"
+ echo >>$xml "<error message='`xmlesc "soso $outdir/$pattern.res $SOSO"`'/>"
+ echo >>$xml "<system-out><![CDATA["
+ cat -v -- "$outdir/$pattern.diff.sav.log" | head >>$xml -n 50
+ echo >>$xml "]]></system-out>"
+ nok="$nok $pattern"
+ echo "$ii" >> "$ERRLIST"
+ elif [ -n "$NSAV" ]; then
+ echo "[======= fail $outdir/$pattern.res $NSAV =======]"
+ echo >>$xml "<error message='`xmlesc "fail $outdir/$pattern.res $NSAV"`'/>"
+ echo >>$xml "<system-out><![CDATA["
+ cat -v -- "$outdir/$pattern.diff.sav.log" | head >>$xml -n 50
+ echo >>$xml "]]></system-out>"
+ nok="$nok $pattern"
+ echo "$ii" >> "$ERRLIST"
+ elif [ -n "$NFIXME" ]; then
+ echo "[======= changed $outdir/$pattern.res $NFIXME ======]"
+ echo >>$xml "<error message='`xmlesc "changed $outdir/$pattern.res $NFIXME"`'/>"
+ echo >>$xml "<system-out><![CDATA["
+ cat -v -- "$outdir/$pattern.diff.sav.log" | head >>$xml -n 50
+ echo >>$xml "]]></system-out>"
+ nok="$nok $pattern"
+ echo "$ii" >> "$ERRLIST"
+ elif [ -s "$outdir/$pattern.res" ]; then
+ echo "[=== no sav ===] $outdir/$pattern.res is not empty"
+ echo >>$xml "<error message='no sav and not empty'/>"
+ echo >>$xml "<system-out><![CDATA["
+ cat -v >>$xml -- "$outdir/$pattern.res"
+ echo >>$xml "]]></system-out>"
+ nos="$nos $pattern"
+ echo "$ii" >> "$ERRLIST"
+ else
+ # no sav but empty res
+ echo "[0k] $outdir/$pattern.res is empty"
+ ok="$ok $pattern"
+ fi
+ if test -s "$outdir/$pattern.cmp.err"; then
+ echo >>$xml "<system-err><![CDATA["
+ cat -v >>$xml -- "$outdir/$pattern.cmp.err"
+ echo >>$xml "]]></system-err>"
+ fi
+ echo >>$xml "</testcase>"
+}
+
+need_skip()
+{
+ test "$noskip" = true && return 1
+ if echo "$1" | grep -f "$engine.skip" >/dev/null 2>&1; then
+ echo "=> $2: [skip]"
+ echo >>$xml "<testcase classname='`xmlesc "$3"`' name='`xmlesc "$2"`' `timestamp`><skipped/></testcase>"
+ return 0
+ fi
+ if test -n "$isinterpret" && echo "$1" | grep -f "exec.skip" >/dev/null 2>&1; then
+ echo "=> $2: [skip exec]"
+ echo >>$xml "<testcase classname='`xmlesc "$3"`' name='`xmlesc "$2"`' `timestamp`><skipped/></testcase>"
+ return 0
+ fi
+
+ # Skip by OS
+ os_skip_file=`uname`.skip
+ if test -e $os_skip_file && echo "$1" | grep -f "$os_skip_file" >/dev/null 2>&1; then
+ echo "=> $2: [skip os]"
+ echo >>$xml "<testcase classname='`xmlesc "$3"`' name='`xmlesc "$2"`' `timestamp`><skipped/></testcase>"
+ return 0
+ fi
+ return 1
+}
+
+skip_exec()
+{
+ test "$noskip" = true && return 1
+ if echo "$1" | grep -f "exec.skip" >/dev/null 2>&1; then
+ echo -n "_ "
+ return 0
+ fi
+ return 1
+}
+
+skip_cc()
+{
+ test "$noskip" = true && return 1
+ if echo "$1" | grep -f "cc.skip" >/dev/null 2>&1; then
+ return 0
+ fi
+ return 1
+}
+
+find_nitc()
+{
+ name="$enginebinname"
+ recent=`ls -t ../src/$name ../src/$name_[0-9] ../bin/$name ../c_src/$name 2>/dev/null | head -1`
+ if [[ "x$recent" == "x" ]]; then
+ echo "Could not find binary for engine $engine, aborting"
+ exit 1
+ fi
+ if [ "x$isnode" = "xfalse" ]; then
+ echo "Found binary for engine $engine: $recent $OPT"
+ fi
+ NITC=$recent
+}
+
+verbose=false
+isnode=false
+stop=false
+engine=nitc
+noskip=
+savdirs=
+while [ $stop = false ]; do
+ case $1 in
+ -o) OPT="$OPT $2"; shift; shift;;
+ -v) verbose=true; shift;;
+ -h) usage; exit;;
+ --engine) engine="$2"; shift; shift;;
+ --noskip) noskip=true; shift;;
+ --outdir) outdir="$2"; shift; shift;;
+ --compdir) compdir="$2"; shift; shift;;
+ --node) isnode=true; shift;;
+ *) stop=true
+ esac
+done
+enginebinname=$engine
+isinterpret=
+case $engine in
+ nitc|nitg)
+ engine=nitg-s;
+ enginebinname=nitc;
+ OPT="--separate $OPT --compile-dir $compdir"
+ savdirs="sav/nitg-common/"
+ ;;
+ nitcs|nitg-s)
+ enginebinname=nitc;
+ OPT="--separate $OPT --compile-dir $compdir"
+ savdirs="sav/nitg-common/"
+ ;;
+ nitce|nitg-e)
+ enginebinname=nitc;
+ OPT="--erasure $OPT --compile-dir $compdir"
+ savdirs="sav/nitg-common/"
+ ;;
+ nitcsg|nitg-sg)
+ enginebinname=nitc;
+ OPT="--semi-global $OPT --compile-dir $compdir"
+ savdirs="sav/nitg-common/"
+ ;;
+ nitcg|nitg-g)
+ enginebinname=nitc;
+ OPT="--global $OPT --compile-dir $compdir"
+ savdirs="sav/nitg-common/"
+ ;;
+ nit)
+ engine=niti
+ isinterpret=true
+ ;;
+ niti)
+ enginebinname=nit
+ isinterpret=true
+ ;;
+ nitvm)
+ isinterpret=true
+ enginebinname=nit
+ OPT="--vm $OPT"
+ savdirs="sav/niti/"
+ ;;
+ emscripten)
+ enginebinname=nitc
+ OPT="-m emscripten_nodejs.nit --semi-global $OPT --compile-dir $compdir"
+ savdirs="sav/nitg-sg/"
+ ;;
+ nitc)
+ echo "disabled engine $engine"
+ exit 0
+ ;;
+ *)
+ echo "unknown engine $engine"
+ exit 1
+ ;;
+esac
+
+savdirs="sav/$engine $savdirs sav/"
+
+# The default nitc compiler
+[ -z "$NITC" ] && find_nitc
+
+# Set NIT_DIR if needed
+[ -z "$NIT_DIR" ] && export NIT_DIR=..
+
+# Mark to distinguish files among tests
+# MARK=
+
+if [ $# = 0 ]; then
+ usage;
+ exit
+fi
+
+# CLEAN the out directory
+rm -rf "$outdir/" 2>/dev/null
+mkdir "$outdir" 2>/dev/null
+
+# File where error tests are outputed
+# Old ERRLIST is backuped
+ERRLIST=${ERRLIST:-errlist}
+ERRLIST_TARGET=$ERRLIST
+
+# Initiate new ERRLIST
+if [ "x$ERRLIST" = "x" ]; then
+ ERRLIST=/dev/null
+else
+ ERRLIST=$ERRLIST.tmp
+ > "$ERRLIST"