carlosgalvezp created this revision. Herald added subscribers: PiotrZSL, xazax.hun. Herald added a reviewer: njames93. Herald added a project: All. carlosgalvezp requested review of this revision. Herald added a project: clang-tools-extra. Herald added a subscriber: cfe-commits.
Test suite name can also be disabled with DISABLED_, not just the test case name. Fix also broken link in the test that refers to the explanation as to why underscores may not be used. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D146655 Files: clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp clang-tools-extra/test/clang-tidy/checkers/readability/avoid-underscore-in-googletest-name.cpp Index: clang-tools-extra/test/clang-tidy/checkers/readability/avoid-underscore-in-googletest-name.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/readability/avoid-underscore-in-googletest-name.cpp +++ clang-tools-extra/test/clang-tidy/checkers/readability/avoid-underscore-in-googletest-name.cpp @@ -87,21 +87,31 @@ // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: avoid using "_" in test case name "Illegal_Type_ParameterizedTestCaseName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name] // Underscores are allowed to disable a test with the DISABLED_ prefix. -// https://github.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore +// https://google.github.io/googletest/faq.html#why-should-test-suite-names-and-test-names-not-contain-underscore TEST(TestCaseName, TestName) {} TEST(TestCaseName, DISABLED_TestName) {} +TEST(DISABLED_TestCaseName, TestName) {} +TEST(DISABLED_TestCaseName, DISABLED_TestName) {} TEST_F(TestCaseFixtureName, TestName) {} TEST_F(TestCaseFixtureName, DISABLED_TestName) {} +TEST_F(DISABLED_TestCaseFixtureName, TestName) {} +TEST_F(DISABLED_TestCaseFixtureName, DISABLED_TestName) {} TEST_P(ParameterizedTestCaseFixtureName, TestName) {} TEST_P(ParameterizedTestCaseFixtureName, DISABLED_TestName) {} +TEST_P(DISABLED_ParameterizedTestCaseFixtureName, TestName) {} +TEST_P(DISABLED_ParameterizedTestCaseFixtureName, DISABLED_TestName) {} TYPED_TEST(TypedTestName, TestName) {} TYPED_TEST(TypedTestName, DISABLED_TestName) {} +TYPED_TEST(DISABLED_TypedTestName, TestName) {} +TYPED_TEST(DISABLED_TypedTestName, DISABLED_TestName) {} TYPED_TEST_P(TypeParameterizedTestName, TestName) {} TYPED_TEST_P(TypeParameterizedTestName, DISABLED_TestName) {} +TYPED_TEST_P(DISABLED_TypeParameterizedTestName, TestName) {} +TYPED_TEST_P(DISABLED_TypeParameterizedTestName, DISABLED_TestName) {} FRIEND_TEST(FriendTest, Is_NotChecked) {} FRIEND_TEST(Friend_Test, IsNotChecked) {} Index: clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp +++ clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp @@ -51,8 +51,10 @@ const Token *TestNameToken = Args->getUnexpArgument(1); if (!TestCaseNameToken || !TestNameToken) return; - std::string TestCaseName = PP->getSpelling(*TestCaseNameToken); - if (TestCaseName.find('_') != std::string::npos) + std::string TestCaseNameMaybeDisabled = PP->getSpelling(*TestCaseNameToken); + StringRef TestCaseName = TestCaseNameMaybeDisabled; + TestCaseName.consume_front(KDisabledTestPrefix); + if (TestCaseName.contains('_')) Check->diag(TestCaseNameToken->getLocation(), "avoid using \"_\" in test case name \"%0\" according to " "Googletest FAQ")
Index: clang-tools-extra/test/clang-tidy/checkers/readability/avoid-underscore-in-googletest-name.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/readability/avoid-underscore-in-googletest-name.cpp +++ clang-tools-extra/test/clang-tidy/checkers/readability/avoid-underscore-in-googletest-name.cpp @@ -87,21 +87,31 @@ // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: avoid using "_" in test case name "Illegal_Type_ParameterizedTestCaseName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name] // Underscores are allowed to disable a test with the DISABLED_ prefix. -// https://github.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore +// https://google.github.io/googletest/faq.html#why-should-test-suite-names-and-test-names-not-contain-underscore TEST(TestCaseName, TestName) {} TEST(TestCaseName, DISABLED_TestName) {} +TEST(DISABLED_TestCaseName, TestName) {} +TEST(DISABLED_TestCaseName, DISABLED_TestName) {} TEST_F(TestCaseFixtureName, TestName) {} TEST_F(TestCaseFixtureName, DISABLED_TestName) {} +TEST_F(DISABLED_TestCaseFixtureName, TestName) {} +TEST_F(DISABLED_TestCaseFixtureName, DISABLED_TestName) {} TEST_P(ParameterizedTestCaseFixtureName, TestName) {} TEST_P(ParameterizedTestCaseFixtureName, DISABLED_TestName) {} +TEST_P(DISABLED_ParameterizedTestCaseFixtureName, TestName) {} +TEST_P(DISABLED_ParameterizedTestCaseFixtureName, DISABLED_TestName) {} TYPED_TEST(TypedTestName, TestName) {} TYPED_TEST(TypedTestName, DISABLED_TestName) {} +TYPED_TEST(DISABLED_TypedTestName, TestName) {} +TYPED_TEST(DISABLED_TypedTestName, DISABLED_TestName) {} TYPED_TEST_P(TypeParameterizedTestName, TestName) {} TYPED_TEST_P(TypeParameterizedTestName, DISABLED_TestName) {} +TYPED_TEST_P(DISABLED_TypeParameterizedTestName, TestName) {} +TYPED_TEST_P(DISABLED_TypeParameterizedTestName, DISABLED_TestName) {} FRIEND_TEST(FriendTest, Is_NotChecked) {} FRIEND_TEST(Friend_Test, IsNotChecked) {} Index: clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp +++ clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp @@ -51,8 +51,10 @@ const Token *TestNameToken = Args->getUnexpArgument(1); if (!TestCaseNameToken || !TestNameToken) return; - std::string TestCaseName = PP->getSpelling(*TestCaseNameToken); - if (TestCaseName.find('_') != std::string::npos) + std::string TestCaseNameMaybeDisabled = PP->getSpelling(*TestCaseNameToken); + StringRef TestCaseName = TestCaseNameMaybeDisabled; + TestCaseName.consume_front(KDisabledTestPrefix); + if (TestCaseName.contains('_')) Check->diag(TestCaseNameToken->getLocation(), "avoid using \"_\" in test case name \"%0\" according to " "Googletest FAQ")
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits