From 4ac601f05db29b6135a784228098e004ca198499 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Wed, 15 Jan 2020 15:18:04 +0100 Subject: Fix pathological_tests.py on Windows When using multiprocessing on Windows, the main program must be guarded with a __name__ check. --- test/pathological_tests.py | 62 ++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 29 deletions(-) (limited to 'test') 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() -- cgit v1.2.3