ddnet / ddnet

DDraceNetwork, a free cooperative platformer game
https://ddnet.org
Other
510 stars 381 forks source link

Silence teehistorian debug in test when GTEST_BRIEF is set #8357

Closed ChillerDragon closed 2 weeks ago

ChillerDragon commented 3 weeks ago

By default running the tests is very verbose and one has to scroll to the failing test case every time while debugging. Luckily there is https://google.github.io/googletest/advanced.html#suppressing-test-passes GTEST_BRIEF=1 which silences passing tests. But then the teehistorian test still prints a lot of things.

heinrich5991 commented 3 weeks ago

I don't see any indication that one is supposed to use GTEST_BRIEF from user code in the posted documentation link.

Is there maybe a way of making gtest only show the output for failing tests?

ChillerDragon commented 3 weeks ago

Is there maybe a way of making gtest only show the output for failing tests?

The only thing I found is GTEST_BRIEF which removed the passing test output coming from gtest. But then what is left is whatever ddnet prints to stdout in the passing tests. Which is a bunch of sql logs and a lot of those teehistorian dumps.

heinrich5991 commented 3 weeks ago

Hmm. Perhaps it's simply not possible: https://github.com/google/googletest/issues/2178.

I wonder if there's a test framework we could switch to that supports this. It seems like a pretty fundamental feature.

ChillerDragon commented 3 weeks ago

I am all in for switching test framework. What about rolling our own?

heinrich5991 commented 3 weeks ago

I'd generally prefer using an existing one so that we can benefit from its features. Writing our own will likely miss many use cases.

heinrich5991 commented 3 weeks ago

Perhaps we could try to implement output-on-failure-only within GTest using events: https://google.github.io/googletest/advanced.html#defining-event-listeners.

ChillerDragon commented 3 weeks ago

Which use cases do we rely on other than an assert eq feature?

heinrich5991 commented 3 weeks ago

Just two features I remember using: Filtering what tests are run. Repeating a single test until failure.

There are probably more that others have used that I'm not aware of.

ChillerDragon commented 3 weeks ago

Seems simple. So we did not use anything complex such as mocking?

heinrich5991 commented 3 weeks ago

Mocking wasn't used AFAIK. I don't know if anything "as complex as mocking" was used.

Robyt3 commented 2 weeks ago

Which use cases do we rely on other than an assert eq feature?

Test fixtures and typed tests.

Death tests also seem interesting for testing dbg_asserts.

What about rolling our own?

I don't think that's a worthwhile effort.

ChillerDragon commented 2 weeks ago

Well if we don't want to roll our own and gtest cant silence stdout. How about we merge this pr or stop spamming stdout in any other way?

Robyt3 commented 2 weeks ago

Can you use ::testing::GTEST_FLAG(brief) instead of checking the environment variable? That seems like the "documented" way to retrieve the googletest configuration.

heinrich5991 commented 2 weeks ago

The flag looks unrelated to what we want though, so it's no good to retrieve it the proper way.

heinrich5991 commented 2 weeks ago

Well if we don't want to roll our own and gtest cant silence stdout. How about we merge this pr or stop spamming stdout in any other way?

Possible solutions:

I don't see this PR as a solution because it uses an flag that is supposed to hide output of successful runs to hide output of all runs.

ChillerDragon commented 2 weeks ago

I am not doing gtest event listeners.