Skip to content

Enable SCOPED_TRACE in Rust googletest crate.#799

Merged
copybara-service[bot] merged 1 commit into
mainfrom
test_910025143
May 11, 2026
Merged

Enable SCOPED_TRACE in Rust googletest crate.#799
copybara-service[bot] merged 1 commit into
mainfrom
test_910025143

Conversation

@copybara-service
Copy link
Copy Markdown

@copybara-service copybara-service Bot commented May 4, 2026

Enable SCOPED_TRACE in Rust googletest crate.

This CL provides an equivalent to C++ gTest's SCOPED_TRACE in Rust tests by integrating it into the googletest crate.

Rationale:

  • Failures in table-driven tests or tests with random inputs are hard to understand without context. SCOPED_TRACE allows adding this context.

Details:

  • Added scoped_trace! macro that pushes traces to a thread-local stack.
  • Used RAII guard to pop traces when going out of scope.
  • Made the guard !Send and !Sync to prevent crossing .await points in async tests.
  • Integrated with TestAssertionFailure to include traces in failure messages.
  • Installed a panic hook to print traces on fatal panics.
  • Added golden test to validate printed output of SCOPED_TRACE.

PUBLIC: Internal

@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 4, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@copybara-service copybara-service Bot force-pushed the test_910025143 branch 6 times, most recently from 7dbfe3f to 10a9831 Compare May 4, 2026 16:18
@copybara-service copybara-service Bot force-pushed the test_910025143 branch 2 times, most recently from b61be76 to aa102b1 Compare May 11, 2026 19:37
This CL provides an equivalent to C++ gTest's SCOPED_TRACE in Rust tests by integrating it into the googletest crate.

Rationale:
- Failures in table-driven tests or tests with random inputs are hard to understand without context. SCOPED_TRACE allows adding this context.

Details:
- Added scoped_trace! macro that pushes traces to a thread-local stack.
- Used RAII guard to pop traces when going out of scope.
- Made the guard !Send and !Sync to prevent crossing .await points in async tests.
- Integrated with TestAssertionFailure to include traces in failure messages.
- Installed a panic hook to print traces on fatal panics.
- Added golden test to validate printed output of SCOPED_TRACE.

PUBLIC: Internal
PiperOrigin-RevId: 913832932
@copybara-service copybara-service Bot merged commit e489b8c into main May 11, 2026
@copybara-service copybara-service Bot deleted the test_910025143 branch May 11, 2026 19:40
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.

0 participants