@@ -50,78 +50,56 @@ def parse_test_return_values_bin(file_location: Path, test_files: TestFiles, tes
5050 return test_results
5151
5252 with file_location .open ("rb" ) as file :
53- while file :
54- len_next_bytes = file .read (4 )
55- if not len_next_bytes :
56- return test_results
57- len_next = int .from_bytes (len_next_bytes , byteorder = "big" )
58- encoded_test_bytes = file .read (len_next )
59- if not encoded_test_bytes :
60- if DEBUG_MODE :
61- logger .warning ("Failed to load test name" )
62- return test_results
63- encoded_test_name = encoded_test_bytes .decode ("ascii" )
64- duration_bytes = file .read (8 )
65- if not duration_bytes :
66- if DEBUG_MODE :
67- logger .warning ("Failed to load test duration" )
68- return test_results
69- duration = int .from_bytes (duration_bytes , byteorder = "big" )
70- len_next_bytes = file .read (4 )
71- if not len_next_bytes :
72- return test_results
73- len_next = int .from_bytes (len_next_bytes , byteorder = "big" )
74- test_pickle_bin = file .read (len_next )
75- if not test_pickle_bin :
76- if DEBUG_MODE :
77- logger .warning ("Failed to load pickle file." )
78- return test_results
79- loop_index_bytes = file .read (8 )
80- if not loop_index_bytes :
81- if DEBUG_MODE :
82- logger .warning ("Failed to load loop index" )
83- return test_results
84- loop_index = int .from_bytes (loop_index_bytes , byteorder = "big" )
85- len_next_bytes = file .read (4 )
86- if not len_next_bytes :
87- if DEBUG_MODE :
88- logger .warning ("Failed to load invocation id" )
89- return test_results
90- len_next = int .from_bytes (len_next_bytes , byteorder = "big" )
91- invocation_id_bytes = file .read (len_next )
92- if not invocation_id_bytes :
93- if DEBUG_MODE :
94- logger .warning ("Failed to load invocation id bytes" )
95- return test_results
96- invocation_id = invocation_id_bytes .decode ("ascii" )
97-
98- invocation_id_object = InvocationId .from_str_id (encoded_test_name , invocation_id )
99- test_file_path = file_path_from_module_name (
100- invocation_id_object .test_module_path , test_config .tests_project_rootdir
101- )
53+ try :
54+ while file :
55+ len_next_bytes = file .read (4 )
56+ if not len_next_bytes :
57+ return test_results
58+ len_next = int .from_bytes (len_next_bytes , byteorder = "big" )
59+ encoded_test_bytes = file .read (len_next )
60+ encoded_test_name = encoded_test_bytes .decode ("ascii" )
61+ duration_bytes = file .read (8 )
62+ duration = int .from_bytes (duration_bytes , byteorder = "big" )
63+ len_next_bytes = file .read (4 )
64+ len_next = int .from_bytes (len_next_bytes , byteorder = "big" )
65+ test_pickle_bin = file .read (len_next )
66+ loop_index_bytes = file .read (8 )
67+ loop_index = int .from_bytes (loop_index_bytes , byteorder = "big" )
68+ len_next_bytes = file .read (4 )
69+ len_next = int .from_bytes (len_next_bytes , byteorder = "big" )
70+ invocation_id_bytes = file .read (len_next )
71+ invocation_id = invocation_id_bytes .decode ("ascii" )
72+
73+ invocation_id_object = InvocationId .from_str_id (encoded_test_name , invocation_id )
74+ test_file_path = file_path_from_module_name (
75+ invocation_id_object .test_module_path , test_config .tests_project_rootdir
76+ )
10277
103- test_type = test_files .get_test_type_by_instrumented_file_path (test_file_path )
104- try :
105- test_pickle = pickle .loads (test_pickle_bin ) if loop_index == 1 else None
106- except Exception as e :
107- if DEBUG_MODE :
108- logger .exception (f"Failed to load pickle file for { encoded_test_name } Exception: { e } " )
109- continue
110- assert test_type is not None , f"Test type not found for { test_file_path } "
111- test_results .add (
112- function_test_invocation = FunctionTestInvocation (
113- loop_index = loop_index ,
114- id = invocation_id_object ,
115- file_name = test_file_path ,
116- did_pass = True ,
117- runtime = duration ,
118- test_framework = test_config .test_framework ,
119- test_type = test_type ,
120- return_value = test_pickle ,
121- timed_out = False ,
122- verification_type = VerificationType .FUNCTION_CALL ,
78+ test_type = test_files .get_test_type_by_instrumented_file_path (test_file_path )
79+ try :
80+ test_pickle = pickle .loads (test_pickle_bin ) if loop_index == 1 else None
81+ except Exception as e :
82+ if DEBUG_MODE :
83+ logger .exception (f"Failed to load pickle file for { encoded_test_name } Exception: { e } " )
84+ continue
85+ assert test_type is not None , f"Test type not found for { test_file_path } "
86+ test_results .add (
87+ function_test_invocation = FunctionTestInvocation (
88+ loop_index = loop_index ,
89+ id = invocation_id_object ,
90+ file_name = test_file_path ,
91+ did_pass = True ,
92+ runtime = duration ,
93+ test_framework = test_config .test_framework ,
94+ test_type = test_type ,
95+ return_value = test_pickle ,
96+ timed_out = False ,
97+ verification_type = VerificationType .FUNCTION_CALL ,
98+ )
12399 )
124- )
100+ except Exception as e :
101+ logger .warning (f"Failed to parse test results from { file_location } . Exception: { e } " )
102+ return test_results
125103 return test_results
126104
127105
0 commit comments