[clang-tools-extra] 38b1a17 - [clang-tidy] allow tests to use --config-file instead of --config
Piotr Zegar via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 20 11:06:59 PST 2023
Author: Alexis Murzeau
Date: 2023-02-20T19:06:45Z
New Revision: 38b1a17c519d3873f413156c302cb7ed0d39ee3d
URL: https://github.com/llvm/llvm-project/commit/38b1a17c519d3873f413156c302cb7ed0d39ee3d
DIFF: https://github.com/llvm/llvm-project/commit/38b1a17c519d3873f413156c302cb7ed0d39ee3d.diff
LOG: [clang-tidy] allow tests to use --config-file instead of --config
The previous way to test hungarian notation doesn't check CHECK-FIXES.
This will allow readability-identifier-naming tests of Hungarian
notation to keep the use of an external .clang-tidy file (not embedded
within the .cpp test file) and properly check CHECK-FIXES.
Also, it turns out the hungarian notation tests use the wrong
.clang-tidy file, so fix that too to make these tests ok.
This is a part of a fix for issue https://github.com/llvm/llvm-project/issues/60670.
Reviewed By: carlosgalvezp
Differential Revision: https://reviews.llvm.org/D144037
Added:
Modified:
clang-tools-extra/test/clang-tidy/check_clang_tidy.py
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation-cfgfile.cpp
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
index 760550abd41bc..f2d9f40fe568c 100755
--- a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -107,9 +107,10 @@ def __init__(self, args, extra_args):
# If the test does not specify a config style, force an empty one; otherwise
# auto-detection logic can discover a ".clang-tidy" file that is not related to
# the test.
- if not any(
- [arg.startswith('-config=') for arg in self.clang_tidy_extra_args]):
- self.clang_tidy_extra_args.append('-config={}')
+ if not any([
+ re.match('^-?-config(-file)?=', arg)
+ for arg in self.clang_tidy_extra_args]):
+ self.clang_tidy_extra_args.append('--config={}')
if extension in ['.m', '.mm']:
self.clang_extra_args = ['-fobjc-abi-version=2', '-fobjc-arc', '-fblocks'] + \
diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation-cfgfile.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation-cfgfile.cpp
index 60a4d9b7464c1..4efc455aa3ce9 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation-cfgfile.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation-cfgfile.cpp
@@ -1,5 +1,4 @@
-// RUN: clang-tidy %s --config-file=%S/Inputs/identifier-naming/hungarian-notation1/.clang-tidy 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK-MESSAGES %s
+// RUN: %check_clang_tidy %s readability-identifier-naming %t -- --config-file=%S/Inputs/identifier-naming/hungarian-notation2/.clang-tidy
// clang-format off
typedef signed char int8_t; // NOLINT
diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation.cpp
index 18a39b15b0c5e..83aa88758e138 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation.cpp
@@ -1,5 +1,4 @@
-// RUN: clang-tidy %s --config-file=%S/Inputs/identifier-naming/hungarian-notation2/.clang-tidy 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK-MESSAGES %s
+// RUN: %check_clang_tidy %s readability-identifier-naming %t -- --config-file=%S/Inputs/identifier-naming/hungarian-notation1/.clang-tidy
// clang-format off
typedef signed char int8_t; // NOLINT
More information about the cfe-commits
mailing list