Changeset: e2140a2a39c4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e2140a2a39c4
Modified Files:
        testing/Mtest.py.in
        testing/sqltest.py
Branch: Mar2025
Log Message:

Layout, and some dead code removal.


diffs (216 lines):

diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -2487,19 +2487,21 @@ def stacktrace(proc, outfile):
     out = ''
     if os.name == 'nt':
         sym = ''
-        if os.path.exists(r'c:\Program Files\Debugging Tools for Windows 
(x64)\cdb.exe'):
-            cdb = r'c:\Program Files\Debugging Tools for Windows (x64)\cdb.exe'
+        cdb = r'c:\Program Files\Debugging Tools for Windows (x64)\cdb.exe'
+        if os.path.exists(cdb):
             if os.path.exists(r'c:\Symbols'):
                 sym = r'c:\Symbols;'
-        elif os.path.exists(r'c:\Program Files\Debugging Tools for Windows 
(x86)\cdb.exe'):
+        else:
             cdb = r'c:\Program Files\Debugging Tools for Windows (x86)\cdb.exe'
-            if os.path.exists(r'c:\WINDOWS\Symbols'):
-                sym = r'c:\WINDOWS\Symbols;'
-        else:
-            cdb = None
-        if cdb:
+            if os.path.exists(cdb):
+                if os.path.exists(r'c:\WINDOWS\Symbols'):
+                    sym = r'c:\WINDOWS\Symbols;'
+            else:
+                cdb = None
+        if cdb is not None:
             with process.Popen([cdb, '-pv', '-p', str(proc.pid),
-                                '-y', 
f'{sym}cache*;srv*http://msdl.microsoft.com/download/symbols', '-lines', '-c', 
'~*kP;!locks;q'],
+                                '-y', 
f'{sym}cache*;srv*http://msdl.microsoft.com/download/symbols',
+                                '-lines', '-c', '~*kP;!locks;q'],
                                stdout=process.PIPE, text=True) as p:
                 try:
                     out, err = p.communicate(timeout=60)
@@ -2507,7 +2509,9 @@ def stacktrace(proc, outfile):
                     p.kill()
     elif platform.system() == 'Darwin':
         try:
-            with process.Popen(['lldb', '--attach-pid', str(proc.pid), 
'--batch', '--one-line', 'bt all'], stdout=process.PIPE, text=True) as p:
+            with process.Popen(['lldb', '--attach-pid', str(proc.pid),
+                                '--batch', '--one-line', 'bt all'],
+                               stdout=process.PIPE, text=True) as p:
                 try:
                     out, err = p.communicate(timeout=60)
                 except process.TimeoutExpired:
@@ -2518,18 +2522,17 @@ def stacktrace(proc, outfile):
             pass
     else:
         try:
-            with process.Popen(['gdb', '-n', '-p', str(proc.pid), '-batch', 
'-ex', 'thread apply all bt full'], stdout=process.PIPE,
-                               text=True) as p:
+            with process.Popen(['gdb', '-n', '-p', str(proc.pid),
+                                '-batch', '-ex', 'thread apply all bt full'],
+                               stdout=process.PIPE, text=True) as p:
                 try:
-                    out, err = p.communicate(timeout=60)
+                    out, err = p.communicate(timeout=600)
                 except process.TimeoutExpired:
                     # gdb sometimes hangs when trying to get the stack
                     # trace: kill it mercilessly if it does
                     p.kill()
                     p.wait()
-                    out = err = ''
-            if t is not None:
-                t.cancel()
+                    out = ''
         except KeyboardInterrupt:
             raise
         except:
diff --git a/testing/sqltest.py b/testing/sqltest.py
--- a/testing/sqltest.py
+++ b/testing/sqltest.py
@@ -10,30 +10,33 @@
 
 import os
 import sys
-import unittest
 import pymonetdb
 import difflib
 from abc import ABCMeta, abstractmethod
 import MonetDBtesting.process as process
 import inspect
-
-TSTDB=os.getenv("TSTDB")
-MAPIPORT=os.getenv("MAPIPORT")
-TIMEOUT=int(os.getenv("TIMEOUT", "0"))
-
 from pathlib import Path
 from typing import Optional
+
+TSTDB = os.getenv("TSTDB")
+MAPIPORT = os.getenv("MAPIPORT")
+TIMEOUT = int(os.getenv("TIMEOUT", "0"))
+
+
 class UnsafeDirectoryHandler(pymonetdb.SafeDirectoryHandler):
     def secure_resolve(self, filename: str) -> Optional[Path]:
         return Path(filename).resolve()
 
+
 transfer_handler = UnsafeDirectoryHandler('.')
 
+
 def equals(a, b) -> bool:
     if type(a) is type(b):
-        return a==b
+        return a == b
     return False
 
+
 def sequence_match(left=[], right=[], index=0):
     right = right[index:]
     ll = len(left)
@@ -47,6 +50,7 @@ def sequence_match(left=[], right=[], in
             return False
     return True
 
+
 def get_index_mismatch(left=[], right=[]):
     ll = len(left)
     rl = len(right)
@@ -57,6 +61,7 @@ def get_index_mismatch(left=[], right=[]
             break
     return index
 
+
 def piped_representation(data=[]):
     def mapfn(next):
         if type(next) is tuple:
@@ -69,16 +74,20 @@ def piped_representation(data=[]):
     res = list(map(mapfn, data))
     return '\n'.join(res)
 
+
 def filter_junk(s: str):
     """filters empty strings and comments
     """
     s = s.strip()
-    if s.startswith('--') or s.startswith('#') or s.startswith('stdout of 
test'):
+    if s.startswith('--') \
+       or s.startswith('#') \
+       or s.startswith('stdout of test'):
         return False
     if s == '':
         return False
     return True
 
+
 def filter_headers(s: str):
     """filter lines prefixed with % (MAPI headers)"""
     s = s.strip()
@@ -88,6 +97,7 @@ def filter_headers(s: str):
         return False
     return True
 
+
 def filter_lines_starting_with(predicates=[]):
     def _fn(line:str):
         line = line.strip()
@@ -115,15 +125,17 @@ def filter_matching_blocks(a: [str] = []
             red_a.append(a[i])
             red_b.append(b[i])
             # keep track of last mismatch to add some ctx in between
-            ptr = i
+#            ptr = i
     # add trailing data if len(a) != len(b)
-    red_a+=a[min_size:]
-    red_b+=b[min_size:]
+    red_a += a[min_size:]
+    red_b += b[min_size:]
     return red_a, red_b
 
+
 def diff(stable_file, test_file, ratio=0.95):
     diff = None
-    filter_fn = filter_lines_starting_with(['--', '#', 'stdout of test', 
'stderr of test', 'MAPI'])
+    filter_fn = filter_lines_starting_with(['--', '#', 'stdout of test',
+                                            'stderr of test', 'MAPI'])
     with open(stable_file) as fstable:
         stable = list(filter(filter_fn, fstable.read().split('\n')))
         with open(test_file) as ftest:
@@ -136,6 +148,7 @@ def diff(stable_file, test_file, ratio=0
                 diff = None
     return diff
 
+
 class PyMonetDBConnectionContext(object):
     def __init__(self,
                  username='monetdb', password='monetdb',
@@ -203,22 +216,24 @@ class PyMonetDBConnectionContext(object)
             self.dbh.close()
             self.dbh = None
 
+
 class RunnableTestResult(metaclass=ABCMeta):
     """Abstract class for sql result"""
     did_run = False
 
     @abstractmethod
-    def run(self, query:str, *args, stdin=None, lineno=None):
+    def run(self, query: str, *args, stdin=None, lineno=None):
         """Run query with specific client"""
         pass
 
+
 class TestCaseResult(object):
     """TestCase connected result"""
     test_case = None
 
     def __init__(self, test_case, **kwargs):
         self.test_case = test_case
-        self.assertion_errors = [] # holds assertion errors
+        self.assertion_errors = []  # holds assertion errors
         self.query = None
         self.test_run_error = None
         self.err_code = None
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to