22# Licensed under the Apache License, Version 2.0
33
44import re
5- import traceback
65
76from colcon_core .logging import colcon_logger
87from colcon_core .plugin_system import get_first_line_doc
@@ -27,7 +26,6 @@ def add_arguments(self, *, parser): # noqa: D102
2726 add_python_testing_step_arguments (parser )
2827
2928 async def test (self , * , additional_hooks = None ): # noqa: D102
30- pkg = self .context .pkg
3129 args = self .context .args
3230
3331 logger .info (
@@ -36,8 +34,8 @@ async def test(self, *, additional_hooks=None): # noqa: D102
3634 try :
3735 env = await get_command_environment (
3836 'setup_py' , args .build_base , self .context .dependencies )
39- except RuntimeError as e :
40- logger .error ( str ( e ) )
37+ except RuntimeError :
38+ logger .exception ( 'Failed to get command environment' )
4139 return 1
4240 setup_py_data = get_setup_data (self .context .pkg , env )
4341
@@ -52,15 +50,13 @@ async def test(self, *, additional_hooks=None): # noqa: D102
5250 1 , "test() by extension '{key}'" .format_map (locals ()))
5351 try :
5452 matched = extension .match (self .context , env , setup_py_data )
55- except Exception as e : # noqa: F841
53+ except Exception :
5654 # catch exceptions raised in python testing step extension
57- exc = traceback .format_exc ()
58- logger .error (
55+ logger .exception (
5956 'Exception in Python testing step extension '
60- "'{extension.STEP_TYPE}': {e} \n {exc} "
57+ "'{extension.STEP_TYPE}'"
6158 .format_map (locals ()))
62- # skip failing extension, continue with next one
63- continue
59+ return 1
6460 if matched :
6561 break
6662 else :
@@ -73,12 +69,11 @@ async def test(self, *, additional_hooks=None): # noqa: D102
7369 1 , "test.step() by extension '{key}'" .format_map (locals ()))
7470 try :
7571 return await extension .step (self .context , env , setup_py_data )
76- except Exception as e : # noqa: F841
72+ except Exception :
7773 # catch exceptions raised in python testing step extension
78- exc = traceback .format_exc ()
79- logger .error (
74+ logger .exception (
8075 'Exception in Python testing step extension '
81- "'{extension.STEP_TYPE}': {e} \n {exc} " .format_map (locals ()))
76+ "'{extension.STEP_TYPE}'" .format_map (locals ()))
8277 return 1
8378
8479
@@ -176,12 +171,11 @@ def add_python_testing_step_arguments(parser):
176171 try :
177172 retval = extension .add_arguments (parser = parser )
178173 assert retval is None , 'add_arguments() should return None'
179- except Exception as e : # noqa: F841
174+ except Exception :
180175 # catch exceptions raised in package selection extension
181- exc = traceback .format_exc ()
182- logger .error (
176+ logger .exception (
183177 'Exception in Python testing step extension '
184- "'{extension.STEP_TYPE}': {e} \n {exc} " .format_map (locals ()))
178+ "'{extension.STEP_TYPE}'" .format_map (locals ()))
185179 # skip failing extension, continue with next one
186180
187181
0 commit comments