test suite: add end_msg()

This commit is contained in:
The MMGen Project 2021-10-02 17:54:11 +00:00
commit ffa6d44834
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
5 changed files with 11 additions and 12 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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'))