Author: Baranov Victor Date: 2026-06-16T10:02:45+03:00 New Revision: 2e36f066212d134bd2e249fb280a1112edd9c50c
URL: https://github.com/llvm/llvm-project/commit/2e36f066212d134bd2e249fb280a1112edd9c50c DIFF: https://github.com/llvm/llvm-project/commit/2e36f066212d134bd2e249fb280a1112edd9c50c.diff LOG: [clang-tidy][NFC] Add more test coverage for tidy errors (#203987) Added: clang-tools-extra/test/clang-tidy/infrastructure/cli-argument-errors.cpp clang-tools-extra/test/clang-tidy/infrastructure/config-file-parse-errors.cpp clang-tools-extra/test/clang-tidy/infrastructure/config-option-errors.cpp clang-tools-extra/test/clang-tidy/infrastructure/export-fixes-errors.cpp clang-tools-extra/test/clang-tidy/infrastructure/list-checks-no-checks.cpp clang-tools-extra/test/clang-tidy/infrastructure/vfsoverlay-errors.cpp Modified: Removed: ################################################################################ diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/cli-argument-errors.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/cli-argument-errors.cpp new file mode 100644 index 0000000000000..68acb72f69333 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/infrastructure/cli-argument-errors.cpp @@ -0,0 +1,13 @@ +// RUN: not clang-tidy -- 2>&1 | FileCheck %s -check-prefix=CHECK-NO-INPUT +// CHECK-NO-INPUT: Error: no input files specified. + +// RUN: not clang-tidy -checks='-*' %s -- 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-NO-CHECKS +// CHECK-NO-CHECKS: Error: no checks enabled. + +// OK with --allow-no-checks +// RUN: clang-tidy -checks='-*' --allow-no-checks %s -- 2>&1 | count 0 + +// RUN: not clang-tidy --line-filter='not json' %s -- 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-LINE-FILTER +// CHECK-LINE-FILTER: Invalid LineFilter: diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/config-file-parse-errors.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/config-file-parse-errors.cpp new file mode 100644 index 0000000000000..ac3c230e0e3cc --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/infrastructure/config-file-parse-errors.cpp @@ -0,0 +1,10 @@ +// RUN: rm -rf %t.dir +// RUN: mkdir -p %t.dir +// RUN: echo 'not valid yaml: ][' > %t.dir/.clang-tidy +// RUN: cp %s %t.dir/test.cpp +// RUN: clang-tidy %t.dir/test.cpp -checks='misc-explicit-constructor' -- 2>&1 \ +// RUN: | FileCheck %s + +// CHECK: Error parsing {{.*}}.clang-tidy: + +class A { A(int) {} }; diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/config-option-errors.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/config-option-errors.cpp new file mode 100644 index 0000000000000..46265b2538d2e --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/infrastructure/config-option-errors.cpp @@ -0,0 +1,13 @@ +// RUN: not clang-tidy --config='not valid yaml: ][' \ +// RUN: -checks='misc-explicit-constructor' %s -- 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-INVALID +// CHECK-INVALID: Error: invalid configuration specified. + +// RUN: not clang-tidy --config='{}' --config-file=%S/Inputs/config-file/config-file %s -- 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-MUTUAL +// CHECK-MUTUAL: Error: --config-file and --config are mutually exclusive. + +// RUN: not clang-tidy --config-file=%t.nonexistent \ +// RUN: -checks='misc-explicit-constructor' %s -- 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-NOT-FOUND +// CHECK-NOT-FOUND: Error: can't read config-file '{{.*}}.nonexistent': diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/export-fixes-errors.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/export-fixes-errors.cpp new file mode 100644 index 0000000000000..3203c485b6d5e --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/infrastructure/export-fixes-errors.cpp @@ -0,0 +1,8 @@ +// RUN: not clang-tidy \ +// RUN: --export-fixes=%t.no-such-directory/fixes.yaml \ +// RUN: -checks='misc-explicit-constructor' %s -- 2>&1 \ +// RUN: | FileCheck %s + +// CHECK: Error opening output file: + +class A { A(int) {} }; diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/list-checks-no-checks.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/list-checks-no-checks.cpp new file mode 100644 index 0000000000000..d2abd2d0e5bb3 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/infrastructure/list-checks-no-checks.cpp @@ -0,0 +1,7 @@ +// RUN: not clang-tidy --list-checks -checks='-*' -- 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-ERROR +// CHECK-ERROR: No checks enabled. + +// RUN: clang-tidy --list-checks -checks='-*' --allow-no-checks -- 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-OK +// CHECK-OK: Enabled checks: diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/vfsoverlay-errors.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/vfsoverlay-errors.cpp new file mode 100644 index 0000000000000..2e568853de009 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/infrastructure/vfsoverlay-errors.cpp @@ -0,0 +1,11 @@ +// RUN: not clang-tidy --vfsoverlay=%t.nonexistent.yaml \ +// RUN: -checks='misc-explicit-constructor' %s -- 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-MISSING +// CHECK-MISSING: Can't load virtual filesystem overlay file '{{.*}}.nonexistent.yaml': + +// Malformed overlay YAML. +// RUN: echo 'not valid yaml: ][' > %t.invalid.yaml +// RUN: not clang-tidy --vfsoverlay=%t.invalid.yaml \ +// RUN: -checks='misc-explicit-constructor' %s -- 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-INVALID +// CHECK-INVALID: Error: invalid virtual filesystem overlay file '{{.*}}.invalid.yaml'. _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
