Skip to content

Commit 83437db

Browse files
committed
[None][test] CBTS coverage: attribute inner unittest coverage to its entry
Nested inner pytests spawned by test_unittests_v2 run as pytest-main, so sitecustomize skipped the CBTS_TEST_ID context switch and their in-process coverage drained to the empty context. Switch context from CBTS_TEST_ID for nested inner pytests too, attributing their coverage to the test-db entry without loading cbts_plugin in the inner pytest. Signed-off-by: Ivy Zhang <25222398+crazydemo@users.noreply.github.com>
1 parent dd70f53 commit 83437db

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

jenkins/scripts/cbts/coverage_utils/sitecustomize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ def _final_save():
9292
name="cbts-periodic-save",
9393
).start()
9494

95-
# In worker processes, attribute coverage to the current test via the CBTS_TEST_ID env var and a polled marker file.
95+
# In worker processes and nested inner pytests, attribute coverage to the current test via the CBTS_TEST_ID env var.
9696
_initial_nodeid = os.environ.get("CBTS_TEST_ID", "").strip()
97-
if _initial_nodeid and not _is_pytest_main:
97+
if _initial_nodeid and (not _is_pytest_main or _is_nested_pytest):
9898
with _cov_lock:
9999
cov.switch_context(_initial_nodeid)
100100

0 commit comments

Comments
 (0)