[clang-tools-extra] [clang-tidy] Return error code on config parse error (PR #136167)
Galen Elias via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 30 16:50:23 PDT 2025
================
@@ -46,20 +46,20 @@ TEST(ClangTidyOptionsProvider, InMemoryFileSystems) {
FileOptionsProvider FileOpt({}, {}, {}, FileSystem);
- ClangTidyOptions File1Options =
+ llvm::ErrorOr<ClangTidyOptions> File1Options =
FileOpt.getOptions("ProjectRoot/SubDir1/File.cpp");
- ClangTidyOptions File2Options =
+ llvm::ErrorOr<ClangTidyOptions> File2Options =
FileOpt.getOptions("ProjectRoot/SubDir1/SubDir2/File.cpp");
- ClangTidyOptions File3Options =
+ llvm::ErrorOr<ClangTidyOptions> File3Options =
FileOpt.getOptions("ProjectRoot/SubDir1/SubDir2/SubDir3/File.cpp");
- ASSERT_TRUE(File1Options.Checks.has_value());
- EXPECT_EQ(*File1Options.Checks, "-*,clang-diagnostic-*,readability-*");
- ASSERT_TRUE(File2Options.Checks.has_value());
- EXPECT_EQ(*File2Options.Checks, "bugprone-*,misc-*,clang-diagnostic-*");
+ ASSERT_TRUE(File1Options->Checks.has_value());
+ EXPECT_EQ(*File1Options->Checks, "-*,clang-diagnostic-*,readability-*");
+ ASSERT_TRUE(File2Options->Checks.has_value());
+ EXPECT_EQ(*File2Options->Checks, "bugprone-*,misc-*,clang-diagnostic-*");
// 2 and 3 should use the same config so these should also be the same.
- EXPECT_EQ(File2Options.Checks, File3Options.Checks);
+ EXPECT_EQ(File2Options->Checks, File3Options->Checks);
}
----------------
galenelias wrote:
I couldn't find any tests which exercise `clangTidyMain` (which makes sense, as that is not really the layer a unit test would operate on. The best place I could find to put a test was near the ClangTidyOptionsProvider.InMemoryFileSystems test, which at least tests the behavior with multiple configuration files, as well as some amount of the propagation logic.
I will go ahead and add a test there unless there is a more appropriate spot for verifying the high level "early exit code 1" behavior of the PR.
https://github.com/llvm/llvm-project/pull/136167
More information about the cfe-commits
mailing list