nitunit: set NIT_TESTING_PATH before running a test suite
[nit.git] / src / testing / testing_suite.nit
index 69478cd..e788067 100644 (file)
@@ -122,13 +122,14 @@ class TestSuite
        # Test to be executed after the whole test suite.
        var after_module: nullable TestCase = null
 
-       fun show_status
-       do
+       # Display test suite status in std-out.
+       fun show_status do
                toolcontext.show_unit_status("Test-suite of module " + mmodule.full_name, test_cases)
        end
 
        # Execute the test suite
        fun run do
+               set_env
                show_status
                if not toolcontext.test_dir.file_exists then
                        toolcontext.test_dir.mkdir
@@ -214,6 +215,13 @@ class TestSuite
                end
        end
 
+       # Set environment variables for test suite execution
+       fun set_env do
+               var loc = mmodule.location.file
+               if loc == null then return
+               toolcontext.set_testing_path(loc.filename)
+       end
+
        # Error occured during test-suite compilation.
        var failure: nullable String = null
 end
@@ -261,7 +269,7 @@ class TestCase
                var res_name = "{test_file}_{method_name.escape_to_c}"
                var clock = new Clock
                var res = toolcontext.safe_exec("{test_file}.bin {method_name} > '{res_name}.out1' 2>&1 </dev/null")
-               real_time = clock.total
+               if not toolcontext.opt_no_time.value then real_time = clock.total
 
                var raw_output = "{res_name}.out1".to_path.read_all
                self.raw_output = raw_output