Skip to content

Commit

Permalink
Slightly better message for failing test
Browse files Browse the repository at this point in the history
Ensures name is always shown whatever the exception cause.
  • Loading branch information
tpwrules committed Jul 18, 2024
1 parent 4722fe3 commit 795ffb4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions dronecan_dsdlc.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,18 @@ def expand_message(msg_name):

def process_test(msg_name, jobs):
print(bcolors.HEADER + 'Starting Test for %s' % (msg_name,) + bcolors.ENDC)
if message_dict[msg_name].kind == message_dict[msg_name].KIND_SERVICE:
if len(message_dict[msg_name].request_fields):
compile_test_app(msg_name+'_request', build_dir)
run_test(message_dict[msg_name], 'request', build_dir)
compile_test_app(msg_name+'_response', build_dir, jobs)
run_test(message_dict[msg_name], 'response', build_dir)
else:
compile_test_app(msg_name, build_dir, jobs)
run_test(message_dict[msg_name], None, build_dir)
try:
if message_dict[msg_name].kind == message_dict[msg_name].KIND_SERVICE:
if len(message_dict[msg_name].request_fields):
compile_test_app(msg_name+'_request', build_dir)
run_test(message_dict[msg_name], 'request', build_dir)
compile_test_app(msg_name+'_response', build_dir, jobs)
run_test(message_dict[msg_name], 'response', build_dir)
else:
compile_test_app(msg_name, build_dir, jobs)
run_test(message_dict[msg_name], None, build_dir)
except Exception as e:
raise Exception("Test for %s failed!" % (msg_name,)) from e

# callback for maintaining list of built messages
def append_builtlist(msg_name):
Expand Down
2 changes: 1 addition & 1 deletion dronecan_dsdlc_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def run_test(msg, msg_type, build_dir):
if 'Messages are equal' in stripped_lines:
return
else:
raise Exception(msg_full_name + " Test failed")
raise Exception(msg_full_name + " test app failed")

if __name__ == '__main__':
msg = dronecan.uavcan.equipment.ahrs.MagneticFieldStrength()
Expand Down

0 comments on commit 795ffb4

Please sign in to comment.