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 # The default nitc compiler
21 [ -z
"$NITC" ] && NITC
=..
/bin
/nitc
27 Usage
: $e [options
] modulenames
28 -o option Pass option to nitc
34 while [ $stop = false
]; do
36 -o
) OPT
="$OPT $2"; shift; shift;;
42 # Mark to distinguish files among tests
45 # File where error tests are outputed
46 # Old ERRLIST is backuped
47 ERRLIST
=${ERRLIST:-errlist}
54 # Backup and initiate new ERRLIST
55 if [ "x$ERRLIST" = "x" ]; then
58 if [ -x
"$ERRLIST" ]; then
59 mv "$ERRLIST" "${ERRLIST}.bak"
68 for alt
in "" `sed -n 's/.*#!*\(alt[0-9]*\)#.*/\1/p' "$ii" | sort -u`; do
69 f
=`basename "$ii" .nit`
73 if [ "x$alt" != "x" ]; then
74 test -d alt || mkdir
-p alt
77 sed "s/#$alt#//g;/#!$alt#/d" "$ii" > "$i"
83 rm "$ff.res" "$ff.err" "$ff.write" 2> /dev
/null
86 $NITC $OPT -o
"$f.bin" "$i" -I .
-I alt
-I ..
/lib
/standard
2> "$ff.cmp.err" > "$ff.compile.log"
88 mv "$f.bin" "$ff.bin" 2> /dev
/null
89 egrep '^[A-Z0-9_]*$' "$ff.compile.log" > "$ff.res"
90 if [ "$ERR" != 0 ]; then
92 cp "$ff.cmp.err" "$ff.res"
96 if [ -f
"$f.args" ]; then
101 if [ -f
"$f.inputs" ]; then
102 "./$ff.bin" $args < "$f.inputs" > "$ff.res" 2>"$ff.err"
104 "./$ff.bin" $args > "$ff.res" 2>"$ff.err"
106 if [ -f
"$ff.write" ]; then
107 cat "$ff.write" >> "$ff.res"
109 if [ -s
"$ff.err" ]; then
110 cat "$ff.err" >> "$ff.res"
115 if [ -r
"sav/$ff.sav" ]; then
116 diff -u
"$ff.res" "sav/$ff.sav" > "$ff.diff.log"
117 if [ "$?" == 0 ]; then
121 echo "[======= fail $ff.res sav/$ff.sav =======]"
123 echo "$ii" >> "$ERRLIST"
126 echo "[=== no sav ===] $ff.res"
132 echo "ok: " `echo $ok | wc -w` "/" `echo $ok $nok $nos | wc -w`
134 if [ -n
"$nok" ]; then
136 echo "There were errors ! (see file $ERRLIST)"
138 if [ -n
"$nos" ]; then
142 if [ -n
"$nok" ]; then