-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Capture plug exceptions into the test record #614
base: master
Are you sure you want to change the base?
Conversation
"""When the framework throws an exception, turn it into a failure code.""" | ||
if self.test_state and not self.test_state.is_finalized: | ||
self.test_state.test_record.add_outcome_details(exc_type.__name__, exc_val.message) | ||
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to be a departure from the previous logic, which suppressed only in the case of ThreadTerminationError. Is that intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree we should look into this more.
- Looking at
util/threads.py
it seems like this is mainly a matter of logging (if the exception is suppressed, it is not printed or logged, otherwise, it is sent to both logging.exception and stderr) or am I missing another side effect that can occur as a result of the thread raising an exception? - It seems like returning True here risks silencing some errors completely (except for the outcome detail added to the test record). Errors in plug initialization are logged in PlugManager.initialize_plugs but other errors might be silenced.
- I noticed PhaseExecutorThread has sort of the opposite behavior—it never suppresses exceptions. It also makes its own call to logger.exception, so in the console you get “Phase <...> raised an exception” followed by “Thread raised an exception” followed by “Exception in thread” (three printouts of the same exception). We should see if the logging behavior can be more consistent (and not unnecessarily repetitive?).
@@ -224,3 +249,4 @@ def test_execute_run_if_false(self): | |||
def test_execute_phase_return_skip(self): | |||
result = self.phase_executor.execute_phase(phase_return_skip) | |||
self.assertEqual(PhaseResult.SKIP, result.phase_result) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra newline
def _thread_exception(self, exc_type, exc_val, exc_tb): | ||
"""When the framework throws an exception, turn it into a failure code.""" | ||
if self.test_state and not self.test_state.is_finalized: | ||
self.test_state.test_record.add_outcome_details(exc_type.__name__, exc_val.message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line length > 80
@@ -146,6 +146,12 @@ def _thread_proc(self): | |||
|
|||
# Everything is set, set status and begin test execution. | |||
self._execute_test_phases(phase_exec) | |||
|
|||
def _thread_exception(self, exc_type, exc_val, exc_tb): | |||
"""When the framework throws an exception, turn it into a failure code.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should clarify When the framework throws an exception
a little more. Looks like this is called when an exception is raised inside a test but outside of all phases?
"""When the framework throws an exception, turn it into a failure code.""" | ||
if self.test_state and not self.test_state.is_finalized: | ||
self.test_state.test_record.add_outcome_details(exc_type.__name__, exc_val.message) | ||
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree we should look into this more.
- Looking at
util/threads.py
it seems like this is mainly a matter of logging (if the exception is suppressed, it is not printed or logged, otherwise, it is sent to both logging.exception and stderr) or am I missing another side effect that can occur as a result of the thread raising an exception? - It seems like returning True here risks silencing some errors completely (except for the outcome detail added to the test record). Errors in plug initialization are logged in PlugManager.initialize_plugs but other errors might be silenced.
- I noticed PhaseExecutorThread has sort of the opposite behavior—it never suppresses exceptions. It also makes its own call to logger.exception, so in the console you get “Phase <...> raised an exception” followed by “Thread raised an exception” followed by “Exception in thread” (three printouts of the same exception). We should see if the logging behavior can be more consistent (and not unnecessarily repetitive?).
I'm also not seeing the logger in the plug show up in the test record, example self.logger.info('blah'). Does this PR address that also? Thanks |
I don't think so. That should be in the test record already... |
Ah I see it in test record when run within a phase, I don't see it when called in tearDown |
@Kenadia is this PR still needed? Looks like it's getting stale sitting here. |
Having plug exceptions into the test record would still be useful |
This change is