summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2020-01-15 15:18:04 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2020-01-15 07:04:27 -0800
commit4ac601f05db29b6135a784228098e004ca198499 (patch)
tree9babd528361c533970c9371ff899d3f8904c178d
parent6b64a95713fc8a045f8e40949cec0765e0acb9b8 (diff)
Fix pathological_tests.py on Windows
When using multiprocessing on Windows, the main program must be guarded with a __name__ check.
-rw-r--r--test/pathological_tests.py62
1 files changed, 33 insertions, 29 deletions
diff --git a/test/pathological_tests.py b/test/pathological_tests.py
index b52f593..061ee5f 100644
--- 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()