Skip to content

Commit 6fa2fb3

Browse files
committed
update dependencies for jest-runner used in loop runner
1 parent e9eaa47 commit 6fa2fb3

4 files changed

Lines changed: 2724 additions & 156 deletions

File tree

codeflash/verification/parse_test_output.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -737,9 +737,10 @@ def parse_jest_test_xml(
737737

738738
# Find matching timing markers for this test
739739
# Jest test names in markers are sanitized by codeflash-jest-helper's sanitizeTestId()
740-
# which replaces: !#:$ and whitespace with underscores
740+
# which replaces: !#: (space) ()[]{}|\/*?^$.+- with underscores
741741
# IMPORTANT: Must match Jest helper's sanitization exactly for marker matching to work
742-
sanitized_test_name = re.sub(r"[!#:$\s]+", "_", test_name)
742+
# Pattern from capture.js: /[!#: ()\[\]{}|\\/*?^$.+\-]/g
743+
sanitized_test_name = re.sub(r"[!#: ()\[\]{}|\\/*?^$.+\-]", "_", test_name)
743744
matching_starts = [m for m in start_matches if sanitized_test_name in m.group(2)]
744745

745746
# For performance tests (capturePerf), there are no START markers - only END markers with duration
@@ -1108,12 +1109,15 @@ def merge_test_results(
11081109
# This means that we only have one FunctionTestInvocation for this test xml. Match them to the bin results
11091110
# Either a whole test function fails or passes.
11101111
for result_bin in bin_results:
1112+
# Prefer XML runtime (from stdout markers) if bin runtime is None/0
1113+
# This is important for Jest perf tests which output timing to stdout, not SQLite
1114+
merged_runtime = result_bin.runtime if result_bin.runtime else xml_result.runtime
11111115
merged_test_results.add(
11121116
FunctionTestInvocation(
11131117
loop_index=xml_result.loop_index,
11141118
id=result_bin.id,
11151119
file_name=xml_result.file_name,
1116-
runtime=result_bin.runtime,
1120+
runtime=merged_runtime,
11171121
test_framework=xml_result.test_framework,
11181122
did_pass=xml_result.did_pass,
11191123
test_type=xml_result.test_type,
@@ -1136,19 +1140,22 @@ def merge_test_results(
11361140
if bin_result is None:
11371141
merged_test_results.add(xml_result)
11381142
continue
1143+
# Prefer XML runtime (from stdout markers) if bin runtime is None/0
1144+
# This is important for Jest perf tests which output timing to stdout, not SQLite
1145+
merged_runtime = bin_result.runtime if bin_result.runtime else xml_result.runtime
11391146
merged_test_results.add(
11401147
FunctionTestInvocation(
11411148
loop_index=xml_result.loop_index,
11421149
id=xml_result.id,
11431150
file_name=xml_result.file_name,
1144-
runtime=bin_result.runtime,
1151+
runtime=merged_runtime,
11451152
test_framework=xml_result.test_framework,
11461153
did_pass=bin_result.did_pass,
11471154
test_type=xml_result.test_type,
11481155
return_value=bin_result.return_value,
11491156
timed_out=xml_result.timed_out
1150-
if bin_result.runtime is None
1151-
else False, # If runtime was measured in the bin file, then the testcase did not time out
1157+
if merged_runtime is None
1158+
else False, # If runtime was measured, then the testcase did not time out
11521159
verification_type=VerificationType(bin_result.verification_type)
11531160
if bin_result.verification_type
11541161
else None,
@@ -1165,12 +1172,15 @@ def merge_test_results(
11651172
if xml_result is None:
11661173
merged_test_results.add(bin_result)
11671174
continue
1175+
# Prefer XML runtime (from stdout markers) if bin runtime is None/0
1176+
# This is important for Jest perf tests which output timing to stdout, not SQLite
1177+
merged_runtime = bin_result.runtime if bin_result.runtime else xml_result.runtime
11681178
merged_test_results.add(
11691179
FunctionTestInvocation(
11701180
loop_index=bin_result.loop_index,
11711181
id=bin_result.id,
11721182
file_name=bin_result.file_name,
1173-
runtime=bin_result.runtime,
1183+
runtime=merged_runtime,
11741184
test_framework=bin_result.test_framework,
11751185
did_pass=bin_result.did_pass,
11761186
test_type=bin_result.test_type,

0 commit comments

Comments
 (0)