xref: /llvm-project/clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp (revision cc54129b983799e1aaea77aa0ff3040dc30cbc8c)
1885c5593SDmitri Gribenko // RUN: clang-tidy -dump-config %S/Inputs/config-files/- -- | FileCheck %s -check-prefix=CHECK-BASE
2885c5593SDmitri Gribenko // CHECK-BASE: Checks: {{.*}}from-parent
3885c5593SDmitri Gribenko // CHECK-BASE: HeaderFilterRegex: parent
4*cc54129bSJustin Cady // CHECK-BASE: ExcludeHeaderFilterRegex: exc-parent
5885c5593SDmitri Gribenko // RUN: clang-tidy -dump-config %S/Inputs/config-files/1/- -- | FileCheck %s -check-prefix=CHECK-CHILD1
6885c5593SDmitri Gribenko // CHECK-CHILD1: Checks: {{.*}}from-child1
7885c5593SDmitri Gribenko // CHECK-CHILD1: HeaderFilterRegex: child1
8*cc54129bSJustin Cady // CHECK-CHILD1: ExcludeHeaderFilterRegex: exc-child1
9885c5593SDmitri Gribenko // RUN: clang-tidy -dump-config %S/Inputs/config-files/2/- -- | FileCheck %s -check-prefix=CHECK-CHILD2
10885c5593SDmitri Gribenko // CHECK-CHILD2: Checks: {{.*}}from-parent
11885c5593SDmitri Gribenko // CHECK-CHILD2: HeaderFilterRegex: parent
12*cc54129bSJustin Cady // CHECK-CHILD2: ExcludeHeaderFilterRegex: exc-parent
13cb1ee34eSDmitry Polukhin // RUN: clang-tidy -dump-config %S/Inputs/config-files/3/- -- | FileCheck %s -check-prefix=CHECK-CHILD3
14cb1ee34eSDmitry Polukhin // CHECK-CHILD3: Checks: {{.*}}from-parent,from-child3
15cb1ee34eSDmitry Polukhin // CHECK-CHILD3: HeaderFilterRegex: child3
16*cc54129bSJustin Cady // CHECK-CHILD3: ExcludeHeaderFilterRegex: exc-child3
17*cc54129bSJustin Cady // RUN: clang-tidy -dump-config -checks='from-command-line' -header-filter='from command line' -exclude-header-filter='from_command_line' %S/Inputs/config-files/- -- | FileCheck %s -check-prefix=CHECK-COMMAND-LINE
18885c5593SDmitri Gribenko // CHECK-COMMAND-LINE: Checks: {{.*}}from-parent,from-command-line
19885c5593SDmitri Gribenko // CHECK-COMMAND-LINE: HeaderFilterRegex: from command line
20*cc54129bSJustin Cady // CHECK-COMMAND-LINE: ExcludeHeaderFilterRegex: from_command_line
21cb1ee34eSDmitry Polukhin 
22cb1ee34eSDmitry Polukhin // For this test we have to use names of the real checks because otherwise values are ignored.
23fbf611edSNathan James // Running with the old key: <Key>, value: <value> CheckOptions
24cb1ee34eSDmitry Polukhin // RUN: clang-tidy -dump-config %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-CHILD4
25fbf611edSNathan James // Running with the new <key>: <value> syntax
26fbf611edSNathan James // RUN: clang-tidy -dump-config %S/Inputs/config-files/4/key-dict/- -- | FileCheck %s -check-prefix=CHECK-CHILD4
27fbf611edSNathan James 
28cb1ee34eSDmitry Polukhin // CHECK-CHILD4: Checks: {{.*}}modernize-loop-convert,modernize-use-using,llvm-qualified-auto
29fbf611edSNathan James // CHECK-CHILD4-DAG: llvm-qualified-auto.AddConstToQualified: 'true'
30fbf611edSNathan James // CHECK-CHILD4-DAG: modernize-loop-convert.MaxCopySize: '20'
31fbf611edSNathan James // CHECK-CHILD4-DAG: modernize-loop-convert.MinConfidence: reasonable
32fbf611edSNathan James // CHECK-CHILD4-DAG: modernize-use-using.IgnoreMacros: 'false'
33cb1ee34eSDmitry Polukhin 
34cb1ee34eSDmitry Polukhin // RUN: clang-tidy --explain-config %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-EXPLAIN
3599e4061bSNico Weber // CHECK-EXPLAIN: 'llvm-qualified-auto' is enabled in the {{.*}}{{[/\\]}}Inputs{{[/\\]}}config-files{{[/\\]}}4{{[/\\]}}44{{[/\\]}}.clang-tidy.
3699e4061bSNico Weber // CHECK-EXPLAIN: 'modernize-loop-convert' is enabled in the {{.*}}{{[/\\]}}Inputs{{[/\\]}}config-files{{[/\\]}}4{{[/\\]}}.clang-tidy.
3799e4061bSNico Weber // CHECK-EXPLAIN: 'modernize-use-using' is enabled in the {{.*}}{{[/\\]}}Inputs{{[/\\]}}config-files{{[/\\]}}4{{[/\\]}}.clang-tidy.
384836188aSNathan James 
394836188aSNathan James // RUN: clang-tidy -dump-config \
404836188aSNathan James // RUN: --config='{InheritParentConfig: true, \
414836188aSNathan James // RUN: Checks: -llvm-qualified-auto, \
424836188aSNathan James // RUN: CheckOptions: [{key: modernize-loop-convert.MaxCopySize, value: 21}]}' \
434836188aSNathan James // RUN: %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-CHILD5
44fbf611edSNathan James // Also test with the {Key: Value} Syntax specified on command line
45fbf611edSNathan James // RUN: clang-tidy -dump-config \
46fbf611edSNathan James // RUN: --config='{InheritParentConfig: true, \
47fbf611edSNathan James // RUN: Checks: -llvm-qualified-auto, \
48fbf611edSNathan James // RUN: CheckOptions: {modernize-loop-convert.MaxCopySize: 21}}' \
49fbf611edSNathan James // RUN: %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-CHILD5
50fbf611edSNathan James 
514836188aSNathan James // CHECK-CHILD5: Checks: {{.*}}modernize-loop-convert,modernize-use-using,llvm-qualified-auto,-llvm-qualified-auto
52fbf611edSNathan James // CHECK-CHILD5-DAG: modernize-loop-convert.MaxCopySize: '21'
53fbf611edSNathan James // CHECK-CHILD5-DAG: modernize-loop-convert.MinConfidence: reasonable
54fbf611edSNathan James // CHECK-CHILD5-DAG: modernize-use-using.IgnoreMacros: 'false'
554836188aSNathan James 
564836188aSNathan James // RUN: clang-tidy -dump-config \
574836188aSNathan James // RUN: --config='{InheritParentConfig: false, \
584836188aSNathan James // RUN: Checks: -llvm-qualified-auto}' \
594836188aSNathan James // RUN: %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-CHILD6
6045a720a8SNathan James // CHECK-CHILD6: Checks: {{.*-llvm-qualified-auto'? *$}}
61fbf611edSNathan James // CHECK-CHILD6-NOT: modernize-use-using.IgnoreMacros
623d9a64f7SPiotr Zegar 
637a73da4cSFelix // RUN: clang-tidy -dump-config \
647a73da4cSFelix // RUN: --config='{CheckOptions: {readability-function-size.LineThreshold: ""}, \
657a73da4cSFelix // RUN: Checks: readability-function-size}' \
667a73da4cSFelix // RUN: %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-CHILD7
677a73da4cSFelix // CHECK-CHILD7: readability-function-size.LineThreshold: none
687a73da4cSFelix 
697a73da4cSFelix 
703d9a64f7SPiotr Zegar // Validate that check options are printed in alphabetical order:
713d9a64f7SPiotr Zegar // RUN: clang-tidy --checks="-*,readability-identifier-naming" --dump-config %S/Inputs/config-files/- -- | grep "readability-identifier-naming\." | sort --check
72c52b18d1Sealcdan 
73c52b18d1Sealcdan // Dumped config does not overflow for unsigned options
749c8b0d4eSHans Wennborg // RUN: clang-tidy --dump-config %S/Inputs/config-files/5/- -- | FileCheck %s -check-prefix=CHECK-OVERFLOW
759c8b0d4eSHans Wennborg // CHECK-OVERFLOW: misc-throw-by-value-catch-by-reference.MaxSize: '1152921504606846976'
76*cc54129bSJustin Cady 
77*cc54129bSJustin Cady // RUN: clang-tidy -dump-config -checks='readability-function-size' -header-filter='foo/*' -exclude-header-filter='bar*' %S/Inputs/config-files/- -- | FileCheck %s -check-prefix=CHECK-EXCLUDE-HEADERS
78*cc54129bSJustin Cady // CHECK-EXCLUDE-HEADERS: HeaderFilterRegex: 'foo/*'
79*cc54129bSJustin Cady // CHECK-EXCLUDE-HEADERS: ExcludeHeaderFilterRegex: 'bar*'
80*cc54129bSJustin Cady 
81*cc54129bSJustin Cady // RUN: clang-tidy -dump-config -checks='readability-function-size' -header-filter='' -exclude-header-filter='' %S/Inputs/config-files/- -- | FileCheck %s -check-prefix=EMPTY-CHECK-EXCLUDE-HEADERS
82*cc54129bSJustin Cady // EMPTY-CHECK-EXCLUDE-HEADERS: HeaderFilterRegex: ''
83*cc54129bSJustin Cady // EMPTY-CHECK-EXCLUDE-HEADERS: ExcludeHeaderFilterRegex: ''
84