Changeset: fcf1d72eaf82 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/fcf1d72eaf82
Modified Files:
testing/Mtest.py.in
testing/helpers.py
testing/process.py
Branch: Mar2025
Log Message:
Cleanup, mostly dead code removal for test types we don't and won't have.
diffs (truncated from 554 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
@@ -13,12 +13,12 @@
import os
import sys
import shutil
+import shlex
import platform
import re
import secrets
import time
import socket
-import string # for whitespace
import struct
import signal
import fnmatch
@@ -183,32 +183,6 @@ else:
ttywidth -= 1 # don't go to the edge
-def splitcommand(cmd):
- '''Like string.split, except take quotes into account.'''
- q = None
- w = []
- command = []
- for c in cmd:
- if q:
- if c == q:
- q = None
- else:
- w.append(c)
- elif c in string.whitespace:
- if w:
- command.append(''.join(w))
- w = []
- elif c == '"' or c == "'":
- q = c
- else:
- w.append(c)
- if w:
- command.append(''.join(w))
- if len(command) > 1 and command[0] == 'call':
- del command[0]
- return command
-
-
def remove(file):
try:
os.remove(file)
@@ -227,7 +201,7 @@ def remove(file):
Warn(f'could not remove {file}')
-def isexecutable(TST, ext = '.sh'):
+def isexecutable(TST, ext='.sh'):
if os.name == 'nt':
for ext in '.exe', '.com', '.bat', '.cmd':
if TST.lower().endswith(ext):
@@ -244,7 +218,7 @@ def isexecutable(TST, ext = '.sh'):
def CheckExec(cmd):
for p in os.environ['PATH'].split(os.pathsep):
- x = isexecutable(os.path.join(p,cmd),'')
+ x = isexecutable(os.path.join(p,cmd), ext='')
if x[0]:
return os.path.join(p, cmd + x[1])
return ''
@@ -362,7 +336,7 @@ class Element(_Encode):
'input', 'col', 'frame', 'isindex', 'base', 'meta', ]
xml = True # write XHTML instead of HTML
- def __init__(self, tag, attrdict = None, *children):
+ def __init__(self, tag, attrdict=None, *children):
self.tag = tag
if attrdict is None:
attrdict = {}
@@ -393,7 +367,7 @@ class Element(_Encode):
s.append('>') # empty HTML element
return ''.join(s)
- def write(self, f, newline = False):
+ def write(self, f, newline=False):
# write the element with its children to a file
# if newline is set, add newlines at strategic points
if self.tag.lower() == 'html':
@@ -445,7 +419,7 @@ class Element(_Encode):
class Text(_Encode):
# class to represent text in (X)HTML
- def __init__(self, text = '', raw = False):
+ def __init__(self, text='', raw=False):
self.text = text
self.raw = raw
@@ -454,7 +428,7 @@ class Text(_Encode):
return self.text
return self.encode(self.text, False)
- def write(self, f, newline = False):
+ def write(self, f, newline=False):
f.write(str(self))
if newline and not self.raw:
f.write('\n')
@@ -468,7 +442,7 @@ class Comment:
def __str__(self):
return '<!--%s-->' % self.text
- def write(self, f, newline = False):
+ def write(self, f, newline=False):
f.write(str(self))
@@ -958,7 +932,7 @@ def AddTstToHtmlIndex(env, TST, STABLEou
td.addchildren(AddHref('.%s%s.html' % (TST, '.out'),
'%s_%s_body' % (DISTVER, TSTDIR),
'out', o))
- td.addchild(Text(' | ', raw = True))
+ td.addchild(Text(' | ', raw=True))
td.addchildren(AddHref('.%s%s.html' % (TST, '.err'),
'%s_%s_body' % (DISTVER, TSTDIR),
'err', e))
@@ -1107,14 +1081,13 @@ def PerformDir(env, testdir, testlist, t
alltests.append((tst,cond))
allf.close()
try:
- f = openutf8(os.path.join(TSTSRCDIR, 'SingleServer'))
+ with openutf8(os.path.join(TSTSRCDIR, 'SingleServer')) as f:
+ options = shlex.split(f.read())
except IOError:
oneserver = False
options = [] # not used
else:
oneserver = not restart
- options = splitcommand(f.read())
- f.close()
if testlist:
tl = []
@@ -1453,7 +1426,7 @@ def PerformDir(env, testdir, testlist, t
# the environment; and the addition of an extra parameter with default
# so that the environment which is used to expand can be replace.
_varprog = re.compile(r'\$(\w+|\{[^}]*\})')
-def expandvars(path, environ = os.environ):
+def expandvars(path, environ=os.environ):
'''Expand shell variables of form $var and ${var}. Unknown variables
are left unchanged.'''
if '$' not in path:
@@ -1518,7 +1491,7 @@ def coredumpctl(pid):
return out, err
-def returnCode(proc, f = None):
+def returnCode(proc, f=None):
'''Interpret the return code of a process.
If second arg specified, write a message to it.'''
if proc.killed:
@@ -1720,6 +1693,9 @@ def GetBitsAndModsAndThreads(env):
print(file=sys.stderr)
print(qErr, file=sys.stderr, flush=True)
rtrn = 1
+ if 'sql' not in mods:
+ ErrMsg('No sql module available!')
+ rtrn = 1
else:
rtrn = 1
ErrMsg('No output from mserver5 when checking for Bits, Modules &
Threads!?')
@@ -1730,7 +1706,7 @@ def GetBitsAndModsAndThreads(env):
return rtrn
-def CheckMods(env, TST, SERVER, CALL):
+def CheckMods(env, TST):
missing = []
if os.path.isfile(TST + '.modules'):
with openutf8(TST + '.modules') as fil:
@@ -1738,11 +1714,6 @@ def CheckMods(env, TST, SERVER, CALL):
m = m.strip()
if m and m[0] != '#' and m not in env['TST_MODS']:
missing.append(m)
- if SERVER == 'SQL':
- sql_mods = ['sql']
- for m in sql_mods:
- if m not in env['TST_MODS']:
- missing.append(m)
return missing
@@ -1826,8 +1797,6 @@ tests = (
('.maltest', '.maltest','maltest','SQL'),
('.py', '.py', 'python', ''),
('.SQL.py', '.SQL.py', 'python', 'SQL'),
- ('.sql', '.sql', 'sql', 'SQL'),
- ('.R', '.R', 'R', 'SQL'),
('.rb', '.rb', 'ruby', 'SQL'),
)
@@ -1844,10 +1813,8 @@ def RunTest(env, TST, COND, oktests, len
TX = -1
EXT = CALL = SERVER = ''
x = isexecutable(os.path.join(TSTSRCDIR, TST))
- if not x[0]:
- x = isexecutable(os.path.join(TSTSRCDIR, TST),'')
xS = isexecutable(os.path.join(TSTSRCDIR, TST) + '.SQL')
- if x[0]:
+ if x[0]:
EXT = x[1]
CALL = 'other'
elif xS[0]:
@@ -1867,7 +1834,7 @@ def RunTest(env, TST, COND, oktests, len
if os.name == 'nt':
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|.R|.rb]`"
+ 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='')
@@ -1893,7 +1860,7 @@ def RunTest(env, TST, COND, oktests, len
return TX,Failed,Failed,elem,reason,links
- MissingMods = CheckMods(env, os.path.join(TSTSRCDIR, TST), SERVER, CALL)
+ MissingMods = CheckMods(env, os.path.join(TSTSRCDIR, TST))
MissingTests = CheckTests(env, os.path.join(TSTSRCDIR, TST), oktests)
nomito = os.path.isfile(os.path.join(TSTSRCDIR, TST + '.nomito'))
user = None
@@ -2055,24 +2022,9 @@ def RunTest(env, TST, COND, oktests, len
elif MissingTests:
reason = "as required test%s '%s' failed." % ('s' if len(MissingTests)
!= 1 else '', "', '".join(MissingTests))
elem = SkipTest(env, TST, EXT, reason, length, TSTDIR, TSTTRGDIR,
TSTSRCDIR)
- elif EXT == ".sql" and 'SQL_Client' not in env['exe']:
- reason = f"as {env['SQLCLIENT'].split(None, 1)[0]} is not available."
- elem = SkipTest(env, TST, EXT, reason, length, TSTDIR, TSTTRGDIR,
TSTSRCDIR)
- elif EXT == ".sql" and 'SQL_Dump' not in env['exe']:
- reason = f"as {env['SQLDUMP'].split(None, 1)[0]} is not available."
- elem = SkipTest(env, TST, EXT, reason, length, TSTDIR, TSTTRGDIR,
TSTSRCDIR)
elif CALL == 'ruby' and 'ruby_client' not in env['exe']:
reason = 'as ruby is not available.'
elem = SkipTest(env, TST, EXT, reason, length, TSTDIR, TSTTRGDIR,
TSTSRCDIR)
- elif CALL == 'R' and 'R_client' not in env['exe']:
- reason = f"as {env['RCLIENT'].split(None, 1)[0]} is not available."
- elem = SkipTest(env, TST, EXT, reason, length, TSTDIR, TSTTRGDIR,
TSTSRCDIR)
- elif SERVER == 'SQL' and 'mserver5' not in env['exe']:
- reason = f"as {env['MSERVER'].split(None, 1)[0]} is not available."
- elem = SkipTest(env, TST, EXT, reason, length, TSTDIR, TSTTRGDIR,
TSTSRCDIR)
- elif EXT == '.malS' and 'mserver5' not in env['exe']:
- reason = f"as {env['MSERVER'].split(None, 1)[0]} is not available."
- elem = SkipTest(env, TST, EXT, reason, length, TSTDIR, TSTTRGDIR,
TSTSRCDIR)
elif MissingMods:
reason = f"as modules '{MissingMods}` are missing."
elem = SkipTest(env, TST, EXT, reason, length, TSTDIR, TSTTRGDIR,
TSTSRCDIR)
@@ -2080,10 +2032,9 @@ def RunTest(env, TST, COND, oktests, len
reason = 'test with timeout'
elem = SkipTest(env, TST, EXT, reason, length, TSTDIR, TSTTRGDIR,
TSTSRCDIR)
else:
- test = re.compile('^'+TST+r'((_[sp][0-9][0-9])?\..*)?$', re.MULTILINE)
srcdir = os.path.join(TSTTRGDIR, RELSRCDIR)
for f in listdir(srcdir):
- if test.match(f):
+ if f.startswith(TST+'.'):
try:
SymlinkOrCopy(os.path.join(RELSRCDIR, f), f, TSTTRGDIR)
links.append(os.path.join(TSTTRGDIR, f))
@@ -2101,42 +2052,29 @@ def RunTest(env, TST, COND, oktests, len
myenv['TSTSRCDIR'] = TSTSRCDIR
myenv['RELSRCDIR'] = RELSRCDIR
myenv['TSTTRGDIR'] = TSTTRGDIR
- if os.path.isfile(os.path.join(TSTTRGDIR, TST+EXT+'.src')) and not
os.path.isfile(os.path.join(TSTTRGDIR, TST+EXT)):
- with openutf8(os.path.join(TSTTRGDIR, TST+EXT+'.src'),'r') as f:
- TSTSRC = expandvars(path(f.readline().strip()), myenv)
- if os.path.isfile(os.path.join(TSTTRGDIR, TSTSRC)):
- try:
- SymlinkOrCopy(TSTSRC, TST + EXT, TSTTRGDIR)
- links.append(TST + EXT)
- except IOError as err:
- ErrMsg("SymlinkOrCopy('%s','%s') in '%s' failed with #%d:
'%s'."
- % (TSTSRC, TST + EXT, TSTTRGDIR, err.errno,
err.strerror))
- else:
- reason = "as source file '%s` is missing." % TSTSRC
- elem = SkipTest(env, TST, EXT+'.src', reason, length, TSTDIR,
TSTTRGDIR, TSTSRCDIR)
- return TX,Failed,Failed,elem,reason,links
- test = re.compile('^'+TST+r'((_[sp][0-9][0-9])?\..*)?\.src$',
re.MULTILINE)
for ff in listdir(TSTTRGDIR):
- if test.match(ff) and not os.path.isfile(os.path.join(TSTTRGDIR,
ff[:-4])):
- with openutf8(os.path.join(TSTTRGDIR, ff),'r') as f:
- TSTSRC = expandvars(path(f.readline().strip()), myenv)
- if os.path.isfile(os.path.join(TSTTRGDIR, TSTSRC)):
- try:
- SymlinkOrCopy(TSTSRC, ff[:-4], TSTTRGDIR)
- links.append(ff[:-4])
- except IOError as err:
- ErrMsg("SymlinkOrCopy('%s','%s') in '%s' failed with
#%d: '%s'."
- % (TSTSRC, ff[:-4], TSTTRGDIR, err.errno,
err.strerror))
- else:
- Warn("source file '"+TSTSRC+"` is missing.")
- test = re.compile('^'+TST+r'(_[sp][0-9][0-9])?\..*\.in$', re.MULTILINE)
- for ff in listdir(TSTTRGDIR):
- fff = ff[:-3]
- if test.match(ff) and not os.path.isfile(os.path.join(TSTTRGDIR,
fff)) and not ff.endswith('.test.in'):
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]