Repository navigation
Fix stop_wrapper masking real test failures - #14885
Conversation
There was a problem hiding this comment.
Pull request overview
This PR prevents stop_wrapper cleanup errors (resetting safety_mode back to run) from masking the original test failure when stop_wrapper is invoked from finally blocks in live tests (e.g., FPS assertion failures on D585S).
Changes:
- Import
rspy.login the wrapper module. - Wrap D585S safety-mode reset in
stop_wrapperwithtry/exceptand log cleanup failures instead of letting them replace the original exception.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try: | ||
| safety_sensor = dev.first_safety_sensor() | ||
| safety_sensor.set_option(rs.option.safety_mode, rs.safety_mode.run) | ||
| except Exception as e: | ||
| log.e(f"Cleanup failed: could not set safety_mode back to run: {e}") No newline at end of file |
There was a problem hiding this comment.
stop_wrapper now swallows any exception from the cleanup unconditionally. This prevents the original failure from being masked in a finally, but it also means a test can pass even if the device could not be returned to safety_mode.run (potentially impacting subsequent tests). Consider logging the cleanup error and re-raising it when no other exception is currently being handled (e.g., detect active exception via sys.exc_info()), so cleanup failures still fail the test when they’re the only error.
There was a problem hiding this comment.
The cleanup failure is an infrastructure issue, not a test failure — logging it with -E- makes it visible in CI logs. The test result should reflect what the test actually tested, not whether teardown succeeded.
Summary
stop_wrappercould throw when resettingsafety_modeback torun, and infinallyblocks this exception replaced the original test failure (e.g. FPS assertion errors were masked byRuntimeError: Failed to set the option to value 0)Test plan
pytest-ah-configurationson D585S — verify FPS assertion errors propagate correctly when cleanup also failsstop_wrappercleanup failure is logged with-E- Cleanup failed: could not set safety_mode back to run: ...