forked from OSchip/llvm-project
[clang-tidy] Organize test files into subdirectories by module (NFC)
Eliminate clutter by reorganizing the Lit test files for clang-tidy: - Move checkers/<module>-* to checkers/<module>/*. - Move module specific inputs from Inputs to <module>/Inputs. Remove any module prefix from the file or subdirectory name as they are no longer needed. - Introduce a Lit substitution %clang_tidy_headers for the system headers in checkers/Inputs/Headers and use this throughout. This avoids referencing system headers through a relative path to the parent directory and makes it clear that these fake system headers are shared among all modules. - Update add_new_check.py to follow the above conventions when creating the boiler plate test files for a new check. - Update Contributing.rst to describe per-module Inputs directory and fix link to test source code. Differential Revision: https://reviews.llvm.org/D128072
This commit is contained in:
parent
130167ed1e
commit
89a1d03e2b
|
@ -278,8 +278,9 @@ def add_release_notes(module_path, module, check_name):
|
|||
# Adds a test for the check.
|
||||
def write_test(module_path, module, check_name, test_extension):
|
||||
check_name_dashes = module + '-' + check_name
|
||||
filename = os.path.normpath(os.path.join(module_path, '../../test/clang-tidy/checkers',
|
||||
check_name_dashes + '.' + test_extension))
|
||||
filename = os.path.normpath(os.path.join(
|
||||
module_path, '..', '..', 'test', 'clang-tidy', 'checkers',
|
||||
module, check_name + '.' + test_extension))
|
||||
print('Creating %s...' % filename)
|
||||
with io.open(filename, 'w', encoding='utf8', newline='\n') as f:
|
||||
f.write("""// RUN: %%check_clang_tidy %%s %(check_name_dashes)s %%t
|
||||
|
|
|
@ -582,7 +582,7 @@ to incorrect parts of the input. Use ``[[@LINE+X]]``/``[[@LINE-X]]``
|
|||
substitutions and distinct function and variable names in the test code.
|
||||
|
||||
Here's an example of a test using the ``check_clang_tidy.py`` script (the full
|
||||
source code is at `test/clang-tidy/google-readability-casting.cpp`_):
|
||||
source code is at `test/clang-tidy/checkers/google/readability-casting.cpp`_):
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
|
@ -632,12 +632,18 @@ most frequent pitfalls are macros and templates:
|
|||
expansions/instantiations.
|
||||
|
||||
If you need multiple files to exercise all the aspects of your check, it is
|
||||
recommended you place them in a subdirectory named for the check under ``Inputs``.
|
||||
This keeps the test directory from getting cluttered.
|
||||
recommended you place them in a subdirectory named for the check under the ``Inputs``
|
||||
directory for the module containing your check. This keeps the test directory from
|
||||
getting cluttered.
|
||||
|
||||
If you need to validate how your check interacts with system header files, a set
|
||||
of simulated system header files is located in the ``checkers/Inputs/Headers``
|
||||
directory. The path to this directory is available in a lit test with the variable
|
||||
``%clang_tidy_headers``.
|
||||
|
||||
.. _lit: https://llvm.org/docs/CommandGuide/lit.html
|
||||
.. _FileCheck: https://llvm.org/docs/CommandGuide/FileCheck.html
|
||||
.. _test/clang-tidy/google-readability-casting.cpp: https://reviews.llvm.org/diffusion/L/browse/clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp
|
||||
.. _test/clang-tidy/checkers/google/readability-casting.cpp: https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/test/clang-tidy/checkers/google/readability-casting.cpp
|
||||
|
||||
Out-of-tree check plugins
|
||||
-------------------------
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// RUN: %check_clang_tidy %s altera-kernel-name-restriction %t -- -- -I%S/Inputs/altera-kernel-name-restriction
|
||||
// RUN: %check_clang_tidy -check-suffix=UPPERCASE %s altera-kernel-name-restriction %t -- -- -I%S/Inputs/altera-kernel-name-restriction/uppercase -DUPPERCASE
|
||||
// RUN: %check_clang_tidy %s altera-kernel-name-restriction %t -- -- -I%S/Inputs/kernel-name-restriction
|
||||
// RUN: %check_clang_tidy -check-suffix=UPPERCASE %s altera-kernel-name-restriction %t -- -- -I%S/Inputs/kernel-name-restriction/uppercase -DUPPERCASE
|
||||
|
||||
#ifdef UPPERCASE
|
||||
// The warning should be triggered regardless of capitalization
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %check_clang_tidy %s bugprone-argument-comment %t -- -- -I %S/Inputs/bugprone-argument-comment
|
||||
// RUN: %check_clang_tidy %s bugprone-argument-comment %t -- -- -I %S/Inputs/argument-comment
|
||||
|
||||
// FIXME: clang-tidy should provide a -verify mode to make writing these checks
|
||||
// easier and more accurate.
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue