Changeset: fa2c9ff495f5 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/fa2c9ff495f5
Modified Files:
testing/Mtest.py.in
Branch: Dec2025
Log Message:
Some cleanup to Mtest.
Removed double verbose flag; when verbose, only print single OK/ERROR
per test; some more code cleanup.
diffs (truncated from 547 to 300 lines):
diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -32,7 +32,7 @@ import concurrent.futures
MonetDB_VERSION = '@MONETDB_VERSION@'.split('.')
procdebug = False
-verbosity = 0
+verbose = False
approve = False
replace = False
stop_crash = False
@@ -64,7 +64,7 @@ fbre = re.compile(r' (?P<bats>\d+) free
ubre = re.compile(r' (?P<bats>\d+) in use')
tbre = re.compile(r'^(?P<bats>\d+) bats total')
-# collect errors if verbosity == 0
+# collect errors if not verbose
errors = []
@@ -966,10 +966,7 @@ def AddSubToHtmlIndex(env, TSTDIR, diff)
def SkipTest(env, TST, EXT, REASON, length, TSTDIR, TSTTRGDIR, TSTSRCDIR):
- TEXT = 'Skipping test %s%s %s' % (TST, EXT, REASON)
- if verbosity > 1:
- Warn(TEXT)
- elif verbosity == 1:
+ if verbose:
if REASON.startswith('as '):
REASON = REASON[3:]
if REASON.endswith('.'):
@@ -984,30 +981,30 @@ def SkipTest(env, TST, EXT, REASON, leng
s = '%s...%s' % (TST[:l//2 - 2], TST[-(l//2 - 1):])
else:
s = '%-*s' % (length, TST)
- print('%s%s skipped (%s)' % (prompt(), s, REASON))
+ print(f'{prompt()}{s} skipped ({REASON})')
if testweb or not produce_html:
return None
- with openutf8(os.path.join(TSTTRGDIR, '.%s.SKIPPED.html' % TST), 'w') as f:
+ with openutf8(os.path.join(TSTTRGDIR, f'.{TST}.SKIPPED.html'), 'w') as f:
Element('html', {},
Element('body', {},
Element('p', {},
- Text('%s Warning: %s' % (THISFILE,
TEXT))))).write(f, newline=True)
- target = '%s_%s_body' % (DISTVER, TSTDIR)
+ Text(f'Skipping test {TST}{EXT}
{REASON}')))).write(f, newline=True)
+ target = f'{DISTVER}_{TSTDIR}_body'
td = Element('td', {'class': 'header'},
- Element('a', {'href': '.%s.src.index.html' % TST,
+ Element('a', {'href': f'.{TST}.src.index.html',
'target': target,
'class': 'black'},
Text(TST)),
Element('br'),
- Element('a', {'href': '.%s.SKIPPED.html' % TST,
+ Element('a', {'href': f'.{TST}.SKIPPED.html',
'target': target},
Text('(skipped)')))
if f'_{TSTDIR}_BODY_' not in env or \
not env[f'_{TSTDIR}_BODY_'][0] or \
not env[f'_{TSTDIR}_BODY_'][1]:
- env[f'_{TSTDIR}_BODY_'] = ['.%s.SKIPPED.html' % TST, F_SKIP]
+ env[f'_{TSTDIR}_BODY_'] = [f'.{TST}.SKIPPED.html', F_SKIP]
CreateSrcIndex(env, TST, EXT, TSTDIR, TSTTRGDIR, TSTSRCDIR)
return td
@@ -1185,7 +1182,7 @@ def PerformDir(env, testdir, testlist, t
body_good = []
body_bad = []
oktests = []
- if verbosity == 1:
+ if verbose:
print('\nRunning in %s' % TSTDIR)
alllinks = []
pSrvr = None
@@ -1262,7 +1259,7 @@ def PerformDir(env, testdir, testlist, t
environ['MAPIPORT'] = pSrvr.port
if pSrvr.usock is not None:
environ['MAPIUSOCK'] = pSrvr.usock
- SetExecEnv(env['exe'], pSrvr.port, verbosity > 1, environ)
+ SetExecEnv(env['exe'], pSrvr.port, environ)
if global_timeout and start_time + global_timeout <
time.time():
if not testweb:
print('\nGlobal testing timeout reached\n')
@@ -1372,7 +1369,7 @@ def PerformDir(env, testdir, testlist, t
CreateHtmlIndex(env, TSTDIR, TSTTRGDIR, ssout, sserr, *body)
elem = AddSubToHtmlIndex(env, TSTDIR, max(FdOut, FdErr, ssout,
sserr))
if ssout == F_ERROR or sserr == F_ERROR:
- if verbosity == 0:
+ if not verbose:
errors.append(('ERROR', f'in directory {TSTDIR}'))
else:
prred('ERROR')
@@ -1840,12 +1837,7 @@ def RunTest(env, TST, COND, oktests, len
reason = "test missing:
'"+os.path.join(TSTSRCDIR,TST)+".(exe|com|bat|cmd|py|sql)`"
else:
reason = "test missing:
'"+os.path.join(TSTSRCDIR,TST)+"[.py|.sql|.rb]`"
- if verbosity > 1:
- print('%s%s ' %
- (prompt(), os.path.join(TSTDIR, TST + EXT)), end='')
- prred('TEST MISSING')
- print()
- elif verbosity == 1:
+ if verbose:
if ttywidth > 0 and length + 10 + 21 >= ttywidth:
# 10 - length of prompt()
# 21 - length of time plus result
@@ -2140,7 +2132,7 @@ Password = {passwd or "monetdb"}-Wrong
TSTSRCDIR, environ)
t1 = time.time()
TX = t1 - t0
- if verbosity > 0:
+ if verbose:
print(f' {TX:7.3f}s ', end='')
if odbc:
@@ -2186,37 +2178,24 @@ Password = {passwd or "monetdb"}-Wrong
sockerr = F_OK
if tres == 'socket':
- if verbosity == 0 and not produce_html:
+ if not verbose and not produce_html:
errors.append(('SOCKET', TST))
- elif verbosity > 1:
- print('(Socket!) ', end='')
if tres == 'timeout':
- if verbosity == 0 and not produce_html:
+ if not verbose and not produce_html:
errors.append(('TIMEOUT', TST))
- elif verbosity > 1:
- print('(Timeout!) ', end='')
if tres == 'recursion':
- if verbosity == 0 and not produce_html:
+ if not verbose and not produce_html:
errors.append(('RECURSION', TST))
- elif verbosity > 1:
- print('(Recursion!) ', end='')
if tres == 'segfault':
- if verbosity == 0 and not produce_html:
+ if not verbose and not produce_html:
errors.append(('CRASHED', TST))
- elif verbosity > 1:
- print('(Crashed!) ', end='')
if tres == 'signal':
- if verbosity == 0 and not produce_html:
+ if not verbose and not produce_html:
errors.append(('SIGNALED', TST))
- elif verbosity > 1:
- print('(Signaled!) ', end='')
-
- if verbosity > 1:
- print()
try:
print('', end='', flush=True)
@@ -2296,7 +2275,7 @@ Password = {passwd or "monetdb"}-Wrong
else:
diff_html.write('<!--NoDiffs-->\n')
- if verbosity == 0 and (FailedOut > F_WARN or FailedErr > F_WARN):
+ if not verbose and (FailedOut > F_WARN or FailedErr > F_WARN):
errors.append(({'socket':'SOCKET',
'timeout':'TIMEOUT',
'recursion':'RECURSION',
@@ -2304,7 +2283,7 @@ Password = {passwd or "monetdb"}-Wrong
'abort':'ABORTED',
'signal':'SIGNALED'}.get(tres, 'ERROR'),
os.path.join(TSTDIR, TSTSUFF, TST + EXT)))
- elif verbosity == 1:
+ elif verbose:
if tres == 'socket':
prpurple('SOCKET')
elif tres == 'timeout':
@@ -2317,20 +2296,12 @@ Password = {passwd or "monetdb"}-Wrong
prpurple('ABORTED')
elif tres == 'signal':
prpurple('SIGNALED')
+ elif FailedOut == F_OK and FailedErr == F_OK:
+ prgreen('OK')
+ elif FailedOut <= F_WARN and FailedErr <= F_WARN:
+ prgreen('minor')
else:
- if FailedOut == F_OK:
- prgreen('OK ')
- elif FailedOut == F_WARN:
- prgreen('minor')
- else:
- prred('ERROR')
- print(' ', end='')
- if FailedErr == F_OK:
- prgreen('OK')
- elif FailedErr == F_WARN:
- prgreen('minor')
- else:
- prred('ERROR')
+ prred('ERROR')
print()
elif FailedOut > F_WARN or FailedErr > F_WARN:
print()
@@ -3060,12 +3031,8 @@ def progress(count, total, test, spaces=
def DoIt(env, SERVER, CALL, TST, EXT, TestOutFile, TestErrFile, TIMEOUT, ME,
length, nomito, threads, user, passwd, COND, PSRVR, total_tests, options,
TSTDB, TSTDIR, TSTTRGDIR, TSTSRCDIR, environ):
ATJOB2 = ''
print(file=sys.stderr, end='', flush=True)
- if verbosity == 0:
+ if not verbose:
progress(test_progress, total_tests, os.path.join(TSTDIR, TST + EXT))
- elif verbosity > 1:
- print('%s%s (<=%d) ...' %
- (prompt(), os.path.join(TSTDIR, TST + EXT),
- TIMEOUT), end='')
else:
if ttywidth > 0 and length + 10 + 21 >= ttywidth:
# 10 - length of prompt()
@@ -3145,7 +3112,7 @@ def DoIt(env, SERVER, CALL, TST, EXT, Te
print('\nFailed to start server.\n')
return 'serverfail'
environ['MAPIPORT'] = pSrvr.port
- SetExecEnv(exe,pSrvr.port,verbosity > 1, environ)
+ SetExecEnv(exe, pSrvr.port, environ)
else:
PSRVR.start(TIMEOUT)
else:
@@ -3442,32 +3409,18 @@ def CheckClassPath():
CONDITIONALS[C] = True
if cp:
os.environ['CLASSPATH'] = cp
- if verbosity > 1:
- miss = ''
- for j in ['monetdbjdbc.jar', 'jdbcclient.jar', 'jdbctests.jar']:
- C = 'HAVE_%s' % j.upper().replace('.','_')
- if not CONDITIONALS.get(C):
- miss += ' "%s"' % j
- if miss:
- Warn('Could not find%s in\nCLASSPATH="%s"' % (miss,cpx))
if CONDITIONALS.get('HAVE_MONETDBJDBC_JAR') and \
CONDITIONALS.get('HAVE_JDBCTESTS_JAR'):
CONDITIONALS['HAVE_JDBCTESTS'] = True
-def SetExecEnv(exe,port,verbose,environ):
- if verbose:
- print(file=sys.stderr, end='', flush=True)
+def SetExecEnv(exe, port, environ):
for v in exe.keys():
if v == 'mserver5':
V = 'MSERVER'
else:
V = v.upper()
environ[V] = ' '.join(exe[v]).replace('${PORT}', port)
- if verbose:
- print('%s = %s' % (V, environ[V]))
- if verbose:
- print(end='', flush=True)
def DummyTlsTester():
@@ -3507,7 +3460,6 @@ def StartTlsTester():
THISFILE = os.path.basename(sys.argv[0])
if THISFILE == 'Mz.py':
produce_html = False
- verbosity == 0
THISPATH = os.path.realpath(os.path.dirname(sys.argv[0]))
TSTDBG = '2'
TSTTHREADS = '0'
@@ -3741,7 +3693,7 @@ def main(argv):
parser.add_argument('--revision', action='store', dest='revision',
metavar='<hgid>', help='use given revision as the HG short hash')
parser.add_argument('--TSTSRCBASE', action='store', dest='TSTSRCBASE',
metavar='<path>', help='default: "%s"' % '@QXSOURCE@')
parser.add_argument('--TSTTRGBASE', action='store', dest='TSTTRGBASE',
metavar='<path>', help='default: "%s"' % '@QXprefix@')
- parser.add_argument('--verbose', '-v', action='count', dest='verbosity',
default=0, help='more verbose test output (can be used twice)')
+ parser.add_argument('--verbose', '-v', action='store_true',
dest='verbose', default=0, help='more verbose test output')
parser.add_argument('--procdebug', action='store_true', dest='procdebug',
help='process debugging (Mtest developers only)')
parser.add_argument('--urlprefix', action='store', help='URL prefix to the
MonetDB Mercurial repository')
@@ -3801,10 +3753,8 @@ def main(argv):
if opts.parallel < 1:
opts.parallel = 1
recursive = opts.recursive
- global testweb
- testweb = False
- global verbosity
- verbosity = opts.verbosity
+ global verbose
+ verbose = opts.verbose
global procdebug
procdebug = opts.procdebug
global approve
@@ -3822,9 +3772,8 @@ def main(argv):
skip_timeout = opts.skip_test_with_timeout
produce_html = opts.produce_html
addreqs = False
+ global testweb
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]