X-Git-Url: http://nitlanguage.org diff --git a/tests/tests.sh b/tests/tests.sh index 36d501d..02ae121 100755 --- a/tests/tests.sh +++ b/tests/tests.sh @@ -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,55 @@ 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 +} + +make_alts0() +{ + ii="$1" + xalt="$2" + fs="" + for alt in `sed -n "s/.*#!*\($xalt[0-9]*\)#.*/\1/p" "$ii" | sort -u`; do + f=`basename "$ii" .nit` + d=`dirname "$ii"` + ff="$f" + i="$ii" + + if [ "x$alt" != "x" ]; then + test -d alt || mkdir -p alt + i="alt/${f}_$alt.nit" + ff="${ff}_$alt" + sed "s/#$alt#//g;/#!$alt#/d" "$ii" > "$i" + fi + ff="$ff$MARK" + fs="$fs $i" + done + echo "$fs" +} +make_alts() +{ + ii="$1" + fs="$1" + for xalt in `sed -n 's/.*#!*\([0-9]*alt\)[0-9]*#.*/\1/p' "$ii" | sort -u`; do + fs2="" + for f in $fs; do + fs2="$fs2 `make_alts0 $f $xalt`" + done + fs="$fs $fs2" + done + echo "$fs" +} + +# The default nitc compiler +[ -z "$NITC" ] && find_nitc verbose=false stop=false @@ -99,49 +145,51 @@ 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 ok="" nok="" + for ii in "$@"; do - for alt in "" `sed -n 's/.*#!*\(alt[0-9]*\)#.*/\1/p' "$ii" | sort -u`; do - f=`basename "$ii" .nit` - d=`dirname "$ii"` - ff="$f" - i="$ii" - if [ "x$alt" != "x" ]; then - test -d alt || mkdir -p alt - i="alt/${f}_$alt.nit" - ff="${ff}_$alt" - sed "s/#$alt#//g;/#!$alt#/d" "$ii" > "$i" - fi - ff="$ff$MARK" + if [ ! -f $ii ]; then + echo "File '$ii' does not exist." + continue + fi - echo -n "=> $i: " + tmp=${ii/../AA} + if [ "x$tmp" = "x$ii" ]; then + includes="-I . -I ../lib/standard -I ../lib/standard/collection -I alt" + else + includes="-I alt" + fi + + f=`basename "$ii" .nit` + for i in `make_alts $ii`; do + ff=`basename $i .nit` + echo -n "=> $ff: " - rm "$ff.res" "$ff.err" "$ff.write" "$ff.bin" 2> /dev/null + rm -rf "$ff.res" "$ff.err" "$ff.write" "$ff.bin" 2> /dev/null # Compile if [ "x$verbose" = "xtrue" ]; then echo "" - echo $NITC $OPT -o "$ff.bin" "$i" -I . -I alt -I ../lib/standard + echo $NITC --no-color $OPT -o "$ff.bin" "$i" "$includes" fi - $NITC $OPT -o "$ff.bin" "$i" -I . -I alt -I ../lib/standard 2> "$ff.cmp.err" > "$ff.compile.log" + $NITC --no-color $OPT -o "$ff.bin" "$i" $includes 2> "$ff.cmp.err" > "$ff.compile.log" ERR=$? if [ "x$verbose" = "xtrue" ]; then cat "$ff.compile.log" @@ -158,12 +206,12 @@ for ii in "$@"; do args="" if [ "x$verbose" = "xtrue" ]; then echo "" - echo "./$ff.bin" $args + echo "NIT_NO_STACK=1 ./$ff.bin" $args fi if [ -f "$f.inputs" ]; then - "./$ff.bin" $args < "$f.inputs" > "$ff.res" 2>"$ff.err" + NIT_NO_STACK=1 "./$ff.bin" $args < "$f.inputs" > "$ff.res" 2>"$ff.err" else - "./$ff.bin" $args > "$ff.res" 2>"$ff.err" + NIT_NO_STACK=1 "./$ff.bin" $args > "$ff.res" 2>"$ff.err" fi if [ "x$verbose" = "xtrue" ]; then cat "$ff.res" @@ -171,6 +219,8 @@ for ii in "$@"; do fi if [ -f "$ff.write" ]; then cat "$ff.write" >> "$ff.res" + elif [ -d "$ff.write" ]; then + ls -F $ff.write >> "$ff.res" fi if [ -s "$ff.err" ]; then cat "$ff.err" >> "$ff.res" @@ -180,20 +230,19 @@ for ii in "$@"; do if [ -f "$f.args" ]; then fargs=$f.args cptr=0 - cat $fargs | while read line; do ((cptr=cptr+1)) args=$line fff=$ff"_args"$cptr if [ "x$verbose" = "xtrue" ]; then echo "" - echo "./$ff.bin" $args + echo "NIT_NO_STACK=1 ./$ff.bin" $args fi echo -n "==> args #"$cptr " " if [ -f "$f.inputs" ]; then - "./$ff.bin" $args < "$f.inputs" > "$fff.res" 2>"$fff.err" + NIT_NO_STACK=1 "./$ff.bin" $args < "$f.inputs" > "$fff.res" 2>"$fff.err" else - sh -c "./$ff.bin ''$args > $fff.res 2>$fff.err" + sh -c "NIT_NO_STACK=1 ./$ff.bin ''$args > $fff.res 2>$fff.err" fi if [ "x$verbose" = "xtrue" ]; then cat "$fff.res" @@ -201,12 +250,14 @@ for ii in "$@"; do fi if [ -f "$fff.write" ]; then cat "$fff.write" >> "$fff.res" + elif [ -d "$fff.write" ]; then + ls -F $fff.write >> "$fff.res" fi if [ -s "$fff.err" ]; then cat "$fff.err" >> "$fff.res" fi process_result $fff - done + done < $fargs fi else echo -n "! " @@ -226,6 +277,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