Skip to content
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

[FR]: Add gtest-spi.h interface for retrieving SCOPED_TRACE() traces #4589

Open
caraitto opened this issue Aug 6, 2024 · 0 comments
Open

Comments

@caraitto
Copy link

caraitto commented Aug 6, 2024

Does the feature exist in the most recent commit?

Nope:

// Copyright 2007, Google Inc.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant