1// RUN: mkdir -p %T/compilation-database-test/include
2// RUN: mkdir -p %T/compilation-database-test/a
3// RUN: mkdir -p %T/compilation-database-test/b
4// RUN: echo 'int *AA = 0;' > %T/compilation-database-test/a/a.cpp
5// RUN: echo 'int *AB = 0;' > %T/compilation-database-test/a/b.cpp
6// RUN: echo 'int *BB = 0;' > %T/compilation-database-test/b/b.cpp
7// RUN: echo 'int *BC = 0;' > %T/compilation-database-test/b/c.cpp
8// RUN: echo 'int *BD = 0;' > %T/compilation-database-test/b/d.cpp
9// RUN: echo 'int *HP = 0;' > %T/compilation-database-test/include/header.h
10// RUN: echo '#include "header.h"' > %T/compilation-database-test/include.cpp
11// RUN: sed 's|test_dir|%/T/compilation-database-test|g' %S/Inputs/compilation-database/template.json > %T/compile_commands.json
12
13// Regression test: shouldn't crash.
14// RUN: not clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/b/not-exist -header-filter=.* 2>&1 | FileCheck %s -check-prefix=CHECK-NOT-EXIST
15// CHECK-NOT-EXIST: Error while processing {{.*[/\\]}}not-exist.
16// CHECK-NOT-EXIST: unable to handle compilation
17// CHECK-NOT-EXIST: Found compiler error
18
19// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/a/a.cpp %T/compilation-database-test/a/b.cpp %T/compilation-database-test/b/b.cpp %T/compilation-database-test/b/c.cpp %T/compilation-database-test/b/d.cpp %T/compilation-database-test/include.cpp -header-filter=.* -fix
20// RUN: FileCheck -input-file=%T/compilation-database-test/a/a.cpp %s -check-prefix=CHECK-FIX1
21// RUN: FileCheck -input-file=%T/compilation-database-test/a/b.cpp %s -check-prefix=CHECK-FIX2
22// RUN: FileCheck -input-file=%T/compilation-database-test/b/b.cpp %s -check-prefix=CHECK-FIX3
23// RUN: FileCheck -input-file=%T/compilation-database-test/b/c.cpp %s -check-prefix=CHECK-FIX4
24// RUN: FileCheck -input-file=%T/compilation-database-test/b/d.cpp %s -check-prefix=CHECK-FIX5
25// RUN: FileCheck -input-file=%T/compilation-database-test/include/header.h %s -check-prefix=CHECK-FIX6
26
27// CHECK-FIX1: int *AA = nullptr;
28// CHECK-FIX2: int *AB = nullptr;
29// CHECK-FIX3: int *BB = nullptr;
30// CHECK-FIX4: int *BC = nullptr;
31// CHECK-FIX5: int *BD = nullptr;
32// CHECK-FIX6: int *HP = nullptr;
33

source code of clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-run-with-database.cpp