From a093075fd56738b722aa2ec711e9f38043241dde Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Wed, 29 Sep 2021 21:17:56 +0000 Subject: [PATCH] test.py: add --no-timings option --- test/test-release.sh | 4 +++- test/test.py | 13 ++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/test/test-release.sh b/test/test-release.sh index 60efc7c5..cb77142e 100755 --- a/test/test-release.sh +++ b/test/test-release.sh @@ -44,7 +44,7 @@ quick_tests='dep misc obj color unit hash ref altref alts xmr eth autosign btc b qskip_tests='btc_tn bch bch_rt ltc ltc_rt' PROGNAME=$(basename $0) -while getopts hAbCfFi:I:lOptvV OPT +while getopts hAbCfFi:I:lNOptvV OPT do case "$OPT" in h) printf " %-16s Test MMGen release\n" "${PROGNAME}:" @@ -59,6 +59,7 @@ do echo " must be supplied as a parameter" echo " '-I' Like '-i', but install the package without running the tests" echo " '-l' List the test name symbols" + echo " '-N' Pass the --no-timings switch to test/test.py" echo " '-O' Use pexpect.spawn rather than popen_spawn for applicable tests" echo " '-p' Pause between tests" echo " '-t' Print the tests without running them" @@ -126,6 +127,7 @@ do echo -e "'quick' test group:\n $quick_tests" echo -e "'qskip' test group:\n $qskip_tests" exit ;; + N) test_py+=" --no-timings" ;; O) test_py+=" --pexpect-spawn" ;; p) PAUSE=1 ;; t) LIST_CMDS=1 ;; diff --git a/test/test.py b/test/test.py index b047abcd..258ce388 100755 --- a/test/test.py +++ b/test/test.py @@ -107,6 +107,7 @@ opts_data = { -L, --list-cmd-groups Output a list of command groups with descriptions -g, --list-current-cmd-groups List command groups for current configuration -n, --names Display command names instead of descriptions +-N, --no-timings Suppress display of timing information -o, --log Log commands to file {lf} -O, --pexpect-spawn Use pexpect.spawn instead of popen_spawn (much slower, kut does real terminal emulation) @@ -685,15 +686,15 @@ class TestSuiteRunner(object): cmd_disp = ' '.join(qargs).replace('\\','/') # for mingw if not no_msg: - t_fmt = f'{time.time() - self.start_time:08.2f}' + t_pfx = '' if opt.no_timings else f'[{time.time() - self.start_time:08.2f}] ' if opt.verbose or opt.print_cmdline or opt.exact_output: clr1,clr2 = ((green,cyan),(nocolor,nocolor))[bool(opt.print_cmdline)] - omsg(green(f'[{t_fmt}] Testing: {desc}')) + omsg(green(f'{t_pfx}Testing: {desc}')) if not msg_only: s = repr(cmd_disp) if g.platform == 'win' else cmd_disp omsg(clr1('Executing: ') + clr2(s)) else: - omsg_r(f'[{t_fmt}] Testing {desc}: ') + omsg_r(f'{t_pfx}Testing {desc}: ') if msg_only: return @@ -712,8 +713,10 @@ class TestSuiteRunner(object): def end_msg(self): t = int(time.time() - self.start_time) - m = '{} test{} performed. Elapsed time: {:02d}:{:02d}\n' - sys.stderr.write(green(m.format(self.cmd_total,suf(self.cmd_total),t//60,t%60))) + sys.stderr.write(green( + f'{self.cmd_total} test{suf(self.cmd_total)} performed.' + + ('' if opt.no_timings else f' Elapsed time: {t//60:02d}:{t%60:02d}\n') + )) def init_group(self,gname,cmd=None,quiet=False,do_clean=True):