nitunit: keep the status bar at the end line and show progress
authorJean Privat <jean@pryen.org>
Thu, 2 Jun 2016 21:44:44 +0000 (17:44 -0400)
committerJean Privat <jean@pryen.org>
Thu, 2 Jun 2016 21:58:35 +0000 (17:58 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/testing/testing_base.nit
src/testing/testing_doc.nit
src/testing/testing_suite.nit

index cb5db15..f814edc 100644 (file)
@@ -136,6 +136,12 @@ ulimit -t {{{ulimit_usertime}}} 2> /dev/null
                return not opt_no_color.value and opt_verbose.value <= 0
        end
 
+       # Clear the line if `has_status` (no-op else)
+       fun clear_status
+       do
+               if has_status then printn "\r\x1B[K"
+       end
+
        # Shoe the full description of the test-case.
        #
        # The output honors `--no-color`.
index 872bff2..936f6dc 100644 (file)
@@ -86,6 +86,8 @@ class NitUnitExecutor
        fun mark_done(du: DocUnit)
        do
                du.is_done = true
+               toolcontext.clear_status
+               toolcontext.show_unit(du)
                show_status
        end
 
@@ -131,10 +133,6 @@ class NitUnitExecutor
                print ""
 
                for du in docunits do
-                       toolcontext.show_unit(du)
-               end
-
-               for du in docunits do
                        testsuite.add du.to_xml
                end
        end
index 9ea3a8e..89f58f9 100644 (file)
@@ -150,17 +150,16 @@ class TestSuite
                if not before_module == null then before_module.run
                for case in test_cases do
                        case.run
+                       toolcontext.clear_status
+                       toolcontext.show_unit(case)
                        show_status
                end
 
-               show_status
-               print ""
-
                var after_module = self.after_module
                if not after_module == null then after_module.run
-               for case in test_cases do
-                       toolcontext.show_unit(case)
-               end
+
+               show_status
+               print ""
        end
 
        # Write the test unit for `self` in a nit compilable file.