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

Add GTEST_QUIET option #2751

Merged
merged 2 commits into from
May 5, 2020
Merged

Add GTEST_QUIET option #2751

merged 2 commits into from
May 5, 2020

Conversation

calumr
Copy link
Contributor

@calumr calumr commented Mar 18, 2020

Only prints failures and a total pass count. This is useful for CI logs, which are more useful if they just have the failures instead of 100s or 1000s of lines of "PASSED" and the one failure buried in the middle.

Fixes #358, which was closed but seems to have a few fans...

@googlebot
Copy link

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

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@calumr
Copy link
Contributor Author

calumr commented Mar 18, 2020

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

Copy link
Member

@vslashg vslashg left a comment

Choose a reason for hiding this comment

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

We are open to this change, but have a couple of suggestions.

First, the name "quiet" seems to suggest that Google Test won't emit any output (reporting results by exit code only.) Maybe a different word is more appropriate, perhaps "brief"?

Second, adding a bunch of early exits to PrettyUnitTestResultPrinter feels slightly off. We think it could work out cleaner to have a second implementation of TestEventListener for brief output, and install the appropriate listener based on the flag setting.

#### Suppressing test passes

By default, googletest prints 1 line of output for each test, indicating if it
passed or failed. T to show only test failures, run the test program with
Copy link
Member

Choose a reason for hiding this comment

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

"T to show" appears to be a typo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed in the last push.

@vslashg vslashg self-assigned this Mar 18, 2020
Only prints failures and a total pass count
@calumr
Copy link
Contributor Author

calumr commented Mar 19, 2020

You were totally right about adding another TestEventListener - it's much cleaner this way. There is some code duplication though, I can understand if you want me to clean that up.

I went a little further and removed the PrintFailedTests calls too, they are just duplicating the information printed from OnTestEnd.

@lishuai87
Copy link

ctest has option --output-on-failure, why gtest not support it?

https://cmake.org/cmake/help/latest/manual/ctest.1.html#options

vslashg added a commit that referenced this pull request May 5, 2020
PiperOrigin-RevId: 309958629
@vslashg vslashg merged commit e589a33 into google:master May 5, 2020
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quiet output
4 participants