zturner created this revision.
zturner added reviewers: alexfh, klimek, djasper.
zturner added a subscriber: cfe-commits.

This allows the test to run on windows, and also makes writing compilation 
database tests easier in general.  See D23532 for more information.

https://reviews.llvm.org/D23533

Files:
  test/clang-tidy/Inputs/compilation-database/a/a.cpp
  test/clang-tidy/Inputs/compilation-database/a/b.cpp
  test/clang-tidy/Inputs/compilation-database/b/b.cpp
  test/clang-tidy/Inputs/compilation-database/b/c.cpp
  test/clang-tidy/Inputs/compilation-database/b/d.cpp
  test/clang-tidy/Inputs/compilation-database/clang-tidy-database.json
  test/clang-tidy/Inputs/compilation-database/include/header.h
  test/clang-tidy/Inputs/compilation-database/template.json
  test/clang-tidy/clang-tidy-run-with-database.cpp

Index: test/clang-tidy/clang-tidy-run-with-database.cpp
===================================================================
--- test/clang-tidy/clang-tidy-run-with-database.cpp
+++ test/clang-tidy/clang-tidy-run-with-database.cpp
@@ -1,24 +1,35 @@
-// REQUIRES: shell
-// RUN: mkdir -p %T/compilation-database-test/include
-// RUN: mkdir -p %T/compilation-database-test/a
-// RUN: mkdir -p %T/compilation-database-test/b
-// RUN: echo 'int *AA = 0;' > %T/compilation-database-test/a/a.cpp
-// RUN: echo 'int *AB = 0;' > %T/compilation-database-test/a/b.cpp
-// RUN: echo 'int *BB = 0;' > %T/compilation-database-test/b/b.cpp
-// RUN: echo 'int *BC = 0;' > %T/compilation-database-test/b/c.cpp
-// RUN: echo 'int *HP = 0;' > %T/compilation-database-test/include/header.h
-// RUN: echo '#include "header.h"' > %T/compilation-database-test/b/d.cpp
-// RUN: sed 's|test_dir|%T/compilation-database-test|g' %S/Inputs/compilation-database/template.json > %T/compile_commands.json
-// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/b/not-exist -header-filter=.*
-// 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 -header-filter=.* -fix
-// RUN: FileCheck -input-file=%T/compilation-database-test/a/a.cpp %s -check-prefix=CHECK-FIX1
-// RUN: FileCheck -input-file=%T/compilation-database-test/a/b.cpp %s -check-prefix=CHECK-FIX2
-// RUN: FileCheck -input-file=%T/compilation-database-test/b/b.cpp %s -check-prefix=CHECK-FIX3
-// RUN: FileCheck -input-file=%T/compilation-database-test/b/c.cpp %s -check-prefix=CHECK-FIX4
-// RUN: FileCheck -input-file=%T/compilation-database-test/include/header.h %s -check-prefix=CHECK-FIX5
+// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %S/Inputs/compilation-database/clang-tidy-database.json \
+// RUN: -r %S/Inputs/compilation-database %S/Inputs/compilation-database/a/a.cpp %S/Inputs/compilation-database/a/b.cpp \
+// RUN: %S/Inputs/compilation-database/b/b.cpp %S/Inputs/compilation-database/b/c.cpp %S/Inputs/compilation-database/b/d.cpp \
+// RUN: -header-filter=.* -export-fixes=%t.yaml > %t.msg 2>&1
+// RUN: FileCheck -input-file=%t.msg -check-prefix=CHECK-MESSAGES %s
+// RUN: FileCheck -input-file=%t.yaml -check-prefix=CHECK-YAML %s
 
-// CHECK-FIX1: int *AA = nullptr;
-// CHECK-FIX2: int *AB = nullptr;
-// CHECK-FIX3: int *BB = nullptr;
-// CHECK-FIX4: int *BC = nullptr;
-// CHECK-FIX5: int *HP = nullptr;
+// CHECK-MESSAGES: int *AA = 0;
+// CHECK-MESSAGES: int *AB = 0;
+// CHECK-MESSAGES: int *BB = 0;
+// CHECK-MESSAGES: int *BC = 0;
+// CHECK-MESSAGES: int *HP = 0;
+
+// CHECK-YAML: MainSourceFile:  ''
+// CHECK-YAML: Replacements:
+// CHECK-YAML:   - FilePath:        a.cpp
+// CHECK-YAML:     Offset:          10
+// CHECK-YAML:     Length:          1
+// CHECK-YAML:     ReplacementText: nullptr
+// CHECK-YAML:   - FilePath:        b.cpp
+// CHECK-YAML:     Offset:          10
+// CHECK-YAML:     Length:          1
+// CHECK-YAML:     ReplacementText: nullptr
+// CHECK-YAML:   - FilePath:        b{{[/\\]}}b.cpp
+// CHECK-YAML:     Offset:          10
+// CHECK-YAML:     Length:          1
+// CHECK-YAML:     ReplacementText: nullptr
+// CHECK-YAML:   - FilePath:        ..{{[/\\]}}b{{[/\\]}}c.cpp
+// CHECK-YAML:     Offset:          10
+// CHECK-YAML:     Length:          1
+// CHECK-YAML:     ReplacementText: nullptr
+// CHECK-YAML:   - FilePath:        '..{{[/\\]}}include{{[/\\]}}header.h'
+// CHECK-YAML:     Offset:          10
+// CHECK-YAML:     Length:          1
+// CHECK-YAML:     ReplacementText: nullptr
\ No newline at end of file
Index: test/clang-tidy/Inputs/compilation-database/template.json
===================================================================
--- test/clang-tidy/Inputs/compilation-database/template.json
+++ /dev/null
@@ -1,32 +0,0 @@
-[
-{
-  "directory": "test_dir/a",
-  "command": "clang++ -o test.o test_dir/a/a.cpp",
-  "file": "test_dir/a/a.cpp"
-},
-{
-  "directory": "test_dir/a",
-  "command": "clang++ -o test.o test_dir/a/b.cpp",
-  "file": "test_dir/a/b.cpp"
-},
-{
-  "directory": "test_dir/",
-  "command": "clang++ -o test.o test_dir/b/b.cpp",
-  "file": "test_dir/b/b.cpp"
-},
-{
-  "directory": "test_dir/b",
-  "command": "clang++ -o test.o ../b/c.cpp",
-  "file": "test_dir/b/c.cpp"
-},
-{
-  "directory": "test_dir/b",
-  "command": "clang++ -I../include -o test.o ../b/d.cpp",
-  "file": "test_dir/b/d.cpp"
-},
-{
-  "directory": "test_dir/",
-  "command": "clang++ -o test.o test_dir/b/not-exist.cpp",
-  "file": "test_dir/b/not-exist.cpp"
-}
-]
Index: test/clang-tidy/Inputs/compilation-database/include/header.h
===================================================================
--- /dev/null
+++ test/clang-tidy/Inputs/compilation-database/include/header.h
@@ -0,0 +1 @@
+int *HP = 0;
Index: test/clang-tidy/Inputs/compilation-database/clang-tidy-database.json
===================================================================
--- /dev/null
+++ test/clang-tidy/Inputs/compilation-database/clang-tidy-database.json
@@ -0,0 +1,32 @@
+[
+{
+  "directory": "a",
+  "command": "clang++ -o test.o a.cpp",
+  "file": "a.cpp"
+},
+{
+  "directory": "a",
+  "command": "clang++ -o test.o b.cpp",
+  "file": "b.cpp"
+},
+{
+  "directory": "",
+  "command": "clang++ -o test.o b/b.cpp",
+  "file": "b/b.cpp"
+},
+{
+  "directory": "b",
+  "command": "clang++ -o test.o ../b/c.cpp",
+  "file": "c.cpp"
+},
+{
+  "directory": "b",
+  "command": "clang++ -I../include -o test.o ../b/d.cpp",
+  "file": "d.cpp"
+},
+{
+  "directory": "",
+  "command": "clang++ -o test.o b/not-exist.cpp",
+  "file": "not-exist.cpp"
+}
+]
Index: test/clang-tidy/Inputs/compilation-database/b/d.cpp
===================================================================
--- /dev/null
+++ test/clang-tidy/Inputs/compilation-database/b/d.cpp
@@ -0,0 +1 @@
+#include "header.h"
Index: test/clang-tidy/Inputs/compilation-database/b/c.cpp
===================================================================
--- /dev/null
+++ test/clang-tidy/Inputs/compilation-database/b/c.cpp
@@ -0,0 +1 @@
+int *BC = 0;
Index: test/clang-tidy/Inputs/compilation-database/b/b.cpp
===================================================================
--- /dev/null
+++ test/clang-tidy/Inputs/compilation-database/b/b.cpp
@@ -0,0 +1 @@
+int *BB = 0;
Index: test/clang-tidy/Inputs/compilation-database/a/b.cpp
===================================================================
--- /dev/null
+++ test/clang-tidy/Inputs/compilation-database/a/b.cpp
@@ -0,0 +1 @@
+int *AB = 0;
Index: test/clang-tidy/Inputs/compilation-database/a/a.cpp
===================================================================
--- /dev/null
+++ test/clang-tidy/Inputs/compilation-database/a/a.cpp
@@ -0,0 +1 @@
+int *AA = 0;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to