<#13239 Coverage for python tests doesn't work cor...
# github-notifications
q
#13239 Coverage for python tests doesn't work correctly over remote execution Issue created by charlesoconor Describe the bug When running python tests with code coverage over remote execution. The code runs correctly and exports coverage metrics when running locally. The section of
pants.toml
.
Copy code
[coverage-py]
config = '.coveragerc'
version = 'coverage==6.0.2'
report = ['xml']     
interpreter_constraints = ['CPython==3.8.*']
Also tried with
version = 'coverage==5.5'
Pants version Which version of Pants are you using? 2.6.1 OS Are you encountering the bug on MacOS, Linux, or both? Linux Additional info Stack trace when running
./pants test <dir_name>::
Copy code
[2021-10-13T07:46:51.304Z] 07:46:36.44 [INFO] Long running tasks:

[2021-10-13T07:46:51.304Z]   82.44s 	Merge 190 Pytest coverage reports.

[2021-10-13T07:47:09.373Z] 07:47:06.46 [INFO] Long running tasks:

[2021-10-13T07:47:09.373Z]   112.46s 	Merge 190 Pytest coverage reports.

[2021-10-13T07:47:56.028Z] 07:47:54.00 [ERROR] Exception caught: (pants.engine.internals.scheduler.ExecutionError)

[2021-10-13T07:47:56.028Z]   File "/home/ocrolus/.cache/pants/setup/bootstrap-Linux-x86_64/2.6.1_py38/lib/python3.8/site-packages/pants/bin/local_pants_runner.py", line 234, in _run_inner

[2021-10-13T07:47:56.028Z]     return self._perform_run(goals)

[2021-10-13T07:47:56.028Z]   File "/home/ocrolus/.cache/pants/setup/bootstrap-Linux-x86_64/2.6.1_py38/lib/python3.8/site-packages/pants/bin/local_pants_runner.py", line 173, in _perform_run

[2021-10-13T07:47:56.028Z]     return self._perform_run_body(goals, poll=False)

[2021-10-13T07:47:56.028Z]   File "/home/ocrolus/.cache/pants/setup/bootstrap-Linux-x86_64/2.6.1_py38/lib/python3.8/site-packages/pants/bin/local_pants_runner.py", line 190, in _perform_run_body

[2021-10-13T07:47:56.028Z]     return self.graph_session.run_goal_rules(

[2021-10-13T07:47:56.028Z]   File "/home/ocrolus/.cache/pants/setup/bootstrap-Linux-x86_64/2.6.1_py38/lib/python3.8/site-packages/pants/init/engine_initializer.py", line 135, in run_goal_rules

[2021-10-13T07:47:56.028Z]     exit_code = self.scheduler_session.run_goal_rule(

[2021-10-13T07:47:56.028Z]   File "/home/ocrolus/.cache/pants/setup/bootstrap-Linux-x86_64/2.6.1_py38/lib/python3.8/site-packages/pants/engine/internals/scheduler.py", line 533, in run_goal_rule

[2021-10-13T07:47:56.028Z]     self._raise_on_error([t for _, t in throws])

[2021-10-13T07:47:56.028Z]   File "/home/ocrolus/.cache/pants/setup/bootstrap-Linux-x86_64/2.6.1_py38/lib/python3.8/site-packages/pants/engine/internals/scheduler.py", line 492, in _raise_on_error

[2021-10-13T07:47:56.028Z]     raise ExecutionError(

[2021-10-13T07:47:56.028Z] 

[2021-10-13T07:47:56.028Z] Exception message: 1 Exception encountered:

[2021-10-13T07:47:56.028Z] 

[2021-10-13T07:47:56.028Z] Engine traceback:

[2021-10-13T07:47:56.028Z]   in select

[2021-10-13T07:47:56.028Z]   in pants.core.goals.test.run_tests

[2021-10-13T07:47:56.028Z]   in pants.backend.python.goals.coverage_py.generate_coverage_reports

[2021-10-13T07:47:56.028Z]   in pants.engine.process.fallible_to_exec_result_or_raise

[2021-10-13T07:47:56.028Z] Traceback (most recent call last):

[2021-10-13T07:47:56.028Z]   File "/home/ocrolus/.cache/pants/setup/bootstrap-Linux-x86_64/2.6.1_py38/lib/python3.8/site-packages/pants/engine/process.py", line 258, in fallible_to_exec_result_or_raise

[2021-10-13T07:47:56.028Z]     raise ProcessExecutionFailure(

[2021-10-13T07:47:56.028Z] pants.engine.process.ProcessExecutionFailure: Process 'Generate Pytest report coverage report.' failed with exit code 1.

[2021-10-13T07:47:56.028Z] stdout:

[2021-10-13T07:47:56.028Z] No source for code: '/worker/build/416d340d8a2e7cf7/root/.cache/pex_root/venvs/5b7fe3b1b328d2677aa38f30067525814a069172/008b37cbe59aadadc25359cf6798a05a8af4bf19/lib/python3.8/site-packages/PIL/BmpImagePlugin.py'.

[2021-10-13T07:47:56.028Z] Aborting report output, consider using -i.

[2021-10-13T07:47:56.028Z] 

[2021-10-13T07:47:56.028Z] stderr:

[2021-10-13T07:47:56.028Z] 

[2021-10-13T07:47:56.028Z] 

[2021-10-13T07:47:56.028Z] Traceback (most recent call last):

[2021-10-13T07:47:56.028Z]   File "/home/ocrolus/.cache/pants/setup/bootstrap-Linux-x86_64/2.6.1_py38/lib/python3.8/site-packages/pants/bin/local_pants_runner.py", line 234, in _run_inner

[2021-10-13T07:47:56.028Z]     return self._perform_run(goals)

[2021-10-13T07:47:56.028Z]   File "/home/ocrolus/.cache/pants/setup/bootstrap-Linux-x86_64/2.6.1_py38/lib/python3.8/site-packages/pants/bin/local_pants_runner.py", line 173, in _perform_run

[2021-10-13T07:47:56.028Z]     return self._perform_run_body(goals, poll=False)

[2021-10-13T07:47:56.028Z]   File "/home/ocrolus/.cache/pants/setup/bootstrap-Linux-x86_64/2.6.1_py38/lib/python3.8/site-packages/pants/bin/local_pants_runner.py", line 190, in _perform_run_body

[2021-10-13T07:47:56.028Z]     return self.graph_session.run_goal_rules(

[2021-10-13T07:47:56.028Z]   File "/home/ocrolus/.cache/pants/setup/bootstrap-Linux-x86_64/2.6.1_py38/lib/python3.8/site-packages/pants/init/engine_initializer.py", line 135, in run_goal_rules

[2021-10-13T07:47:56.028Z]     exit_code = self.scheduler_session.run_goal_rule(

[2021-10-13T07:47:56.028Z]   File "/home/ocrolus/.cache/pants/setup/bootstrap-Linux-x86_64/2.6.1_py38/lib/python3.8/site-packages/pants/engine/internals/scheduler.py", line 533, in run_goal_rule

[2021-10-13T07:47:56.028Z]     self._raise_on_error([t for _, t in throws])

[2021-10-13T07:47:56.028Z]   File "/home/ocrolus/.cache/pants/setup/bootstrap-Linux-x86_64/2.6.1_py38/lib/python3.8/site-packages/pants/engine/internals/scheduler.py", line 492, in _raise_on_error

[2021-10-13T07:47:56.028Z]     raise ExecutionError(

[2021-10-13T07:47:56.028Z] pants.engine.internals.scheduler.ExecutionError: 1 Exception encountered:

[2021-10-13T07:47:56.028Z] 

[2021-10-13T07:47:56.028Z] Engine traceback:

[2021-10-13T07:47:56.028Z]   in select

[2021-10-13T07:47:56.028Z]   in pants.core.goals.test.run_tests

[2021-10-13T07:47:56.028Z]   in pants.backend.python.goals.coverage_py.generate_coverage_reports

[2021-10-13T07:47:56.028Z]   in pants.engine.process.fallible_to_exec_result_or_raise

[2021-10-13T07:47:56.028Z] Traceback (most recent call last):

[2021-10-13T07:47:56.028Z]   File "/home/ocrolus/.cache/pants/setup/bootstrap-Linux-x86_64/2.6.1_py38/lib/python3.8/site-packages/pants/engine/process.py", line 258, in fallible_to_exec_result_or_raise

[2021-10-13T07:47:56.028Z]     raise ProcessExecutionFailure(

[2021-10-13T07:47:56.028Z] pants.engine.process.ProcessExecutionFailure: Process 'Generate Pytest report coverage report.' failed with exit code 1.

[2021-10-13T07:47:56.028Z] stdout:

[2021-10-13T07:47:56.028Z] No source for code: '/worker/build/416d340d8a2e7cf7/root/.cache/pex_root/venvs/5b7fe3b1b328d2677aa38f30067525814a069172/008b37cbe59aadadc25359cf6798a05a8af4bf19/lib/python3.8/site-packages/PIL/BmpImagePlugin.py'.

[2021-10-13T07:47:56.028Z] Aborting report output, consider using -i.

[2021-10-13T07:47:56.028Z] 

[2021-10-13T07:47:56.028Z] stderr:

[2021-10-13T07:47:56.028Z] 

[2021-10-13T07:47:56.028Z] 

[2021-10-13T07:47:56.028Z] 

[2021-10-13T07:47:56.028Z] (Use --no-process-execution-local-cleanup to inspect chroots and/or -ldebug for more logs. See <https://www.pantsbuild.org/v2.6/docs/troubleshooting> for common issues. Consider reaching out for help: <https://www.pantsbuild.org/v2.6/docs/getting-help.)>
pantsbuild/pants