Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions python/private/py_executable.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ def _create_stage2_bootstrap(
"%venv_rel_site_packages%": venv.venv_site_packages,
"%venv_root%": venv.venv_root,
"%workspace_name%": ctx.workspace_name,
"%coverage_instrumented%": str(int(ctx.configuration.coverage_enabled and ctx.coverage_instrumented())),
},
is_executable = True,
)
Expand Down
6 changes: 6 additions & 0 deletions python/private/stage2_bootstrap_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
# string otherwise.
VENV_SITE_PACKAGES = "%venv_rel_site_packages%"

# Whether we should generate coverage data.
COVERAGE_INSTRUMENTED = "%coverage_instrumented%" == "1"

# ===== Template substitutions end =====


Expand Down Expand Up @@ -319,11 +322,14 @@ def _maybe_collect_coverage(enable):
# We need for coveragepy to use relative paths. This can only be configured
# using an rc file.
rcfile_name = os.path.join(coverage_dir, ".coveragerc_{}".format(unique_id))
disable_warnings = ('disable_warnings = module-not-imported, no-data-collected'
if COVERAGE_INSTRUMENTED else '')
print_verbose_coverage("coveragerc file:", rcfile_name)
with open(rcfile_name, "w") as rcfile:
rcfile.write(
f"""[run]
relative_files = True
{disable_warnings}
source =
\t{source}
"""
Expand Down