Skip to content

Commit 1c62fcd

Browse files
committed
Prevent coverage reporting issues in tmp dir
Pytorch generates some python files in the tmp dir and executes them; coverage then fails due to not being able to find the source files. We pass a flag to omit the tmp dir from coverage reporting. Commit: 6ff10ae Branch: https://github.com/bazeltools/rules_python/tree/patch-tmp-coverage-1.6.1 This approach is from the discussion in bazel-contrib#2599 (comment)
1 parent 38f2679 commit 1c62fcd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

python/private/python_bootstrap_template.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,11 @@ source =
471471
kparams['stdout'] = sys.stderr
472472
kparams['stderr'] = sys.stderr
473473

474+
# Prevent coveragepy report issues when packages execute files in tmp dir.
475+
import tempfile
476+
omit_pattern = os.path.join(tempfile.gettempdir(), "*")
477+
params.append(f'--omit={omit_pattern}')
478+
474479
lcov_ret_code = subprocess.call(
475480
params,
476481
**kparams

0 commit comments

Comments
 (0)