From be6ce3328f2c32be99ee81b38e1815c544fe1ab1 Mon Sep 17 00:00:00 2001 From: Sean Shahkarami Date: Thu, 18 Jun 2020 10:14:40 -0500 Subject: [PATCH] allow test_docs to fail if any code block fails --- test_docs.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test_docs.py b/test_docs.py index 352a394..48b2357 100644 --- a/test_docs.py +++ b/test_docs.py @@ -2,12 +2,15 @@ import re import subprocess import logging +import sys def run_python_code_block(code): return subprocess.check_output(['python3', '-s'], input=code.encode()) +exitcode = 0 + for path in Path('.').glob('**/*.md'): text = path.read_text() for code in re.findall('```python(.*?)```', text, re.S): @@ -15,5 +18,8 @@ def run_python_code_block(code): print(f'running {path}') run_python_code_block(code) except Exception as exc: + exitcode = 1 logging.exception( f'code block failed in {path}\n\n```python{code}```\n\n') + +sys.exit(exitcode)