@@ -103,38 +103,43 @@ def do_remove_extension(*args):
103
103
print (f"Couldn't remove { filename } : { exc } " )
104
104
105
105
106
- def label_for_tracer ( tracer ):
106
+ def label_for_core ( core ):
107
107
"""Get the label for these tests."""
108
- if tracer == "py" :
109
- label = "with Python tracer"
108
+ if core == "pytrace" :
109
+ return "with Python tracer"
110
+ elif core == "ctrace" :
111
+ return "with C tracer"
112
+ elif core == "sysmon" :
113
+ return "with sys.monitoring"
110
114
else :
111
- label = "with C tracer"
115
+ raise ValueError ( f"Bad core: { core !r } " )
112
116
113
- return label
114
117
115
-
116
- def should_skip (tracer ):
118
+ def should_skip (core ):
117
119
"""Is there a reason to skip these tests?"""
118
120
skipper = ""
119
121
120
- # $set_env.py: COVERAGE_ONE_TRACER - Only run tests for one tracer .
121
- only_one = os .environ .get ("COVERAGE_ONE_TRACER " )
122
+ # $set_env.py: COVERAGE_ONE_CORE - Only run tests for one core .
123
+ only_one = os .environ .get ("COVERAGE_ONE_CORE " )
122
124
if only_one :
123
125
if CPYTHON :
124
- if tracer == "py" :
125
- skipper = "Only one tracer: no Python tracer for CPython"
126
+ if sys .version_info >= (3 , 12 ):
127
+ if core != "sysmon" :
128
+ skipper = f"Only one core: not running { core } "
129
+ elif core != "ctrace" :
130
+ skipper = f"Only one core: not running { core } "
126
131
else :
127
- if tracer == "c " :
128
- skipper = f"No C tracer for { platform .python_implementation ()} "
129
- elif tracer == "py " :
132
+ if core != "pytrace " :
133
+ skipper = f"No C core for { platform .python_implementation ()} "
134
+ elif core == "pytrace " :
130
135
# $set_env.py: COVERAGE_NO_PYTRACER - Don't run the tests under the Python tracer.
131
136
skipper = os .environ .get ("COVERAGE_NO_PYTRACER" )
132
137
else :
133
138
# $set_env.py: COVERAGE_NO_CTRACER - Don't run the tests under the C tracer.
134
139
skipper = os .environ .get ("COVERAGE_NO_CTRACER" )
135
140
136
141
if skipper :
137
- msg = "Skipping tests " + label_for_tracer ( tracer )
142
+ msg = "Skipping tests " + label_for_core ( core )
138
143
if len (skipper ) > 1 :
139
144
msg += ": " + skipper
140
145
else :
@@ -143,26 +148,26 @@ def should_skip(tracer):
143
148
return msg
144
149
145
150
146
- def make_env_id (tracer ):
151
+ def make_env_id (core ):
147
152
"""An environment id that will keep all the test runs distinct."""
148
153
impl = platform .python_implementation ().lower ()
149
154
version = "%s%s" % sys .version_info [:2 ]
150
155
if PYPY :
151
156
version += "_%s%s" % sys .pypy_version_info [:2 ]
152
- env_id = f"{ impl } { version } _{ tracer } "
157
+ env_id = f"{ impl } { version } _{ core } "
153
158
return env_id
154
159
155
160
156
- def run_tests (tracer , * runner_args ):
161
+ def run_tests (core , * runner_args ):
157
162
"""The actual running of tests."""
158
163
if "COVERAGE_TESTING" not in os .environ :
159
164
os .environ ["COVERAGE_TESTING" ] = "True"
160
- print_banner (label_for_tracer ( tracer ))
165
+ print_banner (label_for_core ( core ))
161
166
162
167
return pytest .main (list (runner_args ))
163
168
164
169
165
- def run_tests_with_coverage (tracer , * runner_args ):
170
+ def run_tests_with_coverage (core , * runner_args ):
166
171
"""Run tests, but with coverage."""
167
172
# Need to define this early enough that the first import of env.py sees it.
168
173
os .environ ["COVERAGE_TESTING" ] = "True"
@@ -172,7 +177,7 @@ def run_tests_with_coverage(tracer, *runner_args):
172
177
if context :
173
178
if context [0 ] == "$" :
174
179
context = os .environ [context [1 :]]
175
- os .environ ["COVERAGE_CONTEXT" ] = context + "." + tracer
180
+ os .environ ["COVERAGE_CONTEXT" ] = context + "." + core
176
181
177
182
# Create the .pth file that will let us measure coverage in sub-processes.
178
183
# The .pth file seems to have to be alphabetically after easy-install.pth
@@ -183,7 +188,7 @@ def run_tests_with_coverage(tracer, *runner_args):
183
188
with open (pth_path , "w" ) as pth_file :
184
189
pth_file .write ("import coverage; coverage.process_startup()\n " )
185
190
186
- suffix = f"{ make_env_id (tracer )} _{ platform .platform ()} "
191
+ suffix = f"{ make_env_id (core )} _{ platform .platform ()} "
187
192
os .environ ["COVERAGE_METAFILE" ] = os .path .abspath (".metacov." + suffix )
188
193
189
194
import coverage
@@ -211,7 +216,7 @@ def run_tests_with_coverage(tracer, *runner_args):
211
216
sys .modules .update (covmods )
212
217
213
218
# Run tests, with the arguments from our command line.
214
- status = run_tests (tracer , * runner_args )
219
+ status = run_tests (core , * runner_args )
215
220
216
221
finally :
217
222
cov .stop ()
@@ -240,19 +245,19 @@ def do_combine_html():
240
245
cov .html_report (show_contexts = show_contexts )
241
246
242
247
243
- def do_test_with_tracer ( tracer , * runner_args ):
244
- """Run tests with a particular tracer ."""
248
+ def do_test_with_core ( core , * runner_args ):
249
+ """Run tests with a particular core ."""
245
250
# If we should skip these tests, skip them.
246
- skip_msg = should_skip (tracer )
251
+ skip_msg = should_skip (core )
247
252
if skip_msg :
248
253
print (skip_msg )
249
254
return None
250
255
251
- os .environ ["COVERAGE_TEST_TRACER " ] = tracer
256
+ os .environ ["COVERAGE_CORE " ] = core
252
257
if os .environ .get ("COVERAGE_COVERAGE" , "no" ) == "yes" :
253
- return run_tests_with_coverage (tracer , * runner_args )
258
+ return run_tests_with_coverage (core , * runner_args )
254
259
else :
255
- return run_tests (tracer , * runner_args )
260
+ return run_tests (core , * runner_args )
256
261
257
262
258
263
def do_zip_mods ():
0 commit comments