Use the VM slug as the code coverage default context

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2023-08-29 17:16:47 +01:00 committed by Megan Wilhite
parent 0441daca90
commit 5ed925ea5e
2 changed files with 6 additions and 0 deletions

View file

@ -1053,12 +1053,16 @@ def _pytest(session, coverage, cmd_args, env=None):
return
if coverage is True:
_coverage_cmd_args = []
if "COVERAGE_CONTEXT" in os.environ:
_coverage_cmd_args.append(f"--context={os.environ['COVERAGE_CONTEXT']}")
_run_with_coverage(
session,
"python",
"-m",
"coverage",
"run",
*_coverage_cmd_args,
"-m",
"pytest",
*args,
@ -1361,6 +1365,7 @@ def create_html_coverage_report(session):
"-d",
str(COVERAGE_OUTPUT_DIR.joinpath("html").relative_to(REPO_ROOT)),
"--include=salt/*,tests/*",
"--show-contexts",
env=env,
)

View file

@ -311,6 +311,7 @@ def test(
"PRINT_TEST_PLAN_ONLY": "0",
"SKIP_INITIAL_ONEDIR_FAILURES": "1",
"SKIP_INITIAL_GH_ACTIONS_FAILURES": "1",
"COVERAGE_CONTEXT": name,
}
if "LANG" in os.environ:
env["LANG"] = os.environ["LANG"]