From 1ead5df1b3279560de525476d7c756c43afc6759 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Fri, 10 Jun 2016 21:45:27 -0400 Subject: [PATCH] nitunit: add time information Signed-off-by: Jean Privat --- src/testing/testing_base.nit | 4 ++++ src/testing/testing_doc.nit | 5 +++++ src/testing/testing_suite.nit | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/src/testing/testing_base.nit b/src/testing/testing_base.nit index 36ce1f9..a6acc79 100644 --- a/src/testing/testing_base.nit +++ b/src/testing/testing_base.nit @@ -201,6 +201,9 @@ abstract class UnitTest # Additional noteworthy information when a test success. var info: nullable String = null + # Time for the execution, in seconds + var real_time: Float = 0.0 is writable + # A colorful `[OK]` or `[KO]`. fun status_tag(color: nullable Bool): String do color = color or else true @@ -252,6 +255,7 @@ abstract class UnitTest var tc = new HTMLTag("testcase") tc.attr("classname", xml_classname) tc.attr("name", xml_name) + tc.attr("time", real_time.to_s) var error = self.error if error != null then if was_exec then diff --git a/src/testing/testing_doc.nit b/src/testing/testing_doc.nit index 75e0830..1cdd10a 100644 --- a/src/testing/testing_doc.nit +++ b/src/testing/testing_doc.nit @@ -19,6 +19,7 @@ private import parser_util import testing_base import markdown import html +import realtime # Extractor, Executor and Reporter for the tests in a module class NitUnitExecutor @@ -194,7 +195,9 @@ class NitUnitExecutor var file = du.test_file.as(not null) var i = du.test_arg.as(not null) toolcontext.info("Execute doc-unit {du.full_name} in {file} {i}", 1) + var clock = new Clock var res2 = toolcontext.safe_exec("{file.to_program_name}.bin {i} >'{file}.out1' 2>&1 '{file}.out1' 2>&1 '{res_name}.out1' 2>&1