From ffa6d44834b364fca01b1cc215c1d39f50c67351 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 2 Oct 2021 17:54:11 +0000 Subject: [PATCH] test suite: add end_msg() --- test/include/common.py | 6 ++++++ test/scrambletest.py | 4 +--- test/tooltest.py | 3 +-- test/tooltest2.py | 3 +-- test/unit_tests.py | 7 ++----- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/test/include/common.py b/test/include/common.py index 3c79fdae..e8d58e22 100755 --- a/test/include/common.py +++ b/test/include/common.py @@ -192,6 +192,12 @@ def oqmsg_r(s): if not (opt.verbose or getattr(opt,'exact_output',None)): omsg_r(s) +def end_msg(t): + omsg(green( + 'All requested tests finished OK' + + ('' if g.test_suite_deterministic else f', elapsed time: {t//60:02d}:{t%60:02d}') + )) + def start_test_daemons(*network_ids,remove_datadir=False): if not opt.no_daemon_autostart: return test_daemons_ops(*network_ids,op='start',remove_datadir=remove_datadir) diff --git a/test/scrambletest.py b/test/scrambletest.py index 38f9bfac..217f6379 100755 --- a/test/scrambletest.py +++ b/test/scrambletest.py @@ -146,6 +146,4 @@ cmds = cmd_args or ('coin','pw') for cmd in cmds: {'coin': do_coin_tests, 'pw': do_passwd_tests }[cmd]() -t = int(time.time()) - start_time -m = 'All requested tests finished OK, elapsed time: {:02}:{:02}' -gmsg(m.format(t//60,t%60)) +end_msg(int(time.time()) - start_time) diff --git a/test/tooltest.py b/test/tooltest.py index 4ca03169..59ebcf69 100755 --- a/test/tooltest.py +++ b/test/tooltest.py @@ -464,5 +464,4 @@ try: except KeyboardInterrupt: die(1,green('\nExiting at user request')) -t = int(time.time()) - start_time -gmsg(f'All requested tests finished OK, elapsed time: {t//60:02}:{t%60:02}') +end_msg(int(time.time()) - start_time) diff --git a/test/tooltest2.py b/test/tooltest2.py index 1ea3963b..cdfa4e59 100755 --- a/test/tooltest2.py +++ b/test/tooltest2.py @@ -1057,5 +1057,4 @@ async def main(): run_session(main()) -t = int(time.time()) - start_time -gmsg(f'All requested tests finished OK, elapsed time: {t//60:02}:{t%60:02}') +end_msg(int(time.time()) - start_time) diff --git a/test/unit_tests.py b/test/unit_tests.py index 18136e22..d2ee517f 100755 --- a/test/unit_tests.py +++ b/test/unit_tests.py @@ -23,6 +23,7 @@ test/unit_tests.py: Unit tests for the MMGen suite import sys,os,time,importlib from include.tests_header import repo_root +from include.common import end_msg from mmgen.common import * opts_data = { @@ -53,10 +54,6 @@ cmd_args = opts.init(opts_data) file_pfx = 'nt_' if opt.node_tools else 'ut_' -def exit_msg(): - t = int(time.time()) - start_time - gmsg(f'All requested unit tests finished OK, elapsed time: {t//60:02}:{t%60:02}') - all_tests = sorted( [fn[3:-3] for fn in os.listdir(os.path.join(repo_root,'test','unit_tests_d')) if fn[:3] == file_pfx]) @@ -141,6 +138,6 @@ try: die(1,f'{test!r}: test not recognized') if test not in exclude: run_test(test,subtest=subtest) - exit_msg() + end_msg(int(time.time()) - start_time) except KeyboardInterrupt: die(1,green('\nExiting at user request'))