1 //===-- TidyProviderTests.cpp - Clang tidy configuration provider tests ---===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 #include "TidyProvider.h"
11 #include "gtest/gtest.h"
18 TEST(TidyProvider
, NestedDirectories
) {
20 FS
.Files
[testPath(".clang-tidy")] = R
"yaml(
25 FS
.Files
[testPath("sub1/.clang-tidy")] = R
"yaml(
30 FS
.Files
[testPath("sub1/sub2/.clang-tidy")] = R
"yaml(
34 InheritParentConfig: true
37 TidyProvider Provider
= provideClangTidyFiles(FS
);
39 auto BaseOptions
= getTidyOptionsForFile(Provider
, testPath("File.cpp"));
40 ASSERT_TRUE(BaseOptions
.Checks
.has_value());
41 EXPECT_EQ(*BaseOptions
.Checks
, "llvm-*");
42 EXPECT_EQ(BaseOptions
.CheckOptions
.lookup("TestKey").Value
, "1");
44 auto Sub1Options
= getTidyOptionsForFile(Provider
, testPath("sub1/File.cpp"));
45 ASSERT_TRUE(Sub1Options
.Checks
.has_value());
46 EXPECT_EQ(*Sub1Options
.Checks
, "misc-*");
47 EXPECT_EQ(Sub1Options
.CheckOptions
.lookup("TestKey").Value
, "2");
50 getTidyOptionsForFile(Provider
, testPath("sub1/sub2/File.cpp"));
51 ASSERT_TRUE(Sub2Options
.Checks
.has_value());
52 EXPECT_EQ(*Sub2Options
.Checks
, "misc-*,bugprone-*");
53 EXPECT_EQ(Sub2Options
.CheckOptions
.lookup("TestKey").Value
, "3");