cmark

My personal build of CMark ✏️

Commit
4ac601f05db29b6135a784228098e004ca198499
Parent
6b64a95713fc8a045f8e40949cec0765e0acb9b8
Author
Nick Wellnhofer <wellnhofer@aevum.de>
Date

Fix pathological_tests.py on Windows

When using multiprocessing on Windows, the main program must be guarded with a __name__ check.

Diffstat

1 file changed, 33 insertions, 29 deletions

Status File Name N° Changes Insertions Deletions
Modified test/pathological_tests.py 62 33 29
diff --git a/test/pathological_tests.py b/test/pathological_tests.py
@@ -105,34 +105,38 @@ def run_pathological_test(description, results):
         else:
             results['failed'].append(description)
 
-print("Testing pathological cases:")
-for description in pathological:
-    p = multiprocessing.Process(target=run_pathological_test,
-              args=(description, results,))
-    p.start()
-    # wait 4 seconds or until it finishes
-    p.join(4)
-    # kill it if still active
-    if p.is_alive():
-        print(description, '[TIMEOUT]')
-        if allowed_failures[description]:
-            results['ignored'].append(description)
-        else:
-            results['errored'].append(description)
-        p.terminate()
-        p.join()
+def run_tests():
+    print("Testing pathological cases:")
+    for description in pathological:
+        p = multiprocessing.Process(target=run_pathological_test,
+                  args=(description, results,))
+        p.start()
+        # wait 4 seconds or until it finishes
+        p.join(4)
+        # kill it if still active
+        if p.is_alive():
+            print(description, '[TIMEOUT]')
+            if allowed_failures[description]:
+                results['ignored'].append(description)
+            else:
+                results['errored'].append(description)
+            p.terminate()
+            p.join()
+
+    passed  = len(results['passed'])
+    failed  = len(results['failed'])
+    errored = len(results['errored'])
+    ignored = len(results['ignored'])
 
-passed  = len(results['passed'])
-failed  = len(results['failed'])
-errored = len(results['errored'])
-ignored = len(results['ignored'])
+    print("%d passed, %d failed, %d errored" % (passed, failed, errored))
+    if ignored > 0:
+        print("Ignoring these allowed failures:")
+        for x in results['ignored']:
+            print(x)
+    if failed == 0 and errored == 0:
+        exit(0)
+    else:
+        exit(1)
 
-print("%d passed, %d failed, %d errored" % (passed, failed, errored))
-if ignored > 0:
-    print("Ignoring these allowed failures:")
-    for x in results['ignored']:
-        print(x)
-if failed == 0 and errored == 0:
-    exit(0)
-else:
-    exit(1)
+if __name__ == "__main__":
+    run_tests()