nitunit: learn to use `nit_dir` instead of hardcoding the path of nitg
[nit.git] / src / nitunit.nit
index f4f9719..2833445 100644 (file)
@@ -93,7 +93,13 @@ class NitUnitExecutor
                end
                f.close
 
-               var cmd = "../bin/nitg --ignore-visibility --no-color '{file}' -I . >'{file}.out1' 2>&1 </dev/null -o '{file}.bin'"
+               var nit_dir = toolcontext.nit_dir
+               var nitg = "{nit_dir}/bin/nitg"
+               if nit_dir == null or not nitg.file_exists then
+                       toolcontext.error(null, "Cannot find nitg. Set envvar NIT_DIR.")
+                       toolcontext.check_errors
+               end
+               var cmd = "{nitg} --ignore-visibility --no-color '{file}' -I . >'{file}.out1' 2>&1 </dev/null -o '{file}.bin'"
                var res = sys.system(cmd)
                var res2 = 0
                if res == 0 then