@@ -37,7 +37,6 @@ def main():
3737
3838 with tempfile .NamedTemporaryFile (mode = 'w+' , suffix = '.json' ) as temp_file :
3939 json_output_path = temp_file .name
40- temp_file .close ()
4140 test_command = [executable , f'--gtest_output=json:{ json_output_path } ' ]
4241 subprocess .run (test_command , stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
4342
@@ -47,11 +46,14 @@ def main():
4746 for test_suite in test_results .get ('testsuites' , []):
4847 total_tests += test_suite ['tests' ]
4948 for test in test_suite .get ('testsuite' , []):
49+ failure_msg = None
50+ if 'failures' in test and test ['failures' ]:
51+ failure_msg = test ['failures' ][0 ].get ('failure' , '' )
5052 all_results [service ].append ({
5153 'service' : service ,
5254 'name' : test ['name' ],
5355 'status' : test ['status' ],
54- 'failure' : test . get ( 'failure' ) ,
56+ 'failure' : failure_msg ,
5557 })
5658
5759 print (f"1..{ total_tests } " )
@@ -65,12 +67,14 @@ def main():
6567 failure = result ['failure' ]
6668 error_expected = "error expected from service" if "Failure" in test_name or "Error" in test_name else "no error expected from service"
6769
68- if status == 'RUN' :
70+ if status == 'RUN' and not failure :
6971 print (f"ok { service } { test_name } - { error_expected } " )
7072 else :
7173 print (f"not ok { service } { test_name } " )
7274 if failure :
73- print (f"# { failure } " )
75+ for line in failure .split ('\n ' ):
76+ if line .strip ():
77+ print (f"# { line } " )
7478
7579 return 0
7680
0 commit comments