summaryrefslogtreecommitdiff
path: root/clang-tools-extra/test/clang-move
diff options
context:
space:
mode:
authorHaojian Wu <hokein@google.com>2016-10-04 09:05:31 +0000
committerHaojian Wu <hokein@google.com>2016-10-04 09:05:31 +0000
commite939efb4aca83f1781e745e50b070f6b32048037 (patch)
treeb650b32bb3d0f3c539fde0d1865a8d48a79b6fd3 /clang-tools-extra/test/clang-move
parenta4b0eb5ec56641108ff2ba2d18ddc47fa95556ae (diff)
[clang-move] Make it support both relative and absolute file path arguments.
Reviewers: ioeric Subscribers: beanz, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D24922
Diffstat (limited to 'clang-tools-extra/test/clang-move')
-rw-r--r--clang-tools-extra/test/clang-move/Inputs/database_template.json7
-rw-r--r--clang-tools-extra/test/clang-move/Inputs/test.cpp8
-rw-r--r--clang-tools-extra/test/clang-move/Inputs/test.h6
-rw-r--r--clang-tools-extra/test/clang-move/move-class.cpp39
4 files changed, 60 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-move/Inputs/database_template.json b/clang-tools-extra/test/clang-move/Inputs/database_template.json
new file mode 100644
index 00000000000..2dc567ba2b0
--- /dev/null
+++ b/clang-tools-extra/test/clang-move/Inputs/database_template.json
@@ -0,0 +1,7 @@
+[
+{
+ "directory": "$test_dir/build",
+ "command": "clang++ -o test.o $test_dir/test.cpp",
+ "file": "$test_dir/test.cpp"
+}
+]
diff --git a/clang-tools-extra/test/clang-move/Inputs/test.cpp b/clang-tools-extra/test/clang-move/Inputs/test.cpp
new file mode 100644
index 00000000000..65997abbdb7
--- /dev/null
+++ b/clang-tools-extra/test/clang-move/Inputs/test.cpp
@@ -0,0 +1,8 @@
+#include "test.h"
+#include "test2.h"
+
+namespace a {
+int Foo::f() {
+ return 0;
+}
+} // namespace a
diff --git a/clang-tools-extra/test/clang-move/Inputs/test.h b/clang-tools-extra/test/clang-move/Inputs/test.h
new file mode 100644
index 00000000000..8ff3316f021
--- /dev/null
+++ b/clang-tools-extra/test/clang-move/Inputs/test.h
@@ -0,0 +1,6 @@
+namespace a {
+class Foo {
+public:
+ int f();
+};
+} // namespace a
diff --git a/clang-tools-extra/test/clang-move/move-class.cpp b/clang-tools-extra/test/clang-move/move-class.cpp
new file mode 100644
index 00000000000..c318f36cc8e
--- /dev/null
+++ b/clang-tools-extra/test/clang-move/move-class.cpp
@@ -0,0 +1,39 @@
+// RUN: mkdir -p %T/clang-move/build
+// RUN: sed 's|$test_dir|%/T/clang-move|g' %S/Inputs/database_template.json > %T/clang-move/compile_commands.json
+// RUN: cp %S/Inputs/test* %T/clang-move/
+// RUN: touch %T/clang-move/test2.h
+// RUN: cd %T/clang-move
+// RUN: clang-move -name="a::Foo" -new_cc=%T/clang-move/new_test.cpp -new_header=%T/clang-move/new_test.h -old_cc=../clang-move/test.cpp -old_header=../clang-move/test.h %T/clang-move/test.cpp
+// RUN: FileCheck -input-file=%T/clang-move/new_test.cpp -check-prefix=CHECK-NEW-TEST-CPP %s
+// RUN: FileCheck -input-file=%T/clang-move/new_test.h -check-prefix=CHECK-NEW-TEST-H %s
+// RUN: FileCheck -input-file=%T/clang-move/test.cpp -check-prefix=CHECK-OLD-TEST-CPP %s
+// RUN: FileCheck -input-file=%T/clang-move/test.h -check-prefix=CHECK-OLD-TEST-H %s
+//
+// RUN: cp %S/Inputs/test* %T/clang-move/
+// RUN: cd %T/clang-move
+// RUN: clang-move -name="a::Foo" -new_cc=%T/clang-move/new_test.cpp -new_header=%T/clang-move/new_test.h -old_cc=%T/clang-move/test.cpp -old_header=%T/clang-move/test.h %T/clang-move/test.cpp
+// RUN: FileCheck -input-file=%T/clang-move/new_test.cpp -check-prefix=CHECK-NEW-TEST-CPP %s
+// RUN: FileCheck -input-file=%T/clang-move/new_test.h -check-prefix=CHECK-NEW-TEST-H %s
+// RUN: FileCheck -input-file=%T/clang-move/test.cpp -check-prefix=CHECK-OLD-TEST-CPP %s
+// RUN: FileCheck -input-file=%T/clang-move/test.h -check-prefix=CHECK-OLD-TEST-H %s
+//
+// CHECK-NEW-TEST-H: namespace a {
+// CHECK-NEW-TEST-H: class Foo {
+// CHECK-NEW-TEST-H: public:
+// CHECK-NEW-TEST-H: int f();
+// CHECK-NEW-TEST-H: };
+// CHECK-NEW-TEST-H: } // namespace a
+//
+// CHECK-NEW-TEST-CPP: #include "{{.*}}new_test.h"
+// CHECK-NEW-TEST-CPP: #include "test2.h"
+// CHECK-NEW-TEST-CPP: namespace a {
+// CHECK-NEW-TEST-CPP: int Foo::f() { return 0; }
+// CHECK-NEW-TEST-CPP: } // namespace a
+//
+// CHECK-OLD-TEST-H: namespace a {
+// CHECK-OLD-TEST-H: } // namespace a
+//
+// CHECK-OLD-TEST-CPP: #include "test.h"
+// CHECK-OLD-TEST-CPP: #include "test2.h"
+// CHECK-OLD-TEST-CPP: namespace a {
+// CHECK-OLD-TEST-CPP: } // namespace a