Skip to content

Commit dac8a5f

Browse files
ewiandaaignas
andauthored
fix: Exclude external directory when generating python report (#2136)
This PR will reduce the time it take to run `bazel coverage` *Before this fix,* ``` bazel coverage --cache_test_results=no //... Elapsed time: 7.054s, Critical Path: 6.87s ``` [lcov --list bazel-out/_coverage/_coverage_report.dat](https://github.com/user-attachments/files/16681828/lcov.log) *After* ``` bazel coverage --cache_test_results=no //... Elapsed time: 2.474s, Critical Path: 1.18s $ lcov --list bazel-out/_coverage/_coverage_report.dat Reading tracefile bazel-out/_coverage/_coverage_report.dat |Lines |Functions |Branches Filename |Rate Num|Rate Num|Rate Num ================================================================================ [/home/ewianda/.cache/bazel/_bazel_ewianda/da4b4cc49e0e621570c9e24d6f1eab95/execroot/_main/bazel-out/k8-fastbuild/bin/benchsci/ml/nlp/] test_tokenizer_stage2_bootstrap.py | 6.0% 250| - 0| - 0 [benchsci/] devtools/python/pytest_helper.py |90.5% 21| - 0| - 0 ml/nlp/test_tokenizer.py | 100% 13| - 0| - 0 ml/nlp/tokenizer.py |61.8% 76| - 0| - 0 ================================================================================ Total:|26.1% 360| - 0| - 0 ``` Related to #1434 --------- Co-authored-by: aignas <[email protected]>
1 parent 04e2f32 commit dac8a5f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ A brief description of the categories of changes:
2929

3030
### Fixed
3131
* (gazelle): Fix incorrect use of `t.Fatal`/`t.Fatalf` in tests.
32+
* (toolchain) Omit third-party python packages from coverage reports from
33+
stage2 bootstrap template.
3234

3335
### Added
3436
* Nothing yet

python/private/stage2_bootstrap_template.py

+8
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,14 @@ def _maybe_collect_coverage(enable):
364364
# Pipes can't be read back later, which can cause coverage to
365365
# throw an error when trying to get its source code.
366366
"/dev/fd/*",
367+
# The mechanism for finding third-party packages in coverage-py
368+
# only works for installed packages, not for runfiles. e.g:
369+
#'$HOME/.local/lib/python3.10/site-packages',
370+
# '/usr/lib/python',
371+
# '/usr/lib/python3.10/site-packages',
372+
# '/usr/local/lib/python3.10/dist-packages'
373+
# see https://github.com/nedbat/coveragepy/blob/bfb0c708fdd8182b2a9f0fc403596693ef65e475/coverage/inorout.py#L153-L164
374+
"*/external/*",
367375
],
368376
)
369377
cov.start()

0 commit comments

Comments
 (0)