X-Git-Url: http://nitlanguage.org diff --git a/tests/tests.sh b/tests/tests.sh index 6483969..6455466 100755 --- a/tests/tests.sh +++ b/tests/tests.sh @@ -19,7 +19,9 @@ # Set lang do default to avoid failed tests because of locale export LANG=C +export LC_ALL=C export NIT_TESTING=true +export MNIT_SRAND=0 unset NIT_DIR @@ -44,7 +46,6 @@ Usage: $e [options] modulenames -h This help --engine Use a specific engine (default=nitg) --noskip Do not skip a test even if the .skip file matches ---[no]soso Force enable (or disable) SOSO END } @@ -60,16 +61,16 @@ function compare_to_result() local pattern="$1" local sav="$2" if [ ! -r "$sav" ]; then return 0; fi + test "`cat "$sav"`" = "UNDEFINED" && return 1 diff -u "$sav" "out/$pattern.res" > "out/$pattern.diff.sav.log" if [ "$?" == 0 ]; then return 1 fi - [ -z "$soso" ] && return 3 sed '/[Ww]arning/d;/[Ee]rror/d' "out/$pattern.res" > "out/$pattern.res2" sed '/[Ww]arning/d;/[Ee]rror/d' "$sav" > "out/$pattern.sav2" grep '[Ee]rror' "out/$pattern.res" >/dev/null && echo "Error" >> "out/$pattern.res2" grep '[Ee]rror' "$sav" >/dev/null && echo "Error" >> "out/$pattern.sav2" - diff -u "out/$pattern.sav2" "out/$pattern.res2" > "out/$pattern.diff.sav.log" + diff -u "out/$pattern.sav2" "out/$pattern.res2" > "out/$pattern.diff.sav.log2" if [ "$?" == 0 ]; then return 2 else @@ -95,7 +96,7 @@ function process_result() OLD="" LIST="" FIRST="" - echo >>$xml "" + echo >>$xml "" #for sav in "sav/$engine/fixme/$pattern.res" "sav/$engine/$pattern.res" "sav/fixme/$pattern.res" "sav/$pattern.res" "sav/$pattern.sav"; do for savdir in $savdirs; do sav=$savdir/fixme/$pattern.res @@ -109,7 +110,10 @@ function process_result() LIST="$LIST $sav" ;; 2) - SOSOF="$sav" + if [ -z "$FIRST" ]; then + SOSOF="$sav" + FIRST="$sav" + fi LIST="$LIST $sav" ;; 3) @@ -132,7 +136,10 @@ function process_result() LIST="$LIST $sav" ;; 2) - SOSO="$sav" + if [ -z "$FIRST" ]; then + SOSO="$sav" + FIRST="$sav" + fi LIST="$LIST $sav" ;; 3) @@ -166,17 +173,26 @@ function process_result() echo >>$xml "" fi todos="$todos $pattern" - elif [ -n "$SOSO" ]; then - echo "[soso] out/$pattern.res $SOSO" - ok="$ok $pattern" elif [ "x$NYI" = "x0" ]; then echo "[todo] out/$pattern.res -> not yet implemented" echo >>$xml "" todos="$todos $pattern" + elif [ -n "$SOSO" ]; then + echo "[======= soso out/$pattern.res $SOSO =======]" + echo >>$xml "" + echo >>$xml ">$xml -n 50 + echo >>$xml "]]>" + nok="$nok $pattern" + echo "$ii" >> "$ERRLIST" elif [ -n "$SOSOF" ]; then - echo "[fixme soso] out/$pattern.res $SOSOF" - echo >>$xml "" - todos="$todos $pattern" + echo "[======= fixme soso out/$pattern.res $SOSOF =======]" + echo >>$xml "" + echo >>$xml ">$xml -n 50 + echo >>$xml "]]>" + nok="$nok $pattern" + echo "$ii" >> "$ERRLIST" elif [ -n "$NSAV" ]; then echo "[======= fail out/$pattern.res $NSAV =======]" echo >>$xml "" @@ -200,6 +216,7 @@ function process_result() cat -v >>$xml out/$pattern.res echo >>$xml "]]>" nos="$nos $pattern" + echo "$ii" >> "$ERRLIST" else # no sav but empty res echo "[0k] out/$pattern.res is empty" @@ -218,12 +235,12 @@ need_skip() test "$noskip" = true && return 1 if echo "$1" | grep -f "$engine.skip" >/dev/null 2>&1; then echo "=> $2: [skip]" - echo >>$xml "" + echo >>$xml "" return 0 fi - if test $engine = niti && echo "$1" | grep -f "exec.skip" >/dev/null 2>&1; then + if test -n "$isinterpret" && echo "$1" | grep -f "exec.skip" >/dev/null 2>&1; then echo "=> $2: [skip exec]" - echo >>$xml "" + echo >>$xml "" return 0 fi return 1 @@ -272,12 +289,11 @@ while [ $stop = false ]; do -h) usage; exit;; --engine) engine="$2"; shift; shift;; --noskip) noskip=true; shift;; - --soso) soso=true; shift;; - --nososo) nososo=true; shift;; *) stop=true esac done enginebinname=$engine +isinterpret= case $engine in nitg) engine=nitg-s; @@ -292,15 +308,30 @@ case $engine in enginebinname=nitg; OPT="--erasure $OPT" ;; + nitg-sg) + enginebinname=nitg; + OPT="--semi-global $OPT" + ;; nitg-g) enginebinname=nitg; OPT="--global $OPT" ;; nit) engine=niti + isinterpret=true ;; niti) enginebinname=nit + isinterpret=true + ;; + nitvm) + isinterpret=true + savdirs="sav/niti/" + ;; + emscripten) + enginebinname=nitg + OPT="-m emscripten_nodejs.nit --semi-global $OPT" + savdirs="sav/nitg-sg/" ;; nitc) echo "disabled engine $engine" @@ -389,11 +420,18 @@ for ii in "$@"; do if [ -f "$f.inputs" ]; then inputs="$f.inputs" + export MNIT_READ_INPUT="$f.inputs" else inputs=/dev/null + export MNIT_READ_INPUT=/dev/null fi - if [ "$engine" = "niti" ]; then + ffout="$ff.bin" + if [ "$engine" = "emscripten" ]; then + ffout="$ff.bin.js" + fi + + if [ -n "$isinterpret" ]; then cat > "./$ff.bin" < "$ff.cmp.err" > "$ff.compile.log" + /usr/bin/time -f%U -o "$ff.time.out" $TIMEOUT $NITC --no-color $OPT -o "$ffout" "$i" $includes $nocc 2> "$ff.cmp.err" > "$ff.compile.log" ERR=$? if [ "x$verbose" = "xtrue" ]; then cat "$ff.compile.log" cat >&2 "$ff.cmp.err" fi fi + if [ "$engine" = "emscripten" ]; then + echo > "./$ff.bin" "nodejs $ffout \"\$@\"" + chmod +x "$ff.bin" + if grep "Fatal Error: more than one primitive class" "$ff.compile.log" > /dev/null; then + echo " [skip] do no not imports kernel" + echo >>$xml "" + continue + fi + fi if [ "$ERR" != 0 ]; then echo -n "! " cat "$ff.compile.log" "$ff.cmp.err" > "$ff.res" process_result $bf $bf $pack - elif skip_exec "$bf"; then - # No exec - > "$ff.res" - process_result $bf $bf $pack elif [ -n "$nocc" ]; then # not compiled echo -n "nocc " > "$ff.res" process_result $bf $bf $pack elif [ -x "./$ff.bin" ]; then + if skip_exec "$bf"; then + # No exec + > "$ff.res" + process_result $bf $bf $pack + break + fi echo -n ". " # Execute args="" @@ -484,7 +533,7 @@ END echo -n "==> $name " echo "./$ff.bin $args" > "./$fff.bin" chmod +x "./$fff.bin" - WRITE="$fff.write" sh -c "NIT_NO_STACK=1 $TIMEOUT ./$fff.bin < $ffinputs > $fff.res 2>$fff.err" + WRITE="$fff.write" /usr/bin/time -f%U -o "$fff.time.out" sh -c "NIT_NO_STACK=1 $TIMEOUT ./$fff.bin < $ffinputs > $fff.res 2>$fff.err" if [ "x$verbose" = "xtrue" ]; then cat "$fff.res" cat >&2 "$fff.err" @@ -502,7 +551,8 @@ END done < $fargs fi elif [ -f "./$ff.bin" ]; then - echo "Not executable (platform?)" > "$ff.res" + #Not executable (platform?)" + > "$ff.res" process_result $bf "$bf" $pack else echo -n "! " @@ -532,10 +582,11 @@ fi # write $ERRLIST if [ "x$ERRLIST" != "x" ]; then - if [ -x "$ERRLIST_TARGET" ]; then + if [ -f "$ERRLIST_TARGET" ]; then mv "$ERRLIST_TARGET" "${ERRLIST_TARGET}.bak" fi - mv $ERRLIST $ERRLIST_TARGET + uniq $ERRLIST > $ERRLIST_TARGET + rm $ERRLIST fi echo >>$xml ""