# See the License for the specific language governing permissions and
# limitations under the License.
-# This shell script compile, run and verify NIT program files
+# This shell script compile, run and verify Nit program files
-# Ruby binary (none if you want to let the program to decide)
-#RUBY=
+# The default nitc compiler
[ -z "$NITC" ] && NITC=../bin/nitc
-# Options to use with the ruby compiler
-# OPT=
+usage()
+{
+ e=`basename "$0"`
+ cat<<END
+Usage: $e [options] modulenames
+-o option Pass option to nitc
+-v Verbose (show tests steps)
+-h This help
+END
+}
+
+verbose=false
+stop=false
+while [ $stop = false ]; do
+ case $1 in
+ -o) OPT="$OPT $2"; shift; shift;;
+ -v) verbose=true; shift;;
+ -h) usage; exit;;
+ *) stop=true
+ esac
+done
# Mark to distinguish files among tests
# MARK=
+# File where error tests are outputed
+# Old ERRLIST is backuped
+ERRLIST=${ERRLIST:-errlist}
+
if [ $# = 0 ]; then
- echo "usage: $0 file.nit ..."
+ usage;
+ exit
+fi
+
+# Backup and initiate new ERRLIST
+if [ "x$ERRLIST" = "x" ]; then
+ ERRLIST=/dev=null
+else
+ if [ -x "$ERRLIST" ]; then
+ mv "$ERRLIST" "${ERRLIST}.bak"
+ fi
+ > "$ERRLIST"
fi
ok=""
rm "$ff.res" "$ff.err" "$ff.write" 2> /dev/null
# Compile
+ if [ "x$verbose" = "xtrue" ]; then
+ echo ""
+ echo $NITC $OPT -o "$f.bin" "$i" -I . -I alt -I ../lib/standard
+ fi
$NITC $OPT -o "$f.bin" "$i" -I . -I alt -I ../lib/standard 2> "$ff.cmp.err" > "$ff.compile.log"
ERR=$?
+ if [ "x$verbose" = "xtrue" ]; then
+ cat "$ff.compile.log"
+ cat >&2 "$ff.cmp.err"
+ fi
mv "$f.bin" "$ff.bin" 2> /dev/null
egrep '^[A-Z0-9_]*$' "$ff.compile.log" > "$ff.res"
if [ "$ERR" != 0 ]; then
else
args=""
fi
+ if [ "x$verbose" = "xtrue" ]; then
+ echo ""
+ echo "./$ff.bin" $args
+ fi
if [ -f "$f.inputs" ]; then
"./$ff.bin" $args < "$f.inputs" > "$ff.res" 2>"$ff.err"
else
"./$ff.bin" $args > "$ff.res" 2>"$ff.err"
fi
+ if [ "x$verbose" = "xtrue" ]; then
+ cat "$ff.res"
+ cat >&2 "$ff.err"
+ fi
if [ -f "$ff.write" ]; then
cat "$ff.write" >> "$ff.res"
fi
else
echo "[======= fail $ff.res sav/$ff.sav =======]"
nok="$nok $ff"
+ echo "$ii" >> "$ERRLIST"
fi
else
echo "[=== no sav ===] $ff.res"
if [ -n "$nok" ]; then
echo "fail: $nok"
- echo "There were errors !"
+ echo "There were errors ! (see file $ERRLIST)"
fi
if [ -n "$nos" ]; then
echo "no sav: $nos"
fi
+
+if [ -n "$nok" ]; then
+ exit 1
+else
+ exit 0
+fi