2 # This file is part of NIT ( http://www.nitlanguage.org ).
4 # Copyright 2004-2008 Jean Privat <jean@pryen.org>
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
18 # This shell script compile, run and verify NIT program files
20 # Ruby binary (none if you want to let the program to decide)
22 [ -z
"$NITC" ] && NITC
=..
/bin
/nitc
24 # Options to use with the ruby compiler
27 # Mark to distinguish files among tests
30 # File where error tests are outputed
31 # Old ERRLIST is backuped
32 ERRLIST
=${ERRLIST:-errlist}
35 echo "usage: $0 file.nit ..."
38 # Backup and initiate new ERRLIST
39 if [ "x$ERRLIST" = "x" ]; then
42 if [ -x
"$ERRLIST" ]; then
43 mv "$ERRLIST" "${ERRLIST}.bak"
52 for alt
in "" `sed -n 's/.*#!*\(alt[0-9]*\)#.*/\1/p' "$ii" | sort -u`; do
53 f
=`basename "$ii" .nit`
57 if [ "x$alt" != "x" ]; then
58 test -d alt || mkdir
-p alt
61 sed "s/#$alt#//g;/#!$alt#/d" "$ii" > "$i"
67 rm "$ff.res" "$ff.err" "$ff.write" 2> /dev
/null
70 $NITC $OPT -o
"$f.bin" "$i" -I .
-I alt
-I ..
/lib
/standard
2> "$ff.cmp.err" > "$ff.compile.log"
72 mv "$f.bin" "$ff.bin" 2> /dev
/null
73 egrep '^[A-Z0-9_]*$' "$ff.compile.log" > "$ff.res"
74 if [ "$ERR" != 0 ]; then
76 cp "$ff.cmp.err" "$ff.res"
80 if [ -f
"$f.args" ]; then
85 if [ -f
"$f.inputs" ]; then
86 "./$ff.bin" $args < "$f.inputs" > "$ff.res" 2>"$ff.err"
88 "./$ff.bin" $args > "$ff.res" 2>"$ff.err"
90 if [ -f
"$ff.write" ]; then
91 cat "$ff.write" >> "$ff.res"
93 if [ -s
"$ff.err" ]; then
94 cat "$ff.err" >> "$ff.res"
99 if [ -r
"sav/$ff.sav" ]; then
100 diff -u
"$ff.res" "sav/$ff.sav" > "$ff.diff.log"
101 if [ "$?" == 0 ]; then
105 echo "[======= fail $ff.res sav/$ff.sav =======]"
107 echo "$ii" >> "$ERRLIST"
110 echo "[=== no sav ===] $ff.res"
116 echo "ok: " `echo $ok | wc -w` "/" `echo $ok $nok $nos | wc -w`
118 if [ -n
"$nok" ]; then
120 echo "There were errors ! (see file $ERRLIST)"
122 if [ -n
"$nos" ]; then
126 if [ -n
"$nok" ]; then