aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2020-11-19 09:10:58 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2020-12-27 13:55:30 +0100
commit9d29bd022502d1f3a0bc64e40da84fc61a5a3843 (patch)
treeec6ab1cb28970cb16dc960bec3711dd76df072d1
parent3f8c9012459d4923cc3167bf4859e2f8a6794f96 (diff)
downloadmeson-9d29bd022502d1f3a0bc64e40da84fc61a5a3843.zip
meson-9d29bd022502d1f3a0bc64e40da84fc61a5a3843.tar.gz
meson-9d29bd022502d1f3a0bc64e40da84fc61a5a3843.tar.bz2
mtest: move test_count and name_max_len to TestHarness class
Avoid passing them around as parameters; this will be useful when logging is moved out of TestHarness, because individual loggers will call back into TestHarness to do common formatting chores. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--mesonbuild/mtest.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py
index c754309..4685b7d 100644
--- a/mesonbuild/mtest.py
+++ b/mesonbuild/mtest.py
@@ -870,13 +870,15 @@ class TestHarness:
self.success_count = 0
self.skip_count = 0
self.timeout_count = 0
+ self.test_count = 0
+ self.name_max_len = 0
self.is_run = False
- self.tests = None
self.results = [] # type: T.List[TestRun]
self.logfilename = None # type: T.Optional[str]
self.logfile = None # type: T.Optional[T.TextIO]
self.jsonlogfile = None # type: T.Optional[T.TextIO]
self.junit = None # type: T.Optional[JunitBuilder]
+
if self.options.benchmark:
self.tests = load_benchmarks(options.wd)
else:
@@ -958,16 +960,15 @@ class TestHarness:
else:
sys.exit('Unknown test result encountered: {}'.format(result.res))
- def print_stats(self, test_count: int, name_max_len: int,
- result: TestRun) -> None:
+ def print_stats(self, result: TestRun) -> None:
ok_statuses = (TestResult.OK, TestResult.EXPECTEDFAIL)
bad_statuses = (TestResult.FAIL, TestResult.TIMEOUT, TestResult.INTERRUPT,
TestResult.UNEXPECTEDPASS, TestResult.ERROR)
result_str = '{num:{numlen}}/{testcount} {name:{name_max_len}} {res:{reslen}} {dur:.2f}s'.format(
- numlen=len(str(test_count)),
+ numlen=len(str(self.test_count)),
num=result.num,
- testcount=test_count,
- name_max_len=name_max_len,
+ testcount=self.test_count,
+ name_max_len=self.name_max_len,
name=result.name,
reslen=TestResult.maxlen(),
res=result.res.value,
@@ -1051,6 +1052,8 @@ class TestHarness:
# wrapper script.
sys.exit(125)
+ self.test_count = len(tests)
+ self.name_max_len = max([len(self.get_pretty_suite(test)) for test in tests])
self.run_tests(tests)
return self.total_failure_count()
@@ -1203,8 +1206,6 @@ class TestHarness:
semaphore = asyncio.Semaphore(self.options.num_processes)
futures = deque() # type: T.Deque[asyncio.Future]
running_tests = dict() # type: T.Dict[asyncio.Future, str]
- test_count = len(tests)
- name_max_len = max([len(self.get_pretty_suite(test)) for test in tests])
self.open_log_files()
startdir = os.getcwd()
if self.options.wd:
@@ -1218,7 +1219,7 @@ class TestHarness:
return
res = await test.run()
self.process_test_result(res)
- self.print_stats(test_count, name_max_len, res)
+ self.print_stats(res)
def test_done(f: asyncio.Future) -> None:
if not f.cancelled():