Browse Source

test suite: add end_msg()

The MMGen Project 3 years ago
parent
commit
ffa6d44834
5 changed files with 11 additions and 12 deletions
  1. 6 0
      test/include/common.py
  2. 1 3
      test/scrambletest.py
  3. 1 2
      test/tooltest.py
  4. 1 2
      test/tooltest2.py
  5. 2 5
      test/unit_tests.py

+ 6 - 0
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)

+ 1 - 3
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)

+ 1 - 2
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)

+ 1 - 2
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)

+ 2 - 5
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'))