- Commit
- 4db1f75834602aa1215b58cbad737593c99ccdc2
- Parent
- cb27409921300ad5ea6ccc5e29d3c78d2ed048b3
- Author
- John MacFarlane <jgm@berkeley.edu>
- Date
Add timeout to pathological_tests.py.
Tests must complete in 8 seconds or are errors.
My personal build of CMark ✏️
Add timeout to pathological_tests.py.
Tests must complete in 8 seconds or are errors.
1 file changed, 13 insertions, 1 deletion
Status | File Name | N° Changes | Insertions | Deletions |
Modified | test/pathological_tests.py | 14 | 13 | 1 |
diff --git 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']))