@@ -101,16 +101,18 @@ def test(example, test_data, serial_handle):
101101
102102 if response == None :
103103 formatted_output = output .replace ("\r " , "\\ r" ).replace ("\n " , "\\ n" )
104- logging .error (f"\t Did not get the expected response \" { expectation } \" , got: \" { formatted_output } \" " )
104+ error = f"\t Did not get the expected response \" { expectation } \" , got: \" { formatted_output } \" "
105+ logging .error (error )
105106 logging .error (f"{ example_name } : Failed" )
106- return False
107+ return ( False , error )
107108
108109 formatted_response = response .group (0 ).replace ("\r " , "\\ r" ).replace ("\n " , "\\ n" )
109110
110111 logging .info (f"\t Got valid response: { formatted_response } " )
111112
112113 print (f"{ example_name } : Passed" )
113- return True
114+
115+ return (True , None )
114116
115117
116118if __name__ == '__main__' :
@@ -194,12 +196,12 @@ def test(example, test_data, serial_handle):
194196 example_name = os .path .splitext (os .path .basename (example ))[0 ]
195197
196198 if not example_name in test_config :
197- examples_test_status [example_name ] = " No test defined"
199+ examples_test_status [example_name ] = { "status" : " No test defined", "error" : None }
198200 continue
199201
200202 if not test_config [example_name ]["enabled" ]:
201203 logging .warning (f"Skipping test for { example_name } , not enabled" )
202- examples_test_status [example_name ] = " Test disabled"
204+ examples_test_status [example_name ] = { "status" : " Test disabled", "error" : None }
203205 continue
204206
205207 backend .start_session (session_config )
@@ -211,11 +213,12 @@ def test(example, test_data, serial_handle):
211213 # so that the board is reset and running the programmed code
212214 with serial .Serial (arguments .port , 115200 , timeout = TIMEOUT ) as serial_handle :
213215 backend .end_session ()
214- if test (example , test_config [example_name ]["tests" ], serial_handle ):
215- examples_test_status [example_name ] = "Passed"
216+ (result , error ) = test (example , test_config [example_name ]["tests" ], serial_handle )
217+
218+ if not error :
219+ examples_test_status [example_name ] = {"status" : "Passed" , "error" : None }
216220 else :
217- examples_test_status [example_name ] = "Not passed"
218- exit (1 )
221+ examples_test_status [example_name ] = {"status" : "Passed" , "error" : error }
219222
220223 except serial .SerialException as exception :
221224 logging .error (f"Got exception while opening serial port: { exception } " )
@@ -226,7 +229,13 @@ def test(example, test_data, serial_handle):
226229 backend .disconnect_from_tool ()
227230
228231 print ("--------------- Test status ---------------" )
229- for example_name , status in examples_test_status .items ():
230- print (f"{ example_name :<30} : { status } " )
232+ for example_name , entry in examples_test_status .items ():
233+ status = entry ["status" ]
234+ error = entry ["error" ]
235+
236+ if status == "Passed" or status == "No test defined" or status == "Test disabled" :
237+ print (f"{ example_name :<30} : { status } " )
238+ else :
239+ print (f"{ example_name :<30} : { status } - { error } " )
231240
232241 exit (0 )
0 commit comments