Skip to content

Commit 64034e6

Browse files
committed
wip: switch from BRANCH_TAKEN to BRANCH_RIGHT
1 parent f3aede0 commit 64034e6

File tree

8 files changed

+274
-167
lines changed

8 files changed

+274
-167
lines changed

coverage/control.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ def _init_for_start(self) -> None:
534534

535535
self._core = Core(
536536
warn=self._warn,
537-
timid=self.config.timid,
537+
config=self.config,
538538
metacov=self._metacov,
539539
)
540540
self._collector = Collector(

coverage/core.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from typing import Any
1111

1212
from coverage import env
13+
from coverage.config import CoverageConfig
1314
from coverage.disposition import FileDisposition
1415
from coverage.exceptions import ConfigError
1516
from coverage.misc import isolate_module
@@ -52,16 +53,9 @@ class Core:
5253
packed_arcs: bool
5354
systrace: bool
5455

55-
def __init__(self,
56-
warn: TWarnFn,
57-
timid: bool,
58-
metacov: bool,
59-
) -> None:
60-
# Defaults
61-
self.tracer_kwargs = {}
62-
56+
def __init__(self, warn: TWarnFn, config: CoverageConfig, metacov: bool) -> None:
6357
core_name: str | None
64-
if timid:
58+
if config.timid:
6559
core_name = "pytrace"
6660
else:
6761
core_name = os.getenv("COVERAGE_CORE")
@@ -70,6 +64,13 @@ def __init__(self,
7064
warn("sys.monitoring isn't available, using default core", slug="no-sysmon")
7165
core_name = None
7266

67+
# if core_name == "sysmon" and config.branch and not env.PYBEHAVIOR.branch_right_left:
68+
# warn(
69+
# "sys.monitoring can't yet measure branches well, using default core",
70+
# slug="no-sysmon",
71+
# )
72+
# core_name = None
73+
7374
if not core_name:
7475
# Once we're comfortable with sysmon as a default:
7576
# if env.PYBEHAVIOR.pep669 and self.should_start_context is None:
@@ -79,9 +80,11 @@ def __init__(self,
7980
else:
8081
core_name = "pytrace"
8182

83+
self.tracer_kwargs = {}
84+
8285
if core_name == "sysmon":
8386
self.tracer_class = SysMonitor
84-
self.tracer_kwargs = {"tool_id": 3 if metacov else 1}
87+
self.tracer_kwargs["tool_id"] = 3 if metacov else 1
8588
self.file_disposition_class = FileDisposition
8689
self.supports_plugins = False
8790
self.packed_arcs = False

coverage/env.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ class PYBEHAVIOR:
156156
# PEP649 and PEP749: Deferred annotations
157157
deferred_annotations = (PYVERSION >= (3, 14))
158158

159+
# Does sys.monitoring support BRANCH_RIGHT and BRANCH_LEFT?
160+
branch_right_left = (
161+
pep669 and
162+
hasattr(sys.monitoring.events, "BRANCH_RIGHT") # type:ignore[attr-defined,unused-ignore]
163+
)
164+
159165

160166
# Coverage.py specifics, about testing scenarios. See tests/testenv.py also.
161167

0 commit comments

Comments
 (0)