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
29 -v Verbose
(show tests steps
)
36 while [ $stop = false
]; do
38 -o
) OPT
="$OPT $2"; shift; shift;;
39 -v
) verbose
=true
; shift;;
45 # Mark to distinguish files among tests
48 # File where error tests are outputed
49 # Old ERRLIST is backuped
50 ERRLIST
=${ERRLIST:-errlist}
57 # Backup and initiate new ERRLIST
58 if [ "x$ERRLIST" = "x" ]; then
61 if [ -x
"$ERRLIST" ]; then
62 mv "$ERRLIST" "${ERRLIST}.bak"
71 for alt
in "" `sed -n 's/.*#!*\(alt[0-9]*\)#.*/\1/p' "$ii" | sort -u`; do
72 f
=`basename "$ii" .nit`
76 if [ "x$alt" != "x" ]; then
77 test -d alt || mkdir
-p alt
80 sed "s/#$alt#//g;/#!$alt#/d" "$ii" > "$i"
86 rm "$ff.res" "$ff.err" "$ff.write" 2> /dev
/null
89 if [ "x$verbose" = "xtrue" ]; then
91 echo $NITC $OPT -o
"$f.bin" "$i" -I .
-I alt
-I ..
/lib
/standard
93 $NITC $OPT -o
"$f.bin" "$i" -I .
-I alt
-I ..
/lib
/standard
2> "$ff.cmp.err" > "$ff.compile.log"
95 if [ "x$verbose" = "xtrue" ]; then
99 mv "$f.bin" "$ff.bin" 2> /dev
/null
100 egrep '^[A-Z0-9_]*$' "$ff.compile.log" > "$ff.res"
101 if [ "$ERR" != 0 ]; then
103 cp "$ff.cmp.err" "$ff.res"
107 if [ -f
"$f.args" ]; then
112 if [ "x$verbose" = "xtrue" ]; then
114 echo "./$ff.bin" $args
116 if [ -f
"$f.inputs" ]; then
117 "./$ff.bin" $args < "$f.inputs" > "$ff.res" 2>"$ff.err"
119 "./$ff.bin" $args > "$ff.res" 2>"$ff.err"
121 if [ "x$verbose" = "xtrue" ]; then
125 if [ -f
"$ff.write" ]; then
126 cat "$ff.write" >> "$ff.res"
128 if [ -s
"$ff.err" ]; then
129 cat "$ff.err" >> "$ff.res"
134 if [ -r
"sav/$ff.sav" ]; then
135 diff -u
"$ff.res" "sav/$ff.sav" > "$ff.diff.log"
136 if [ "$?" == 0 ]; then
140 echo "[======= fail $ff.res sav/$ff.sav =======]"
142 echo "$ii" >> "$ERRLIST"
145 echo "[=== no sav ===] $ff.res"
151 echo "ok: " `echo $ok | wc -w` "/" `echo $ok $nok $nos | wc -w`
153 if [ -n
"$nok" ]; then
155 echo "There were errors ! (see file $ERRLIST)"
157 if [ -n
"$nos" ]; then
161 if [ -n
"$nok" ]; then