-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Detect and report "Rotten Green Tests" #4192
Conversation
did not execute, even though they were contained in a test method that was executed. Use `--gtest_treat_rotten_as_pass` to report these but not cause them to fail the test execution.
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. |
This is one of the more interesting pull requests I've seen. However, we do need the CLA before we can discuss it. |
I am actively trying to get the CLA issue resolved. If someone on the Google side can tell me who the Sony/SIE contact is, that would help immensely. |
I'm told I've been added to the CLA, so we should be okay to go now? |
I've added the |
@derekmauro According to https://cla.developers.google.com/clas, paul.robinson@sony.com is on the corporate CLA https://cla.developers.google.com/about/android-legacy-corporate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like your CLA is passing now.
I want to be upfront with you here. In principle, I like this a lot. It might be hard to merge, but I do think it is doable.
What you need to understand is that my mandate as a GoogleTest maintainer is to primarily support Google's use cases. For everyone else, while we hope GoogleTest is useful, it unfortunately means that use cases for everyone else don't get as high of a priority. In my personal view I'm not 100% happy with this stance, but such is life.
GoogleTest is developed with our internal monorepo as the source of truth. The Software Engineering at Google book talks about the approach. Changes first get merged into the monorepo, then get re-exported to GitHub. Unfortunately, as an open source contributor, you don't get visibility into the monorepo.
This also means that we have put in place what we call the "Churn Policy". This policy basically says that if you want to make a change, the people making the change must do the work to move their internal users to new versions themselves, or do the update in place, in backward-compatible fashion. https://abseil.io/resources/swe-book/html/ch01.html#scale_and_efficiency talks about this in more detail.
As a consequence, we can't enable detection of rotten green tests by default, as much as I'd like to. We have (I'm guessing) millions of tests written using the GoogleTest framework. You can bet that a non-trivial number of them would start failing if this were enabled. For better or worse, the engineering culture here is that if your change breaks a distant test, your change almost certainly gets rolled back, even if it exposed a bug in the downstream code. Personally I dislike this - if my code has a bug, I want to know. But the reality of the situation is that most build-cops are not equipped to quickly understand why their tests are failing.
So to set exceptions, it is going to require a lot of my time to get this merged internally.
Now I haven't taken a hard look at the implementation, but here is what needs to happen initially.
- This has to be backwards compatible, at least for now. That means this must be disabled by default. We can look into turning it on by default at a later time.
- It also looks like you have set this up to work with CMake, but not Bazel. Bazel is our primary build system, and it must be supported.
Let me know if you have questions, and thanks for submitting this for consideration.
Thanks Derek! Very happy to have the bureaucratic stuff over with. It was pretty clear from the googletest commit history that this is an internal thing that Google chooses to make available. I agree with you that this will likely find a bunch of things in Google's internal tests, and I have heard from other Googlers about the "it's on you" policy. I have exactly the same situation with LLVM, my main project--I have not been able to fix all the rotten tests there. So, I am on board with having RGT detection turned off by default. There's already a global toggle to let you compile-out RGT support, but that's too big a hammer, I think. (I had to invent that because at some point older version of gcc weren't able to build it.) There's a command-line option to control rotten=pass/fail, which I can fiddle the LLVM test runner to set to pass, but maybe that's tricky for how Google works. A separate toggle to control the default pass/fail behavior would be worthwhile. Then you can have a default mode that reports rotten assertions but doesn't fail the test program. I don't know how you have things set up internally but maybe this would let you enable RGT incrementally as you fix tests. I'll have a go at the Bazel stuff. I've never used it before, and the syntax looks a little funky, but with any luck it shouldn't be too hard. It wasn't clear whether contributors were on the hook for that part, but it's fine to have me do it. Question for you. I don't have access to a Mac, so I haven't tested RGT in that environment at all. If Macs use Clang to build, there's a decent chance that it will Just Work, but no way to know until somebody tries it. Maybe you can do that after I get the Bazel stuff done? FTR, this is a side project for me so it might take a little while to deliver an update. |
I've pushed an update to make the default for Filed #4254 regarding my failure to get bazel to build googletest, which is kind of a prerequisite to providing BUILD file patches for the new files. |
|
|
now. Update gtest-port.h to remove the special case.
independently. CMake builds gtest-all.cc but bazel builds the modules separately, which detected some sloppiness. Also, put GTEST_HAS_RGT conditionals around the parser stuff, which obviously isn't needed unless RGT is enabled.
Found the build problem--bazel builds modules individually, but CMake uses gtest-all.cc, which allowed some sloppiness to creep in. That's fixed. Speculatively tried |
|
Hi Derek, good news and bad news. The good news is, I got my new tests to build and run under Bazel. You might want to look at the BUILD.bazel change, where I had to list a test source explicitly, because it doesn't have The bad news is: I think the current implementation of RGT will be useless under Bazel. This is because the implementation needs to parse the test source, at runtime. It records the I've only figured this out now because I developed RGT using CMake to generate makefiles, and it seems those pass absolute paths to the compiler. Under CMake, If there's a magic option to bazel to have it pass absolute paths to the compiler, then it could still work. I did skim the bazel command-line reference and didn't see anything that looked like this. So, lacking a magic bazel option, if we want to proceed with RGT, we need to come up with a tactic that doesn't involve parsing source at runtime. Now, the reason RGT parses the source is because I couldn't come up with any other way to associate assertions with their containing Test methods reliably at compile-time. There's a way to do it for the TEST and TEST_F macros, because those generate a So, I could go back to capturing Let me know how you want to proceed with this. |
See #4552 for a revised patch that works in Google's Bazel environment, but is less effective. |
I'm retiring soon, if someone else wants to pick this up the PRs are still here. |
Rotten Green Tests are tests that have assertions that did not execute, even though they were contained in a test method that was executed.
Use
--gtest_treat_rotten_as_pass
to report these but not cause them to fail the test execution.