Skip to content

Fix stop_wrapper masking real test failures - #14885

Merged
Nir-Az merged 2 commits into
realsenseai:developmentfrom
Nir-Az:stop-wrapper-masking-errors
Mar 31, 2026
Merged

Nir-Az merged 2 commits into
realsenseai:developmentfrom
Nir-Az:stop-wrapper-masking-errors

Conversation

@Nir-Az

@Nir-Az Nir-Az commented Mar 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • stop_wrapper could throw when resetting safety_mode back to run, and in finally blocks this exception replaced the original test failure (e.g. FPS assertion errors were masked by RuntimeError: Failed to set the option to value 0)
  • Wrapped the cleanup in try/except so failures are logged clearly without hiding the real test error

Test plan

  • Run pytest-ah-configurations on D585S — verify FPS assertion errors propagate correctly when cleanup also fails
  • Verify stop_wrapper cleanup failure is logged with -E- Cleanup failed: could not set safety_mode back to run: ...

Copilot AI review requested due to automatic review settings March 31, 2026 07:54
@Nir-Az
Nir-Az requested a review from remibettan March 31, 2026 07:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.log in the wrapper module.
  • Wrap D585S safety-mode reset in stop_wrapper with try/except and 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.

Comment on lines +18 to +22
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

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Nir-Az
Nir-Az merged commit 4749e27 into realsenseai:development Mar 31, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants