2 # This file is part of NIT ( http://www.nitlanguage.org ).
4 # Copyright 2009 Jean-Sebastien Gelinas <calestar@gmail.com>
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.
28 recent
=`ls -t ../src/nitc ../src/nitc_[0-9] ../bin/nitc ../c_src/nitc 2>/dev/null | head -1`
29 if [[ "x$recent" == "x" ]]; then
30 echo 'Could not find nitc, aborting'
33 echo 'Using nitc from: '$recent
37 # The default nitc compiler
38 [ -z
"$NITC" ] && find_nitc
48 # Process each files given as arguments
51 echo "File '$ii' does not exist."
55 # Prepare the includes
57 if [ "x$tmp" = "x$ii" ]; then
58 oincludes
="-I . -I ../lib/standard -I ../lib/standard/collection"
63 # Process each alternatives in the current file
64 for alt
in "$ii" `./alterner.pl --start '#' "$ii"`; do
65 f
=`basename "$ii" .nit`
69 includes
="$oincludes -I alt"
73 # Clean-up before compile and tests
74 rm -rf .nit_compile
2> /dev
/null
77 # The point of ICode testing is to validate analysis/optimizations
78 # Force '--global' option !
79 $NITC $OPT --global
--output
-format icode
"$i" $includes 2> "out/$ff.cmp.err" > "out/$ff.compile.log"
81 if [ "$ERR" != 0 ]; then
83 echo "! [======= fail: Compilation error =======]"
86 TEST_FILE
=$d/$ff.tests
87 if [ ! -f
$TEST_FILE ]; then
88 # Could not find the .tests file associated with this test
89 echo ". [======= fail: Cannot open test file =======]"
96 # Each lines in the .tests file describe a test to execute on the generated
97 # ICode. The file has 4 parameters:
101 # - Arguments for the test
102 # We use the class to open the right icode file.
103 # We use a special method named "no-file" to ensure that the class file does not exist.
104 # If the method is different from "no-file" then we search in said method for the expression given
105 # with the _arguments_ field. This expression will be evaluated as a awk regexp.
106 # We have two types of tests :
107 # - has : the given argument must be found for the test to be successful
108 # - no : the given argument must NOT be found for the test to be successful
110 while IFS
=, read CLASS METHOD TYPE ATTR
112 ICODE_FILE
=$d/.nit_compile
/$CLASS.icode
114 echo -n
'==> Test #'$cptr' ...... '
116 if [ -f
$ICODE_FILE ]; then
117 # Check if the file should exist
118 if [ "x$METHOD" = "xno-file" ]; then
119 # this is not normal, the file should not exist
125 # Use awk to get the method in the file and search in it for the argument
144 if [ $awkstatus -ne
0 ] ; then
146 if [ "x$TYPE" = "xno" ]; then
147 # Should not have beed found
150 elif [ "x$TYPE" = "xhas" ]; then
151 # Should have been found
155 echo "Test file format error !!!"
160 if [ "x$TYPE" = "xno" ]; then
161 # Should not have beed found
164 elif [ "x$TYPE" = "xhas" ]; then
165 # Should have been found
169 echo "Test file format error !!!"
174 # The class file was not found
175 if [ "x$METHOD" = "xno-file" ]; then
180 # Should have been found
190 echo "ok: " `echo $ok | wc -w` "/" `echo $ok $nok $nos | wc -w`
192 if [ -n
"$nok" ]; then
194 echo "There were $(echo $nok | wc -w) errors !"
196 if [ -n
"$nos" ]; then
200 if [ -n
"$nok" ]; then