Skip to content

Commit 3adae9b

Browse files
committed
COVERAGE_ONE_TRACER runs just one tracer
It chooses the appropriate tracer based on the implementation.
1 parent 0ac78b4 commit 3adae9b

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

igor.py

+21-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222

2323
import pytest
2424

25+
# Contants derived the same as in coverage/env.py. We can't import
26+
# that file here, it would be evaluated too early and not get the
27+
# settings we make in this file.
28+
29+
CPYTHON = (platform.python_implementation() == "CPython")
30+
PYPY = (platform.python_implementation() == "PyPy")
2531

2632
@contextlib.contextmanager
2733
def ignore_warnings():
@@ -73,7 +79,18 @@ def label_for_tracer(tracer):
7379

7480
def should_skip(tracer):
7581
"""Is there a reason to skip these tests?"""
76-
if tracer == "py":
82+
skipper = ""
83+
84+
# $set_env.py: COVERAGE_ONE_TRACER - Only run tests for one tracer.
85+
only_one = os.environ.get("COVERAGE_ONE_TRACER")
86+
if only_one:
87+
if CPYTHON:
88+
if tracer == "py":
89+
skipper = "Only one tracer: no Python tracer for CPython"
90+
else:
91+
if tracer == "c":
92+
skipper = "No C tracer for {}".format(platform.python_implementation())
93+
elif tracer == "py":
7794
# $set_env.py: COVERAGE_NO_PYTRACER - Don't run the tests under the Python tracer.
7895
skipper = os.environ.get("COVERAGE_NO_PYTRACER")
7996
else:
@@ -94,7 +111,7 @@ def make_env_id(tracer):
94111
"""An environment id that will keep all the test runs distinct."""
95112
impl = platform.python_implementation().lower()
96113
version = "%s%s" % sys.version_info[:2]
97-
if '__pypy__' in sys.builtin_module_names:
114+
if PYPY:
98115
version += "_%s%s" % sys.pypy_version_info[:2]
99116
env_id = "%s%s_%s" % (impl, version, tracer)
100117
return env_id
@@ -108,6 +125,7 @@ def run_tests(tracer, *runner_args):
108125
if 'COVERAGE_ENV_ID' in os.environ:
109126
os.environ['COVERAGE_ENV_ID'] = make_env_id(tracer)
110127
print_banner(label_for_tracer(tracer))
128+
111129
return pytest.main(list(runner_args))
112130

113131

@@ -325,7 +343,7 @@ def print_banner(label):
325343

326344
version = platform.python_version()
327345

328-
if '__pypy__' in sys.builtin_module_names:
346+
if PYPY:
329347
version += " (pypy %s)" % ".".join(str(v) for v in sys.pypy_version_info)
330348

331349
rev = platform.python_revision()

0 commit comments

Comments
 (0)