From: Jean Privat Date: Thu, 2 Jun 2016 21:44:44 +0000 (-0400) Subject: nitunit: keep the status bar at the end line and show progress X-Git-Url: http://nitlanguage.org nitunit: keep the status bar at the end line and show progress Signed-off-by: Jean Privat --- diff --git a/src/testing/testing_base.nit b/src/testing/testing_base.nit index cb5db15..f814edc 100644 --- a/src/testing/testing_base.nit +++ b/src/testing/testing_base.nit @@ -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`. diff --git a/src/testing/testing_doc.nit b/src/testing/testing_doc.nit index 872bff2..936f6dc 100644 --- a/src/testing/testing_doc.nit +++ b/src/testing/testing_doc.nit @@ -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 diff --git a/src/testing/testing_suite.nit b/src/testing/testing_suite.nit index 9ea3a8e..89f58f9 100644 --- a/src/testing/testing_suite.nit +++ b/src/testing/testing_suite.nit @@ -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.