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

On modern Windows we can use ESC sequences.
This means, running with --parallel now is doable on Windows.


diffs (49 lines):

diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -75,8 +75,22 @@ def prgreen(str):
     print(str, end='')
 def prpurple(str):
     print(str, end='')
+use_esc = False
 if isatty:
-    if os.name != 'nt':
+    if os.name == 'nt':
+        try:
+            import ctypes
+            kernel32 = ctypes.windll.kernel32
+            origmode = ctypes.c_long()
+            handle = kernel32.GetStdHandle(-11) # STD_OUTPUT_HANDLE
+            if kernel32.GetConsoleMode(handle, ctypes.byref(origmode)):
+                if kernel32.SetConsoleMode(handle, origmode.value | 0x0004):
+                    use_esc = True
+        except (ImportError, AttributeError):
+            pass
+    else:
+        use_esc = True
+    if use_esc:
         # color output a little
         RED = '\033[1;31m'
         GREEN = '\033[0;32m'
@@ -3039,10 +3053,7 @@ down = '\033[B'
 
 def progress(count, errors, total, test, spaces=' '*(ttywidth or 100)):
     errs = ''
-    if os.name == 'nt':
-        nl = ''
-        line = 0
-    else:
+    if use_esc:
         tid = threading.get_ident()
         nl = ''
         if tid not in threadids:
@@ -3051,6 +3062,9 @@ def progress(count, errors, total, test,
         line = len(threadids) - threadids[tid]
         if errors:
             errs = f'\r{errors} errors'
+    else:
+        nl = ''
+        line = 0
     perc = int(count*100/total) if total and count else 0
     width = len(str(total))
     s = f'[{count:{width}}/{total}] ({perc:2}%)    {test}'
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to