From 4db1f75834602aa1215b58cbad737593c99ccdc2 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 5 Nov 2017 10:23:57 -0800 Subject: Add timeout to pathological_tests.py. Tests must complete in 8 seconds or are errors. --- test/pathological_tests.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/pathological_tests.py b/test/pathological_tests.py index dd80092..40552de 100644 --- a/test/pathological_tests.py +++ b/test/pathological_tests.py @@ -5,6 +5,8 @@ import re import argparse import sys import platform +import multiprocessing +import time from cmark import CMark if __name__ == "__main__": @@ -92,7 +94,17 @@ def run_pathological_test(description, results): print("Testing pathological cases:") for description in pathological: - run_pathological_test(description, results) + p = multiprocessing.Process(target=run_pathological_test, + args=(description, results,)) + p.start() + # wait 8 seconds or until it finishes + p.join(8) + # kill it if still active + if p.is_alive(): + print(description, '[TIMEOUT]') + p.terminate() + results['errored'] += 1 + p.join() print("%d passed, %d failed, %d errored" % (results['passed'], results['failed'], results['errored'])) -- cgit v1.2.3