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

Some cleanup.
Mostly just whitespace.


diffs (truncated from 592 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
@@ -10,21 +10,6 @@
 # Copyright August 2008 - 2023 MonetDB B.V.;
 # Copyright 1997 - July 2008 CWI.
 
-#TODO:
-#=====
-# - check all TODO's below
-# - tidy -up HTML-generation by "keeping in mind" during testing,
-#   which OUT/ERR differ or not and which tests were skipped.
-#   dump HTML-stuff only at end
-#   print an ascii summary at end, too
-# - if no diffs, but warnings, say so at end
-# - produce, keep & reference LOG
-# - add a "grep-like" function and replace "inlined" grep
-#   contains(<file>,<string>)
-# - do multi-level prompting?
-# - normalize all path's used
-# - Python 3? (or do a full rewrite?)
-
 import os
 import sys
 import shutil
@@ -33,6 +18,7 @@ import re
 import secrets
 import time
 import socket
+import string                   # for whitespace
 import struct
 import signal
 import fnmatch
@@ -40,7 +26,7 @@ import http
 import http.server
 import glob
 import datetime
-import pymonetdb # check for pymonetdb early: it is essential for our work
+import pymonetdb  # check for pymonetdb early: it is essential for our work
 import concurrent.futures
 
 MonetDB_VERSION = '@MONETDB_VERSION@'.split('.')
@@ -77,6 +63,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')
 
+
 # default is no color (these three functions may get redefined)
 def prred(str):
     print(str, end='')
@@ -195,7 +182,7 @@ else:
     if ttywidth > 0 and os.name == 'nt':
         ttywidth -= 1           # don't go to the edge
 
-import string                   # for whitespace
+
 def splitcommand(cmd):
     '''Like string.split, except take quotes into account.'''
     q = None
@@ -221,6 +208,7 @@ def splitcommand(cmd):
         del command[0]
     return command
 
+
 def remove(file):
     try:
         os.remove(file)
@@ -238,7 +226,8 @@ def remove(file):
     except:
         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):
@@ -251,15 +240,14 @@ def isexecutable(TST, ext = '.sh') :
            ( os.path.isfile(TST+'.src') and os.access(TST+'.src',os.X_OK) ):
             return (True, ext)
     return (False, '')
-### isexecutable(TST, ext = '.sh') #
-
-def CheckExec(cmd) :
+
+
+def CheckExec(cmd):
     for p in os.environ['PATH'].split(os.pathsep):
         x = isexecutable(os.path.join(p,cmd),'')
         if x[0]:
             return os.path.join(p, cmd + x[1])
     return ''
-### CheckExec(cmd) #
 
 import argparse
 
@@ -334,6 +322,7 @@ CONDITIONALS = {
     'HAVE_PYTHON_LZ4'      : False, # import lz4
 }
 
+
 # a bunch of classes to help with generating (X)HTML files
 class _Encode:
     # mix-in class for encoding text and attribute values so that they
@@ -357,6 +346,7 @@ class _Encode:
             data = data.replace(c, tr)
         return data
 
+
 class Element(_Encode):
     # class to represent an (X)HTML element with its attributes and
     # children
@@ -452,6 +442,7 @@ class Element(_Encode):
     def inschild(self, index, child):
         self.children.insert(index, child)
 
+
 class Text(_Encode):
     # class to represent text in (X)HTML
     def __init__(self, text = '', raw = False):
@@ -468,6 +459,7 @@ class Text(_Encode):
         if newline and not self.raw:
             f.write('\n')
 
+
 class Comment:
     # class to represent an (X)HTML comment (not currently used)
     def __init__(self, text):
@@ -479,6 +471,7 @@ class Comment:
     def write(self, f, newline = False):
         f.write(str(self))
 
+
 REV = ''                # revision (output of hg id), default unknown
 
 black = 'black'                         # #000000
@@ -504,17 +497,18 @@ stylesheet = Element('style', None, Text
 
 TIMES = []
 
-def ErrMsg(TEXT) :
+
+def ErrMsg(TEXT):
     print(end='', flush=True)
     print('\n%s:  ERROR:  %s\n' % (THISFILE, TEXT), file=sys.stderr, 
flush=True)
-### ErrMsg(TEXT) #
-
-def ErrXit(TEXT) :
+
+
+def ErrXit(TEXT):
     ErrMsg(TEXT)
     sys.exit(1)
-### ErrXit(TEXT) #
-
-def Warn(TEXT) :
+
+
+def Warn(TEXT):
     try:
         print(end='', flush=True)
     except IOError:
@@ -523,34 +517,37 @@ def Warn(TEXT) :
         print('\n%s  Warning:  %s\n' % (THISFILE, TEXT), file=sys.stderr, 
flush=True)
     except IOError:
         pass
-### Warn(TEXT) #
-
-def startswithpath(str,pre) :
+
+
+def startswithpath(str,pre):
     return os.path.normcase(str[:len(pre)]) == os.path.normcase(pre)
-### startswithpath(str,pre) #
 
 import urllib.request, urllib.parse
 path = urllib.request.url2pathname
-def url(str) :
+
+
+def url(str):
     url = urllib.request.pathname2url(str)
     # on Windows, C:\tmp\foo becomes ///C:/tmp/foo, turn into /C:/tmp/foo
     if url.startswith('///'):
         url = url[2:]
     return url
 
+
 def openutf8(file, mode='r'):
     return open(file, mode, encoding='utf-8', errors='replace')
 
-def try_open(path, mode) :
+
+def try_open(path, mode):
     try:
         f = openutf8(path, mode)
     except IOError as err:
         Warn("Opening file '%s' in mode '%s' failed with #%d: '%s'." % (path, 
mode, err.errno, err.strerror))
         f = None
     return f
-###  try_open(path, mode) #
-
-def CreateHtmlIndex (env, TSTDIR, TSTTRGDIR, ssout, sserr, *body) :
+
+
+def CreateHtmlIndex(env, TSTDIR, TSTTRGDIR, ssout, sserr, *body):
     if TSTDIR:
         INDEX='.index'
     else:
@@ -646,12 +643,12 @@ def CreateHtmlIndex (env, TSTDIR, TSTTRG
                                         'marginheight': '0'})))
         with openutf8(os.path.join(TSTTRGDIR, '%s.html' % INDEX), 'w') as f:
             html.write(f, True)
-### CreateHtmlIndex (env, ssout, sserr, *body) #
+
 
 bugre = re.compile(r'\.(sf|bug)-(?P<bugno>[1-9]\d+)', re.I)
 
 
-def CreateTstWhatXhtml (env, TST, stableWHAT, EXT, result, TSTDIR, TSTTRGDIR, 
TSTSRCDIR, RELSRCDIR) :
+def CreateTstWhatXhtml(env, TST, stableWHAT, EXT, result, TSTDIR, TSTTRGDIR, 
TSTSRCDIR, RELSRCDIR):
     WHAT = stableWHAT[7:11]
 
     if result == F_OK:
@@ -813,7 +810,8 @@ def CreateTstWhatXhtml (env, TST, stable
     html.write(f, True)
     f.close()
 
-def CreateSrcIndex (env, TST, EXT, TSTDIR, TSTTRGDIR, TSTSRCDIR) :
+
+def CreateSrcIndex(env, TST, EXT, TSTDIR, TSTTRGDIR, TSTSRCDIR):
     if REV:
         framesrc = '%s%s/%s/%s%s' % (URLPREFIX, url(TSTDIR), TSTSUFF, TST, EXT)
     else:
@@ -895,9 +893,9 @@ def CreateSrcIndex (env, TST, EXT, TSTDI
                                            tr))))
     with openutf8(os.path.join(TSTTRGDIR, '.%s.src.index.head.html' % TST), 
'w') as f:
         html.write(f, True)
-### CreateSrcIndex (env, TST, EXT) #
-
-def AddHref (href, target, linktext, diff) :
+
+
+def AddHref(href, target, linktext, diff):
     if   diff == F_ERROR:
         klass = 'error'
     elif diff == F_RECU:
@@ -923,11 +921,14 @@ def AddHref (href, target, linktext, dif
         return [Text('('), a, Text(')')]
     else:
         return [a]
-### AddHref (TSTDIR, TST, WHAT, diff) #
-
-def AddTstToHtmlIndex (env, TST, STABLEout, STABLEerr, EXT, o, e, TSTDIR, 
TSTTRGDIR, TSTSRCDIR, RELSRCDIR) :
-    CreateTstWhatXhtml(env, TST, STABLEout, EXT, o, TSTDIR, TSTTRGDIR, 
TSTSRCDIR, RELSRCDIR)
-    CreateTstWhatXhtml(env, TST, STABLEerr, EXT, e, TSTDIR, TSTTRGDIR, 
TSTSRCDIR, RELSRCDIR)
+
+
+def AddTstToHtmlIndex(env, TST, STABLEout, STABLEerr, EXT, o, e, TSTDIR,
+                      TSTTRGDIR, TSTSRCDIR, RELSRCDIR):
+    CreateTstWhatXhtml(env, TST, STABLEout, EXT, o, TSTDIR, TSTTRGDIR,
+                       TSTSRCDIR, RELSRCDIR)
+    CreateTstWhatXhtml(env, TST, STABLEerr, EXT, e, TSTDIR, TSTTRGDIR,
+                       TSTSRCDIR, RELSRCDIR)
 
     if e == F_RECU:
         tstclass = 'recursion'
@@ -970,9 +971,9 @@ def AddTstToHtmlIndex (env, TST, STABLEo
     CreateSrcIndex(env, TST, EXT, TSTDIR, TSTTRGDIR, TSTSRCDIR)
 
     return td
-### AddTstToHtmlIndex (env, TST, STABLEout, STABLEerr, EXT) #
-
-def AddSubToHtmlIndex (env, TSTDIR, diff) :
+
+
+def AddSubToHtmlIndex(env, TSTDIR, diff):
     elem = Element('p', {})
     elem.addchildren(AddHref('%s/.index.html' % url(TSTDIR),
                              '%s__body' % DISTVER,
@@ -982,9 +983,9 @@ def AddSubToHtmlIndex (env, TSTDIR, diff
        env['__BODY_'][1] < diff:
         env['__BODY_'] = ['%s/.index.html' % TSTDIR, diff]
     return elem
-### AddSubToHtmlIndex (env, TSTDIR, diff) #
-
-def SkipTest(env, TST, EXT, REASON, length, TSTDIR, TSTTRGDIR, TSTSRCDIR) :
+
+
+def SkipTest(env, TST, EXT, REASON, length, TSTDIR, TSTTRGDIR, TSTSRCDIR):
     TEXT = 'Skipping test %s%s %s' % (TST, EXT, REASON)
     if verbosity > 1:
         Warn(TEXT)
@@ -1029,9 +1030,9 @@ def SkipTest(env, TST, EXT, REASON, leng
         env[f'_{TSTDIR}_BODY_'] = ['.%s.SKIPPED.html' % TST, F_SKIP]
     CreateSrcIndex(env, TST, EXT, TSTDIR, TSTTRGDIR, TSTSRCDIR)
     return td
-### SkipTest(env, TST, EXT, REASON) #
-
-def find_test_dirs(thisdir, recursive=True) :
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to