Try to set up subprocess coverage better

This commit is contained in:
James R. Barlow
2019-12-31 15:39:45 -08:00
parent 4b759af6ff
commit 96ee21aee9
2 changed files with 12 additions and 4 deletions
+3 -3
View File
@@ -1,5 +1,3 @@
# Coverage isn't really compatible with subprocesses so results are unreliable
[paths]
source =
src
@@ -8,9 +6,11 @@ source =
[run]
branch = true
parallel = true
concurrency =
thread
multiprocessing
source =
src/ocrmypdf
tests
omit =
tests/spoof/*
+9 -1
View File
@@ -229,13 +229,21 @@ def run_ocrmypdf(input_file, output_file, *args, env=None, universal_newlines=Tr
"Run ocrmypdf and let caller deal with results"
if env is None:
env = os.environ
env = os.environ.copy()
p_args = (
OCRMYPDF
+ [str(arg) for arg in args if arg is not None]
+ [str(input_file), str(output_file)]
)
# Tell subprocess where to find coverage.py configuration
# This has no effect except when coverage is running
# Details: https://coverage.readthedocs.io/en/coverage-5.0/subprocess.html
coverage_rc = Path(__file__).parent.parent / '.coveragerc'
assert coverage_rc.exists()
env['COVERAGE_PROCESS_START'] = os.fspath(coverage_rc)
p = run(
p_args, stdout=PIPE, stderr=PIPE, universal_newlines=universal_newlines, env=env
)