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
31 echo "usage: $0 file.nit ..."
34 if [ -z
"$HTM" ]; then
36 elif [ ! -f
"$HTM" ]; then
37 echo "<html><body><table border=\"1\">" > $HTM
38 echo "<tr><td>Mode</td>" >> $HTM
40 f
=`echo $i | cut -f1 -d.`
41 echo -n
"<td><a href=\"$f.nit\">$f</a>" >> $HTM
42 if [ -r
"sav/$f.sav" ]; then
43 echo -n
" - <a href=\"sav/$f.sav\">sav</a>" >> $HTM
45 if [ -f
"$f.inputs" ]; then
46 echo -n
" - <a href=\"$f.inputs\">inputs</a>" >> $HTM
50 echo "<td>ok</td><td>fails</td></tr>" >> $HTM
55 echo "<tr><td>$MARK</td>" >> $HTM
58 for alt
in "" `sed -n 's/.*#\(alt[0-9]*\)#.*/\1/p' "$ii" | sort -u`; do
59 f
=`basename "$ii" .nit`
63 if [ "x$alt" != "x" ]; then
64 test -d alt || mkdir
-p alt
67 sed "s/#$alt#//g;/#!$alt#/d" "$ii" > "$i"
73 rm "$ff.res" "$ff.err" "$ff.write" 2> /dev
/null
76 $NITC $OPT -o
"$f.bin" "$i" -I .
-I alt
-I ..
/lib
/standard
2> "$ff.cmp.err" > "$ff.compile.log"
78 mv "$f.bin" "$ff.bin" 2> /dev
/null
79 egrep '^[A-Z0-9_]*$' "$ff.compile.log" > "$ff.res"
80 echo -n
"<td><a href=\"$ff.compile.log\">compil " >> $HTM
81 if [ "$ERR" != 0 ]; then
83 echo -n
"fail</a> - " >> $HTM
84 cp "$ff.cmp.err" "$ff.res"
87 echo -n
"ok</a> - " >> $HTM
89 if [ -f
"$f.args" ]; then
94 if [ -f
"$f.inputs" ]; then
95 "./$ff.bin" $args < "$f.inputs" > "$ff.res" 2>"$ff.err"
97 "./$ff.bin" $args > "$ff.res" 2>"$ff.err"
99 if [ -f
"$ff.write" ]; then
100 cat "$ff.write" >> "$ff.res"
101 echo -n
"<a href=\"$ff.err\">write</a> - " >> $HTM
103 if [ -s
"$ff.err" ]; then
104 cat "$ff.err" >> "$ff.res"
105 echo -n
"<a href=\"$ff.err\">err</a> - " >> $HTM
110 if [ -r
"sav/$ff.sav" ]; then
111 diff "$ff.res" "sav/$ff.sav" > "$ff.diff.log"
112 if [ "$?" == 0 ]; then
115 echo -n
"<a href=\"$ff.res\">res ok</a>" >> $HTM
117 echo "[======= fail $ff.res sav/$ff.sav =======]"
119 echo -n
"<strong style=\"background-color:red\"><a href=\"$ff.res\">res fail</a> - <a href=\"$ff.diff.log\">diff</a></strong>" >> $HTM
122 echo "[=== no sav ===] $ff.res"
123 echo -n
"<a href=\"$ff.res\">res</a>" >> $HTM
130 echo "ok: " `echo $ok | wc -w` "/" `echo $ok $nok $nos | wc -w`
131 echo "<td>" `echo $ok | wc -w` "</td><td>" `echo $nok | wc -w` "</td></tr>" >> $HTM
133 if [ -n
"$nok" ]; then
135 echo "There were errors !"
137 if [ -n
"$nos" ]; then