summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2018-04-09 15:12:10 +0000
committerAlexander Kornienko <alexfh@google.com>2018-04-09 15:12:10 +0000
commitc3ad02e84009a2d32501cde8704b3b1271944184 (patch)
tree848c075312633eff1073ec879043be3187f6aedc /clang-tools-extra/test/clang-tidy
parente9a5a2f10ca1d04fbf06b50dcb052711b8ddb1e7 (diff)
downloadbcm5719-llvm-c3ad02e84009a2d32501cde8704b3b1271944184.tar.gz
bcm5719-llvm-c3ad02e84009a2d32501cde8704b3b1271944184.zip
[clang-tidy] Return non-zero exit code for clang errors.
Summary: Updated tests broken by this change. Fixes https://bugs.llvm.org/show_bug.cgi?id=27628 Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: klimek, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D45258 llvm-svn: 329579
Diffstat (limited to 'clang-tools-extra/test/clang-tidy')
-rw-r--r--clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-fail.cpp6
-rwxr-xr-xclang-tools-extra/test/clang-tidy/check_clang_tidy.py4
-rw-r--r--clang-tools-extra/test/clang-tidy/diagnostic.cpp30
-rw-r--r--clang-tools-extra/test/clang-tidy/fix-errors.cpp2
-rw-r--r--clang-tools-extra/test/clang-tidy/misc-misplaced-const-cxx17.cpp2
-rw-r--r--clang-tools-extra/test/clang-tidy/misc-unused-using-decls-errors.cpp2
-rw-r--r--clang-tools-extra/test/clang-tidy/modernize-loop-convert-assert-failure.cpp2
-rw-r--r--clang-tools-extra/test/clang-tidy/readability-braces-around-statements-assert-failure.cpp2
-rw-r--r--clang-tools-extra/test/clang-tidy/serialize-diagnostics.cpp2
9 files changed, 34 insertions, 18 deletions
diff --git a/clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-fail.cpp b/clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-fail.cpp
index db270d8c21d..45fa2262f6d 100644
--- a/clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-fail.cpp
+++ b/clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-fail.cpp
@@ -1,7 +1,9 @@
-// RUN: clang-tidy %s -checks="-*,bugprone-suspicious-semicolon" -- -DERROR 2>&1 \
+// RUN: not clang-tidy %s \
+// RUN: -checks="-*,bugprone-suspicious-semicolon" -- -DERROR 2>&1 \
// RUN: | FileCheck %s -check-prefix=CHECK-ERROR \
// RUN: -implicit-check-not="{{warning|error}}:"
-// RUN: clang-tidy %s -checks="-*,bugprone-suspicious-semicolon,clang-diagnostic*" \
+// RUN: not clang-tidy %s \
+// RUN: -checks="-*,bugprone-suspicious-semicolon,clang-diagnostic*" \
// RUN: -- -DWERROR -Wno-everything -Werror=unused-variable 2>&1 \
// RUN: | FileCheck %s -check-prefix=CHECK-WERROR \
// RUN: -implicit-check-not="{{warning|error}}:"
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 1ade4cdc745..7fa03992bb7 100755
--- a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -39,6 +39,7 @@ def write_file(file_name, text):
def main():
parser = argparse.ArgumentParser()
+ parser.add_argument('-expect-clang-tidy-error', action='store_true')
parser.add_argument('-resource-dir')
parser.add_argument('-assume-filename')
parser.add_argument('input_file_name')
@@ -52,6 +53,7 @@ def main():
input_file_name = args.input_file_name
check_name = args.check_name
temp_file_name = args.temp_file_name
+ expect_clang_tidy_error = args.expect_clang_tidy_error
file_name_with_extension = assume_file_name or input_file_name
_, extension = os.path.splitext(file_name_with_extension)
@@ -97,6 +99,8 @@ def main():
args = ['clang-tidy', temp_file_name, '-fix', '--checks=-*,' + check_name] + \
clang_tidy_extra_args
+ if expect_clang_tidy_error:
+ args.insert(0, 'not')
print('Running ' + repr(args) + '...')
try:
clang_tidy_output = \
diff --git a/clang-tools-extra/test/clang-tidy/diagnostic.cpp b/clang-tools-extra/test/clang-tidy/diagnostic.cpp
index 656e05b7ece..d12fc7b7a86 100644
--- a/clang-tools-extra/test/clang-tidy/diagnostic.cpp
+++ b/clang-tools-extra/test/clang-tidy/diagnostic.cpp
@@ -1,13 +1,15 @@
-// RUN: clang-tidy -checks='-*,modernize-use-override' %s.nonexistent.cpp -- | FileCheck -check-prefix=CHECK1 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' %s -- -fan-unknown-option | FileCheck -check-prefix=CHECK2 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %s -- -fan-unknown-option | FileCheck -check-prefix=CHECK3 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,modernize-use-override' %s.nonexistent.cpp -- | FileCheck -check-prefix=CHECK1 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' %s -- -fan-unknown-option | FileCheck -check-prefix=CHECK2 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %s -- -fan-unknown-option | FileCheck -check-prefix=CHECK3 -implicit-check-not='{{warning:|error:}}' %s
// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %s -- -DMACRO_FROM_COMMAND_LINE | FileCheck -check-prefix=CHECK4 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,modernize-use-override' %s -- -DCOMPILATION_ERROR | FileCheck -check-prefix=CHECK6 -implicit-check-not='{{warning:|error:}}' %s
//
// Now repeat the tests and ensure no other errors appear on stderr:
-// RUN: clang-tidy -checks='-*,modernize-use-override' %s.nonexistent.cpp -- 2>&1 | FileCheck -check-prefix=CHECK1 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' %s -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK2 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %s -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK3 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,modernize-use-override' %s.nonexistent.cpp -- 2>&1 | FileCheck -check-prefix=CHECK1 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' %s -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK2 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %s -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK3 -implicit-check-not='{{warning:|error:}}' %s
// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %s -- -DMACRO_FROM_COMMAND_LINE 2>&1 | FileCheck -check-prefix=CHECK4 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,modernize-use-override' %s -- -DCOMPILATION_ERROR 2>&1 | FileCheck -check-prefix=CHECK6 -implicit-check-not='{{warning:|error:}}' %s
//
// Now create a directory with a compilation database file and ensure we don't
// use it after failing to parse commands from the command line:
@@ -15,11 +17,12 @@
// RUN: mkdir -p %T/diagnostics/
// RUN: echo '[{"directory": "%/T/diagnostics/","command": "clang++ -fan-option-from-compilation-database -c %/T/diagnostics/input.cpp", "file": "%/T/diagnostics/input.cpp"}]' > %T/diagnostics/compile_commands.json
// RUN: cat %s > %T/diagnostics/input.cpp
-// RUN: clang-tidy -checks='-*,modernize-use-override' %T/diagnostics/nonexistent.cpp -- 2>&1 | FileCheck -check-prefix=CHECK1 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' %T/diagnostics/input.cpp -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK2 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %T/diagnostics/input.cpp -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK3 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,modernize-use-override' %T/diagnostics/nonexistent.cpp -- 2>&1 | FileCheck -check-prefix=CHECK1 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' %T/diagnostics/input.cpp -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK2 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %T/diagnostics/input.cpp -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK3 -implicit-check-not='{{warning:|error:}}' %s
// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %T/diagnostics/input.cpp -- -DMACRO_FROM_COMMAND_LINE 2>&1 | FileCheck -check-prefix=CHECK4 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' %T/diagnostics/input.cpp 2>&1 | FileCheck -check-prefix=CHECK5 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' %T/diagnostics/input.cpp 2>&1 | FileCheck -check-prefix=CHECK5 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,modernize-use-override' %T/diagnostics/input.cpp -- -DCOMPILATION_ERROR 2>&1 | FileCheck -check-prefix=CHECK6 -implicit-check-not='{{warning:|error:}}' %s
// CHECK1: error: error reading '{{.*}}nonexistent.cpp' [clang-diagnostic-error]
// CHECK2: error: unknown argument: '-fan-unknown-option' [clang-diagnostic-error]
@@ -38,3 +41,10 @@ class A { A(int) {} };
#define MACRO_FROM_COMMAND_LINE
// CHECK4: :[[@LINE-1]]:9: warning: 'MACRO_FROM_COMMAND_LINE' macro redefined
+
+#ifdef COMPILATION_ERROR
+void f(int a) {
+ &(a + 1);
+ // CHECK6: :[[@LINE-1]]:3: error: cannot take the address of an rvalue of type 'int' [clang-diagnostic-error]
+}
+#endif
diff --git a/clang-tools-extra/test/clang-tidy/fix-errors.cpp b/clang-tools-extra/test/clang-tidy/fix-errors.cpp
index 639873e2524..0c026163203 100644
--- a/clang-tools-extra/test/clang-tidy/fix-errors.cpp
+++ b/clang-tools-extra/test/clang-tidy/fix-errors.cpp
@@ -1,5 +1,5 @@
// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
-// RUN: clang-tidy %t.cpp -checks='-*,google-explicit-constructor' -fix -- > %t.msg 2>&1
+// RUN: not clang-tidy %t.cpp -checks='-*,google-explicit-constructor' -fix -- > %t.msg 2>&1
// RUN: FileCheck -input-file=%t.cpp -check-prefix=CHECK-FIX %s
// RUN: FileCheck -input-file=%t.msg -check-prefix=CHECK-MESSAGES %s
// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
diff --git a/clang-tools-extra/test/clang-tidy/misc-misplaced-const-cxx17.cpp b/clang-tools-extra/test/clang-tidy/misc-misplaced-const-cxx17.cpp
index d9213cea601..7816a091d7a 100644
--- a/clang-tools-extra/test/clang-tidy/misc-misplaced-const-cxx17.cpp
+++ b/clang-tools-extra/test/clang-tidy/misc-misplaced-const-cxx17.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-misplaced-const %t -- -- -std=c++17
+// RUN: %check_clang_tidy -expect-clang-tidy-error %s misc-misplaced-const %t -- -- -std=c++17
// This test previously would cause a failed assertion because the structured
// binding declaration had no valid type associated with it. This ensures the
diff --git a/clang-tools-extra/test/clang-tidy/misc-unused-using-decls-errors.cpp b/clang-tools-extra/test/clang-tidy/misc-unused-using-decls-errors.cpp
index 5eb380f7739..1c26a6961aa 100644
--- a/clang-tools-extra/test/clang-tidy/misc-unused-using-decls-errors.cpp
+++ b/clang-tools-extra/test/clang-tidy/misc-unused-using-decls-errors.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-unused-using-decls %t
+// RUN: %check_clang_tidy -expect-clang-tidy-error %s misc-unused-using-decls %t
namespace n {
class C;
diff --git a/clang-tools-extra/test/clang-tidy/modernize-loop-convert-assert-failure.cpp b/clang-tools-extra/test/clang-tidy/modernize-loop-convert-assert-failure.cpp
index 1e289017251..fab51dafd2e 100644
--- a/clang-tools-extra/test/clang-tidy/modernize-loop-convert-assert-failure.cpp
+++ b/clang-tools-extra/test/clang-tidy/modernize-loop-convert-assert-failure.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-tidy %s -checks=-*,modernize-loop-convert --
+// RUN: not clang-tidy %s -checks=-*,modernize-loop-convert --
// Note: this test expects no assert failure happened in clang-tidy.
diff --git a/clang-tools-extra/test/clang-tidy/readability-braces-around-statements-assert-failure.cpp b/clang-tools-extra/test/clang-tidy/readability-braces-around-statements-assert-failure.cpp
index 146268709e2..7d619c0ba59 100644
--- a/clang-tools-extra/test/clang-tidy/readability-braces-around-statements-assert-failure.cpp
+++ b/clang-tools-extra/test/clang-tidy/readability-braces-around-statements-assert-failure.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-tidy -checks='-*,readability-braces-around-statements' %s --
+// RUN: not clang-tidy -checks='-*,readability-braces-around-statements' %s --
// Note: this test expects no assert failure happened in clang-tidy.
diff --git a/clang-tools-extra/test/clang-tidy/serialize-diagnostics.cpp b/clang-tools-extra/test/clang-tidy/serialize-diagnostics.cpp
index 804253c7d08..8b0895af795 100644
--- a/clang-tools-extra/test/clang-tidy/serialize-diagnostics.cpp
+++ b/clang-tools-extra/test/clang-tidy/serialize-diagnostics.cpp
@@ -1,3 +1,3 @@
-// RUN: clang-tidy -checks=-*,llvm-namespace-comment %s -- -serialize-diagnostics %t | FileCheck %s
+// RUN: not clang-tidy -checks=-*,llvm-namespace-comment %s -- -serialize-diagnostics %t | FileCheck %s
// CHECK: :[[@LINE+1]]:12: error: expected ';' after struct [clang-diagnostic-error]
struct A {}
OpenPOWER on IntegriCloud