[FR]: Add gtest-spi.h interface for retrieving SCOPED_TRACE() traces
- Dominant language
- C++
- Stars
- 39.5k
- Forks
- 10.9k
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 1
Description
### Does the feature exist in the most recent commit?
Nope: https://github.com/google/googletest/blob/ff233bdd4cac0a0bf6e5cd45bda3406814cb2796/googletest/include/gtest/gtest-spi.h#L1
### Why do we need this feature?
gtest-spi.h allows checking for non-fatal failures with `EXPECT_NONFATAL_FAILURE()` and matching the failure message.
Today, it is even possible to match against `SCOPE_TRACE()` traces, but it's a bit awkward, since the trace usually looks like this:
```
Google Test trace:
../../path/to/file.cc:104: 0
../../path/to/file.cc:95: some text
...
```
Since line numbers are included in the trace (which is useful when debugging tests), if the `EXPECT_NONFATAL_FAILURE()` `substr` includes the trace, it will have to include the filenames and line numbers too, but these can change over time. It would be nice to somehow just match against the values without the file names and line numbers (this would be possible if `substr` could be regular expression, or if it was possible to programmatically retrieve the trace values).
### Describe the proposal.
Either
1) Add a variant macro that accepts a regular expression instead of a pure string match, or
2) Add a method (something like https://en.cppreference.com/w/cpp/utility/tuple/get perhaps) that allows retrieving elements of the scoped trace.
### Is the feature specific to an operating system, compiler, or build system version?
No
Contributor guide
Research direction
Start with googletest/include/gtest/gtest-spi.h and review EXPECT_NONFATAL_FAILURE() alongside SCOPED_TRACE() behavior. Decide whether the intended interface is a regular-expression matching variant or programmatic access to scoped-trace values, then define the expected API and coverage for the selected approach.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100