Changeset: 2f2b58669b90 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2f2b58669b90
Modified Files:
testing/sqllogictest.py
Branch: Dec2025
Log Message:
If column types in .test file are incorrect, produce correct ones when
approving.
diffs (truncated from 345 to 300 lines):
diff --git a/testing/sqllogictest.py b/testing/sqllogictest.py
--- a/testing/sqllogictest.py
+++ b/testing/sqllogictest.py
@@ -529,13 +529,15 @@ class SQLLogic:
raise
except TimeoutError as e:
self.query_error(query, 'Timeout', str(e))
- return ['statement', 'crash'] # should never be approved
+ return ['statement', 'crash'] # should never be approved
except ConnectionError as e:
- self.query_error(query, 'Timeout or server may have crashed',
str(e))
- return ['statement', 'crash'] # should never be approved
+ self.query_error(query, 'Timeout or server may have crashed',
+ str(e))
+ return ['statement', 'crash'] # should never be approved
except:
tpe, value, traceback = sys.exc_info()
- self.query_error(query, 'unexpected error from pymonetdb',
str(value))
+ self.query_error(query, 'unexpected error from pymonetdb',
+ str(value))
return ['statement', 'error'], []
if crs.description is None:
# it's not a query, it's a statement
@@ -547,7 +549,8 @@ class SQLLogic:
raise
except:
tpe, value, traceback = sys.exc_info()
- self.query_error(query, 'unexpected error from pymonetdb',
str(value))
+ self.query_error(query, 'unexpected error from pymonetdb',
+ str(value))
return ['statement', 'error'], []
if crs.lastrowid is not None:
# it was a PREPARE query
@@ -563,40 +566,51 @@ class SQLLogic:
res = geosre.search(col)
if res is not None:
points = ptsre.sub(r'(\g<0>)', res.group('points'))
- col = col[:res.start('points')] + points +
col[res.end('points'):]
+ col = col[:res.start('points')] + points \
+ + col[res.end('points'):]
res = geoszre.search(col)
if res is not None:
points = ptszre.sub(r'(\g<0>)', res.group('points'))
- col = col[:res.start('points')] + points +
col[res.end('points'):]
+ col = col[:res.start('points')] + points \
+ + col[res.end('points'):]
res = geosere.search(col)
if res is not None:
- col = col[:res.start(0)] + 'MULTIPOLYGON EMPTY' +
col[res.end(0):]
+ col = col[:res.start(0)] + 'MULTIPOLYGON EMPTY' \
+ + col[res.end(0):]
nrow.append(col)
ndata.append(nrow)
data = ndata
if crs.description:
rescols = []
for desc in crs.description:
- if desc.type_code in ('boolean', 'tinyint', 'smallint', 'int',
'bigint', 'hugeint', 'bit', 'sht', 'lng', 'hge', 'oid', 'void'):
+ if desc.type_code in ('boolean', 'tinyint', 'smallint', 'int',
+ 'bigint', 'hugeint', 'bit', 'sht', 'lng',
+ 'hge', 'oid', 'void'):
rescols.append('I')
elif desc.type_code == 'decimal':
- rescols.append('D') # extension
+ rescols.append('D') # extension
elif desc.type_code in ('double', 'real', 'flt', 'dbl'):
rescols.append('R')
else:
rescols.append('T')
rescols = ''.join(rescols)
if len(crs.description) != len(columns):
- self.query_error(query, f'received {len(crs.description)}
columns, expected {len(columns)} columns', data=data)
+ self.query_error(query
+ , f'received {len(crs.description)} columns,'
+ f' expected {len(columns)} columns',
+ data=data)
columns = rescols
err = True
else:
# how can this be?
- #self.query_error(query, 'no crs.description')
+ # self.query_error(query, 'no crs.description')
rescols = 'T'
if sorting != 'python' and crs.rowcount * len(columns) != nresult:
if not err:
- self.query_error(query, f'received {crs.rowcount} rows,
expected {nresult // len(columns)} rows', data=data)
+ self.query_error(query,
+ f'received {crs.rowcount} rows,'
+ f' expected {nresult // len(columns)} rows',
+ data=data)
err = True
if self.res is not None:
for row in data:
@@ -614,34 +628,38 @@ class SQLLogic:
resdata = None
data = self.convertresult(query, columns, data)
if data is None:
- return ['statement', 'error'], []
+ err = True
m = hashlib.md5()
resm = hashlib.md5()
i = 0
result = []
if sorting == 'valuesort':
- ndata = []
- for row in data:
- for col in row:
- ndata.append(col)
- ndata.sort()
- for col in ndata:
- if expected is not None:
- if i < len(expected) and col != expected[i]:
- self.query_error(query, 'unexpected value; received
"%s", expected "%s"' % (col, expected[i]))
- err = True
- i += 1
- m.update(bytes(col, encoding='utf-8'))
- m.update(b'\n')
- result.append(col)
- if err and expected is not None and self.out:
- print('Differences:', file=self.out)
- print('\n'.join(difflib.unified_diff(expected,
- ndata,
- fromfile='expected',
- tofile='received',
- lineterm='')),
- file=self.out)
+ if data is not None:
+ ndata = []
+ for row in data:
+ for col in row:
+ ndata.append(col)
+ ndata.sort()
+ for col in ndata:
+ if expected is not None:
+ if i < len(expected) and col != expected[i]:
+ self.query_error(query,
+ 'unexpected value; received'
+ f' "{col}", expected'
+ f' "{expected[i]}"')
+ err = True
+ i += 1
+ m.update(bytes(col, encoding='utf-8'))
+ m.update(b'\n')
+ result.append(col)
+ if err and expected is not None and self.out:
+ print('Differences:', file=self.out)
+ print('\n'.join(difflib.unified_diff(expected,
+ ndata,
+ fromfile='expected',
+ tofile='received',
+ lineterm='')),
+ file=self.out)
if resdata is not None:
result = []
ndata = []
@@ -662,7 +680,8 @@ class SQLLogic:
else:
pymod = importlib.import_module(mod)
except ModuleNotFoundError:
- self.query_error(query, 'cannot import filter function
module')
+ self.query_error(query,
+ 'cannot import filter function module')
err = True
else:
try:
@@ -681,45 +700,53 @@ class SQLLogic:
err = True
ndata = data
if not err:
- try:
- ndata = pyfnc(data)
- except:
- self.query_error(query, 'filter function failed')
- err = True
+ if data is not None:
+ try:
+ ndata = pyfnc(data)
+ except:
+ self.query_error(query, 'filter function failed')
+ err = True
if resdata is not None:
try:
resdata = pyfnc(resdata)
except:
resdata = None
- ncols = 1
- if (len(ndata)):
- ncols = len(ndata[0])
- if len(ndata)*ncols != nresult:
- self.query_error(query, f'received {len(ndata)*ncols} rows,
expected {nresult} rows', data=data)
- err = True
- for row in ndata:
- for col in row:
- if expected is not None:
- if i < len(expected) and col != expected[i]:
- self.query_error(query, 'unexpected value;
received "%s", expected "%s"' % (col, expected[i]))
- err = True
- i += 1
- m.update(bytes(col, encoding='utf-8'))
- m.update(b'\n')
- result.append(col)
- if err and expected is not None:
- recv = []
+ if data is not None:
+ ncols = 1
+ if (len(ndata)):
+ ncols = len(ndata[0])
+ if len(ndata)*ncols != nresult:
+ self.query_error(query,
+ f'received {len(ndata)*ncols} rows,'
+ f' expected {nresult} rows', data=data)
+ err = True
for row in ndata:
for col in row:
- recv.append(col)
- if self.out:
- print('Differences:', file=self.out)
- print('\n'.join(difflib.unified_diff(expected,
- recv,
- fromfile='expected',
- tofile='received',
- lineterm='')),
- file=self.out)
+ if expected is not None:
+ if i < len(expected) and col != expected[i]:
+ self.query_error(query,
+ 'unexpected value; received'
+ f' "{col}", expected'
+ f' "{expected[i]}"')
+ err = True
+ i += 1
+ m.update(bytes(col, encoding='utf-8'))
+ m.update(b'\n')
+ result.append(col)
+ if err and expected is not None:
+ recv = []
+ for row in ndata:
+ for col in row:
+ recv.append(col)
+ if self.out:
+ print('Differences:', file=self.out)
+ print(
+ '\n'.join(difflib.unified_diff(expected,
+ recv,
+ fromfile='expected',
+ tofile='received',
+ lineterm='')),
+ file=self.out)
if resdata is not None:
result = []
for row in resdata:
@@ -728,30 +755,31 @@ class SQLLogic:
resm.update(b'\n')
result.append(col)
else:
- ndata = data
- if sorting == 'rowsort':
- ndata = sorted(data)
- err_msg_buff = []
- received = []
- for row in ndata:
- for col in row:
- received.append(col)
- m.update(bytes(col, encoding='utf-8'))
- m.update(b'\n')
- result.append(col)
- if expected is not None:
- diffs = list(difflib.unified_diff(expected,
- received,
- fromfile='expected',
- tofile='received',
- lineterm=''))
- if diffs:
- if not err:
- self.query_error(query, 'unexpected output')
- err = True
- if self.out:
- print('Differences:', file=self.out)
- print('\n'.join(diffs), file=self.out)
+ if data is not None:
+ ndata = data
+ if sorting == 'rowsort':
+ ndata = sorted(data)
+ err_msg_buff = []
+ received = []
+ for row in ndata:
+ for col in row:
+ received.append(col)
+ m.update(bytes(col, encoding='utf-8'))
+ m.update(b'\n')
+ result.append(col)
+ if expected is not None:
+ diffs = list(difflib.unified_diff(expected,
+ received,
+ fromfile='expected',
+ tofile='received',
+ lineterm=''))
+ if diffs:
+ if not err:
+ self.query_error(query, 'unexpected output')
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]