33import json
44import logging
55import re
6- from typing import TYPE_CHECKING
6+ from typing import TYPE_CHECKING , Any
77
88from codeflash .models .models import FunctionTestInvocation , InvocationId , TestResults
99
1212 from pathlib import Path
1313
1414 from codeflash .models .models import TestFiles
15+ from codeflash .models .test_type import TestType
1516 from codeflash .verification .verification_utils import TestConfig
1617
1718logger = logging .getLogger (__name__ )
@@ -29,7 +30,7 @@ def parse_go_test_output(
2930 test_json_path : Path ,
3031 test_files : TestFiles ,
3132 test_config : TestConfig ,
32- run_result : subprocess .CompletedProcess | None = None ,
33+ run_result : subprocess .CompletedProcess [ str ] | None = None ,
3334) -> TestResults :
3435 test_results = TestResults ()
3536
@@ -71,10 +72,11 @@ def parse_go_test_output(
7172 active [test_name ] = _TestIteration (test_name = test_name , package = package )
7273 continue
7374
74- it = active .get (test_name )
75- if it is None :
76- it = _TestIteration (test_name = test_name , package = package )
77- active [test_name ] = it
75+ maybe_it = active .get (test_name )
76+ if maybe_it is None :
77+ maybe_it = _TestIteration (test_name = test_name , package = package )
78+ active [test_name ] = maybe_it
79+ it = maybe_it
7880
7981 if action == "output" :
8082 output_text = event .get ("Output" , "" )
@@ -109,9 +111,6 @@ def parse_go_test_output(
109111
110112 test_file_path = _resolve_test_file (it .test_name , it .package , test_files , base_dir )
111113 test_type = _resolve_test_type (test_file_path , test_files )
112- if test_type is None :
113- logger .debug ("Skipping test %s: could not resolve test type" , it .test_name )
114- continue
115114
116115 test_results .add (
117116 FunctionTestInvocation (
@@ -157,23 +156,20 @@ def __init__(self, test_name: str, package: str) -> None:
157156 self .stdout : str = ""
158157
159158
160- def _read_json_output (path : Path , run_result : subprocess .CompletedProcess | None ) -> str :
159+ def _read_json_output (path : Path , run_result : subprocess .CompletedProcess [ str ] | None ) -> str :
161160 try :
162161 content = path .read_text (encoding = "utf-8" )
163162 if content .strip ():
164163 return content
165164 except Exception :
166165 pass
167166 if run_result is not None :
168- stdout = run_result .stdout
169- if isinstance (stdout , bytes ):
170- stdout = stdout .decode ("utf-8" , errors = "replace" )
171- return stdout or ""
167+ return run_result .stdout or ""
172168 return ""
173169
174170
175- def _parse_json_lines (content : str ) -> list [dict ]:
176- events : list [dict ] = []
171+ def _parse_json_lines (content : str ) -> list [dict [ str , Any ] ]:
172+ events : list [dict [ str , Any ] ] = []
177173 for line in content .splitlines ():
178174 line = line .strip ()
179175 if not line :
@@ -199,7 +195,7 @@ def _resolve_test_file(test_name: str, package: str, test_files: TestFiles, base
199195 return base_dir / f"{ test_name } .go"
200196
201197
202- def _resolve_test_type (test_file_path : Path , test_files : TestFiles ):
198+ def _resolve_test_type (test_file_path : Path , test_files : TestFiles ) -> TestType :
203199 from codeflash .models .test_type import TestType
204200
205201 test_type = test_files .get_test_type_by_instrumented_file_path (test_file_path )
0 commit comments