Skip to content

Commit 50394b1

Browse files
committed
keep find_objects defined within main
1 parent 8973006 commit 50394b1

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

scripts/gen_coverage.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -170,25 +170,6 @@ def parse_args():
170170
return p.parse_args()
171171

172172

173-
def find_objects(setup_dir):
174-
objects = []
175-
sfx_regexp = sysconfig.get_config_var("EXT_SUFFIX").replace(".", r"\.")
176-
regexp1 = re.compile(r"^_tensor_.*impl" + sfx_regexp)
177-
regexp2 = re.compile(r"^^_device_queries" + sfx_regexp)
178-
179-
def is_py_ext(fn):
180-
return re.match(regexp1, fn) or re.match(regexp2, fn)
181-
182-
for root, _, files in os.walk(os.path.join(setup_dir, "dpctl")):
183-
for file in files:
184-
if not file.endswith(".so"):
185-
continue
186-
if is_py_ext(file) or "DPCTLSyclInterface" in file:
187-
objects.extend(["-object", os.path.join(root, file)])
188-
print("[gen_coverage] Using objects:", objects)
189-
return objects
190-
191-
192173
def main():
193174
is_linux = "linux" in sys.platform
194175
if not is_linux:
@@ -290,7 +271,27 @@ def main():
290271
]
291272
run(pytest_cmd, env=env, cwd=setup_dir)
292273

293-
objects = find_objects(setup_dir)
274+
def find_objects():
275+
objects = []
276+
sfx_regexp = sysconfig.get_config_var("EXT_SUFFIX").replace(
277+
".", r"\."
278+
)
279+
regexp1 = re.compile(r"^_tensor_.*impl" + sfx_regexp)
280+
regexp2 = re.compile(r"^^_device_queries" + sfx_regexp)
281+
282+
def is_py_ext(fn):
283+
return re.match(regexp1, fn) or re.match(regexp2, fn)
284+
285+
for root, _, files in os.walk("dpctl"):
286+
for file in files:
287+
if not file.endswith(".so"):
288+
continue
289+
if is_py_ext(file) or "DPCTLSyclInterface" in file:
290+
objects.extend(["-object", os.path.join(root, file)])
291+
print("Using objects: ", objects)
292+
return objects
293+
294+
objects = find_objects()
294295
instr_profile_fn = "dpctl_pytest.profdata"
295296

296297
run(

0 commit comments

Comments
 (0)