+
+ # Generated test file name.
+ fun test_file: String do
+ return toolcontext.test_dir / "gen_{mmodule.name.escape_to_c}"
+ end
+
+ # Compile all `test_cases` cases in one file.
+ fun compile do
+ # find nitc
+ var nit_dir = toolcontext.nit_dir
+ var nitc = nit_dir/"bin/nitc"
+ if not nitc.file_exists then
+ toolcontext.error(null, "Error: cannot find nitc. Set envvar NIT_DIR.")
+ toolcontext.check_errors
+ end
+ # compile test suite
+ var file = test_file
+ var include_dir = mmodule.location.file.filename.dirname
+ var cmd = "{nitc} --no-color '{file}.nit' -I {include_dir} -o '{file}.bin' > '{file}.out' 2>&1 </dev/null"
+ var res = sys.system(cmd)
+ var f = new FileReader.open("{file}.out")
+ var msg = f.read_all
+ f.close
+ # set test case result
+ var loc = mmodule.location
+ if res != 0 then
+ failure = msg
+ toolcontext.warning(loc, "failure", "FAILURE: {mmodule.name} (in file {file}.nit): {msg}")
+ toolcontext.modelbuilder.failed_tests += 1
+ end
+ toolcontext.check_errors
+ end
+
+ # Error occured during test-suite compilation.
+ var failure: nullable String = null