As discussed on #2172. Requires migrating existing uses of TEST(...).
Once this is done, also remove the "_Use the GTEST prefix in unit test declarations_" rule from code_style_guide.rst, since it will be impossible to do otherwise.
If we are going to defect this in inspections, we better darn well just tell the compiler to pre-enforce it. I'll implement this now.
Would resolving this issue involve defining a header file with this macro that is included by all Google-Test-based unit tests? In which case, maybe the same header file can also include gtest/gtest.h and be located in drake/common/?
My current spike test sets it via CMake, which is more likely to succeed than relying on using-code to remember to set it.
Interesting. I did not know CMake can inject macros into C++ source code. Looking forward to learning how that's done.
I've pushed the fixes to github, but it hasn't deigned to show them in the web UI yet. Once it does, I'll PR this.
As of recently, here is the complete list of suspect names that GTEST lets you suppress. Consider forbidding some or all of these.
$ grep DONT ~/checkout/drake/externals/googletest/googletest/include/gtest/gtest.h #if !GTEST_DONT_DEFINE_FAIL #if !GTEST_DONT_DEFINE_SUCCEED // Define macro GTEST_DONT_DEFINE_ASSERT_XY to 1 to omit the definition of #if !GTEST_DONT_DEFINE_ASSERT_EQ #if !GTEST_DONT_DEFINE_ASSERT_NE #if !GTEST_DONT_DEFINE_ASSERT_LE #if !GTEST_DONT_DEFINE_ASSERT_LT #if !GTEST_DONT_DEFINE_ASSERT_GE #if !GTEST_DONT_DEFINE_ASSERT_GT #if !GTEST_DONT_DEFINE_TEST
Would be good to use only the GTEST_ form of all of these but could be a different PR. (Would be even better if Google had had some respect for the sanctity of our namespaces in the first place!)
I asked rpoyner-tri to list all of the remaining ones here. The PR will stay as-is, but I intend to keep the issue open to track the fixes to all of the pollution.
I propose that we keep the ASSERT_EQ and friends (to match EXPECT_EQ), but that we nuke FAIL and SUCCEED.
Most helpful comment
I propose that we keep the ASSERT_EQ and friends (to match EXPECT_EQ), but that we nuke FAIL and SUCCEED.