Skip to content

Commit 8b2f948

Browse files
committed
seems to be working
1 parent 26f48b6 commit 8b2f948

File tree

1 file changed

+35
-23
lines changed

1 file changed

+35
-23
lines changed

codeflash/verification/parse_test_output.py

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def parse_func(file_path: Path) -> XMLParser:
3636
return parse(file_path, xml_parser)
3737

3838

39-
matches_re = re.compile(r"!######(.*?):(.*?)([^\.:]*?):(.*?):(.*?):(.*?)######!")
40-
stdout_re = re.compile(r"!\$######.*?######\$!\n(.*)!######.*?######!", re.DOTALL)
39+
matches_re_start = re.compile(r"!\$######(.*?):(.*?)([^\.:]*?):(.*?):(.*?):(.*?)######\$!\n")
40+
matches_re_end = re.compile(r"!######(.*?):(.*?)([^\.:]*?):(.*?):(.*?):(.*?)######!")
4141

4242

4343
def parse_test_return_values_bin(file_location: Path, test_files: TestFiles, test_config: TestConfig) -> TestResults:
@@ -265,14 +265,16 @@ def parse_test_xml(
265265
timed_out = True
266266

267267
sys_stdout = testcase.system_out or ""
268-
matches = matches_re.findall(sys_stdout)
269-
270-
if sys_stdout:
271-
print("sys_stdout: ", sys_stdout)
272-
stdout_match = stdout_re.search(sys_stdout)
273-
sys_stdout = stdout_match.group(1) if stdout_match else ""
274-
275-
if not matches or not len(matches):
268+
begin_matches = [match for match in matches_re_start.finditer(sys_stdout)]
269+
end_matches = {}
270+
for match in matches_re_end.finditer(sys_stdout):
271+
groups = match.groups()
272+
if len(groups[5].split(":")) > 1:
273+
iteration_id = groups[5].split(":")[0]
274+
groups = groups[:5] + (iteration_id,)
275+
end_matches[groups] = match
276+
277+
if not begin_matches or not begin_matches:
276278
test_results.add(
277279
FunctionTestInvocation(
278280
loop_index=loop_index,
@@ -290,26 +292,36 @@ def parse_test_xml(
290292
test_type=test_type,
291293
return_value=None,
292294
timed_out=timed_out,
293-
stdout=sys_stdout,
295+
stdout="",
294296
)
295297
)
296298

297299
else:
298-
for match in matches:
299-
split_val = match[5].split(":")
300-
if len(split_val) > 1:
301-
iteration_id = split_val[0]
302-
runtime = int(split_val[1])
300+
for match_index, match in enumerate(begin_matches):
301+
groups = match.groups()
302+
end_match = end_matches.get(groups)
303+
iteration_id, runtime = groups[5], None
304+
if end_match:
305+
stdout = sys_stdout[match.end() : end_match.start()]
306+
split_val = end_match.groups()[5].split(":")
307+
if len(split_val) > 1:
308+
iteration_id = split_val[0]
309+
runtime = int(split_val[1])
310+
else:
311+
iteration_id, runtime = split_val[0], None
312+
elif match_index == len(begin_matches) - 1:
313+
stdout = sys_stdout[match.end() :]
303314
else:
304-
iteration_id, runtime = split_val[0], None
315+
stdout = sys_stdout[match.end() : begin_matches[match_index + 1].start()]
316+
305317
test_results.add(
306318
FunctionTestInvocation(
307-
loop_index=int(match[4]),
319+
loop_index=int(groups[4]),
308320
id=InvocationId(
309-
test_module_path=match[0],
310-
test_class_name=None if match[1] == "" else match[1][:-1],
311-
test_function_name=match[2],
312-
function_getting_tested=match[3],
321+
test_module_path=groups[0],
322+
test_class_name=None if groups[1] == "" else groups[1][:-1],
323+
test_function_name=groups[2],
324+
function_getting_tested=groups[3],
313325
iteration_id=iteration_id,
314326
),
315327
file_name=test_file_path,
@@ -319,7 +331,7 @@ def parse_test_xml(
319331
test_type=test_type,
320332
return_value=None,
321333
timed_out=timed_out,
322-
stdout=sys_stdout,
334+
stdout=stdout,
323335
)
324336
)
325337

0 commit comments

Comments
 (0)