if dir == null then return ".nitunit"
return dir
end
+
+ # Search the `nitc` compiler to use
+ #
+ # If not `nitc` is suitable, then prints an error and quit.
+ fun find_nitc: String
+ do
+ var nit_dir = nit_dir
+ var nitc = nit_dir/"bin/nitc"
+ if not nitc.file_exists then
+ fatal_error(null, "Error: cannot find nitc. Set envvar NIT_DIR.")
+ abort
+ end
+ return nitc
+ end
end
# Can terminate the program if the compiler is not found
private fun compile_unitfile(file: String): Int
do
- 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
+ var nitc = toolcontext.find_nitc
var opts = new Array[String]
if mmodule != null then
opts.add "-I {mmodule.filepath.dirname}"
# 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
+ var nitc = toolcontext.find_nitc
# compile test suite
var file = test_file
var module_file = mmodule.location.file