|
1 | | -// RUN: clang-tidy -checks=-*,readability-magic-numbers %s -- 2>&1 | FileCheck %s --check-prefix=CHECK-NORMAL |
2 | | -// RUN: clang-tidy -checks=-*,readability-magic-numbers -quiet %s -- 2>&1 | FileCheck %s --check-prefix=CHECK-QUIET |
| 1 | +// This test ensures that the --quiet flag only suppresses the "X warnings generated" |
| 2 | +// message while keeping all diagnostic information including caret indicators (^). |
3 | 3 |
|
4 | | -// Normal mode should show warning count |
5 | | -// CHECK-NORMAL: 1 warning generated |
6 | | -// CHECK-NORMAL: warning: 42 is a magic number |
| 4 | +// RUN: clang-tidy -checks=-*,readability-magic-numbers,clang-diagnostic-sign-compare %s -- \ |
| 5 | +// RUN: -Wsign-compare 2>&1 | FileCheck %s --check-prefix=CHECK-NORMAL |
| 6 | +// RUN: clang-tidy -checks=-*,readability-magic-numbers,clang-diagnostic-sign-compare -quiet %s -- \ |
| 7 | +// RUN: -Wsign-compare 2>&1 | FileCheck %s --check-prefix=CHECK-QUIET |
| 8 | + |
| 9 | +// CHECK-NORMAL: 2 warnings generated |
| 10 | +// CHECK-NORMAL-DAG: warning: 42 is a magic number |
| 11 | +// CHECK-NORMAL-DAG: {{[ ]*\^}} |
| 12 | +// CHECK-NORMAL-DAG: warning: comparison of integers of different signs |
| 13 | +// CHECK-NORMAL-DAG: {{[ ]*~ \^ ~}} |
7 | 14 |
|
8 | | -// Quiet mode should suppress warning count but show diagnostic |
9 | | -// CHECK-QUIET: warning: 42 is a magic number |
10 | 15 | // CHECK-QUIET-NOT: {{[0-9]+}} warning{{s?}} generated |
| 16 | +// CHECK-QUIET-DAG: warning: 42 is a magic number |
| 17 | +// CHECK-QUIET-DAG: {{[ ]*\^}} |
| 18 | +// CHECK-QUIET-DAG: warning: comparison of integers of different signs |
| 19 | +// CHECK-QUIET-DAG: {{[ ]*~ \^ ~}} |
11 | 20 |
|
12 | 21 | int main() { |
13 | | - int x = 42; // This will trigger readability-magic-numbers |
| 22 | + const int CONST_VAL = 10; |
| 23 | + int x = 42; // trigger 'readability-magic-numbers' with caret: ^ |
| 24 | + unsigned int y = CONST_VAL; |
| 25 | + return x < y; // trigger 'clang-diagnostic-sign-compare' with caret: ^ |
14 | 26 | } |
0 commit comments