Skip to content

Commit d5b48c7

Browse files
committed
key: remove COVERAGE_PROCESS_START during meta
1 parent 4c2dc7c commit d5b48c7

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ clean: debug_clean _clean_platform ## Remove artifacts of test execution, instal
4141
@rm -f */.coverage */*/.coverage */*/*/.coverage */*/*/*/.coverage */*/*/*/*/.coverage */*/*/*/*/*/.coverage
4242
@rm -f tests/covmain.zip tests/zipmods.zip tests/zip1.zip
4343
@rm -rf doc/_build doc/_spell doc/sample_html_beta
44-
@rm -rf tmp
44+
@rm -rf tmp /tmp/foo.out
4545
@rm -rf .*cache */.*cache */*/.*cache */*/*/.*cache .hypothesis
4646
@rm -rf tests/actual
4747
@-make -C tests/gold/html clean

coverage/control.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ def _init_for_start(self) -> None:
584584

585585
self._core = Core(
586586
warn=self._warn,
587+
debug=(self._debug if self._debug.should("core") else None),
587588
config=self.config,
588589
dynamic_contexts=(should_start_context is not None),
589590
metacov=self._metacov,

coverage/core.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from coverage.misc import isolate_module
1717
from coverage.pytracer import PyTracer
1818
from coverage.sysmon import SysMonitor
19-
from coverage.types import TFileDisposition, Tracer, TWarnFn
19+
from coverage.types import TDebugCtl, TFileDisposition, Tracer, TWarnFn
2020

2121
os = isolate_module(os)
2222

@@ -56,17 +56,18 @@ class Core:
5656

5757
def __init__(
5858
self,
59+
*,
5960
warn: TWarnFn,
61+
debug: TDebugCtl | None,
6062
config: CoverageConfig,
6163
dynamic_contexts: bool,
6264
metacov: bool,
6365
) -> None:
64-
# print("core.py!!!")
65-
# print(f"sys.path = {newline}{newline.join(sys.path)}")
66-
# print(f"{CTRACER_FILE = }")
67-
# import inspect
68-
#
69-
# print("\n".join("%30s : %s:%d" % (t[3], t[1], t[2]) for t in inspect.stack()[99:0:-1]))
66+
def _debug(msg: str) -> None:
67+
if debug:
68+
debug.write(msg)
69+
70+
_debug("in core.py")
7071

7172
# Check the conditions that preclude us from using sys.monitoring.
7273
reason_no_sysmon = ""
@@ -82,31 +83,34 @@ def __init__(
8283
core_name: str | None = None
8384
if config.timid:
8485
core_name = "pytrace"
85-
# print("core.py: Using pytrace because timid=True")
86+
_debug("core.py: Using pytrace because timid=True")
8687
elif core_name is None:
8788
# This could still leave core_name as None.
8889
core_name = config.core
89-
# print(f"core.py: core from config is {core_name!r}")
90+
_debug(f"core.py: core from config is {core_name!r}")
9091

9192
if core_name == "sysmon" and reason_no_sysmon:
93+
_debug(f"core.py: raising ConfigError because sysmon not usable: {reason_no_sysmon}")
9294
raise ConfigError(
9395
f"Can't use core=sysmon: sys.monitoring {reason_no_sysmon}", skip_tests=True
9496
)
9597

9698
if core_name is None:
9799
if env.SYSMON_DEFAULT and not reason_no_sysmon:
98100
core_name = "sysmon"
99-
# print("core.py: Using sysmon because SYSMON_DEFAULT is set")
101+
_debug("core.py: Using sysmon because SYSMON_DEFAULT is set")
100102
else:
101103
core_name = "ctrace"
102-
# print("core.py: Defaulting to ctrace core")
104+
_debug("core.py: Defaulting to ctrace core")
103105

104106
if core_name == "ctrace":
105107
if not CTRACER_FILE:
106108
if IMPORT_ERROR and env.SHIPPING_WHEELS:
107109
warn(f"Couldn't import C tracer: {IMPORT_ERROR}", slug="no-ctracer", once=True)
108110
core_name = "pytrace"
109-
# print("core.py: Falling back to pytrace because C tracer not available")
111+
_debug("core.py: Falling back to pytrace because C tracer not available")
112+
113+
_debug(f"core.py: Using core={core_name}")
110114

111115
self.tracer_kwargs = {}
112116

igor.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ def run_tests_with_coverage(core, *runner_args):
207207
cov._warn_unimported_source = False
208208
cov._warn_preimported_source = False
209209
cov._metacov = True
210-
# print(f"igor start()")
211210
cov.start()
212211

213212
try:
@@ -224,7 +223,10 @@ def run_tests_with_coverage(core, *runner_args):
224223
covmods[name] = mod
225224
del sys.modules[name]
226225
hidden = hide_extension(core)
227-
# print("igor: re-importing coverage")
226+
227+
# Remove the reference to metacov.ini.
228+
del os.environ["COVERAGE_PROCESS_START"]
229+
228230
import coverage # pylint: disable=reimported
229231

230232
sys.modules.update(covmods)

0 commit comments

Comments
 (0)