Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Sep 1, 2024
1 parent 7ea9f9a commit d86e46e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion coverage/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def _init_for_start(self) -> None:

self._core = Core(
warn=self._warn,
timid=self.config.timid,
config=self.config,
metacov=self._metacov,
)
self._collector = Collector(
Expand Down
16 changes: 6 additions & 10 deletions coverage/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from typing import Any

from coverage import env
from coverage.config import CoverageConfig
from coverage.disposition import FileDisposition
from coverage.exceptions import ConfigError
from coverage.pytracer import PyTracer
Expand Down Expand Up @@ -49,16 +50,9 @@ class Core:
packed_arcs: bool
systrace: bool

def __init__(self,
warn: TWarnFn,
timid: bool,
metacov: bool,
) -> None:
# Defaults
self.tracer_kwargs = {}

def __init__(self, warn: TWarnFn, config: CoverageConfig, metacov: bool) -> None:
core_name: str | None
if timid:
if config.timid:
core_name = "pytrace"
else:
core_name = os.getenv("COVERAGE_CORE")
Expand All @@ -76,9 +70,11 @@ def __init__(self,
else:
core_name = "pytrace"

self.tracer_kwargs = {}

if core_name == "sysmon":
self.tracer_class = SysMonitor
self.tracer_kwargs = {"tool_id": 3 if metacov else 1}
self.tracer_kwargs["tool_id"] = 3 if metacov else 1
self.file_disposition_class = FileDisposition
self.supports_plugins = False
self.packed_arcs = False
Expand Down
6 changes: 6 additions & 0 deletions coverage/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ class PYBEHAVIOR:
# https://github.com/python/cpython/issues/113728
lasti_is_yield = (PYVERSION[:2] != (3, 13))

# Does sys.monitoring support BRANCH_TAKEN?
branch_taken = (
pep669 and
hasattr(sys.monitoring.events, "BRANCH_TAKEN") # type:ignore[attr-defined]
)


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

Expand Down
6 changes: 4 additions & 2 deletions coverage/sysmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
cast,
)

from coverage import env
from coverage.debug import short_filename, short_stack
from coverage.types import (
AnyCallable,
Expand Down Expand Up @@ -352,8 +353,9 @@ def sysmon_py_start(self, code: CodeType, instruction_offset: int) -> MonitorRet
#
| events.PY_RESUME
# | events.PY_YIELD
| events.LINE,
# | events.BRANCH
| events.LINE
| events.BRANCH_TAKEN
| events.BRANCH_NOT_TAKEN
# | events.JUMP
)
self.local_event_codes[id(code)] = code
Expand Down

0 comments on commit d86e46e

Please sign in to comment.