summaryrefslogtreecommitdiff
path: root/test/Tooling
diff options
context:
space:
mode:
authorJohannes Altmanninger <aclopte@gmail.com>2017-08-19 15:40:45 +0000
committerJohannes Altmanninger <aclopte@gmail.com>2017-08-19 15:40:45 +0000
commit1e7d61fd34a2cab2fbd4a3633c19fdcd00c6dced (patch)
treed645201262a5c7d6b1fc9a6c2e45989729aa643a /test/Tooling
parentd159a31098954a88c859c6e9cc2d2600d1e3cf93 (diff)
downloadclang-1e7d61fd34a2cab2fbd4a3633c19fdcd00c6dced.tar.gz
[clang-diff] Add HTML side-by-side diff output
Reviewers: arphaman Subscribers: mgorny Differential Revision: https://reviews.llvm.org/D36182 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@311241 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Tooling')
-rw-r--r--test/Tooling/Inputs/clang-diff-basic-src.cpp31
-rw-r--r--test/Tooling/clang-diff-basic.cpp39
-rw-r--r--test/Tooling/clang-diff-html.test36
3 files changed, 68 insertions, 38 deletions
diff --git a/test/Tooling/Inputs/clang-diff-basic-src.cpp b/test/Tooling/Inputs/clang-diff-basic-src.cpp
new file mode 100644
index 0000000000..7a7b98675b
--- /dev/null
+++ b/test/Tooling/Inputs/clang-diff-basic-src.cpp
@@ -0,0 +1,31 @@
+namespace src {
+
+void foo() {
+ int x = 321;
+}
+
+void main() { foo(); };
+
+const char *a = "foo";
+
+typedef unsigned int nat;
+
+int p = 1 * 2 * 3 * 4;
+int squared = p * p;
+
+class X {
+ const char *foo(int i) {
+ if (i == 0)
+ return "foo";
+ return 0;
+ }
+
+public:
+ X(){};
+
+ int id(int i) { return i; }
+};
+}
+
+void m() { int x = 0 + 0 + 0; }
+int um = 1 + 2 + 3;
diff --git a/test/Tooling/clang-diff-basic.cpp b/test/Tooling/clang-diff-basic.cpp
index 23534749e1..0e375fb1b0 100644
--- a/test/Tooling/clang-diff-basic.cpp
+++ b/test/Tooling/clang-diff-basic.cpp
@@ -1,41 +1,5 @@
-// RUN: %clang_cc1 -E %s > %t.src.cpp
-// RUN: %clang_cc1 -E %s > %t.dst.cpp -DDEST
-// RUN: clang-diff -dump-matches %t.src.cpp %t.dst.cpp -- | FileCheck %s
+// RUN: clang-diff -dump-matches %S/Inputs/clang-diff-basic-src.cpp %s -- | FileCheck %s
-#ifndef DEST
-namespace src {
-
-void foo() {
- int x = 321;
-}
-
-void main() { foo(); };
-
-const char *a = "foo";
-
-typedef unsigned int nat;
-
-int p = 1 * 2 * 3 * 4;
-int squared = p * p;
-
-class X {
- const char *foo(int i) {
- if (i == 0)
- return "foo";
- return 0;
- }
-
-public:
- X(){};
-
- int id(int i) { return i; }
-};
-}
-
-void m() { int x = 0 + 0 + 0; }
-int um = 1 + 2 + 3;
-
-#else
// CHECK: Match TranslationUnitDecl{{.*}} to TranslationUnitDecl
// CHECK: Match NamespaceDecl: src{{.*}} to NamespaceDecl: dst
namespace dst {
@@ -82,7 +46,6 @@ class X {
void m() { { int x = 0 + 0 + 0; } }
// CHECK: Update and Move IntegerLiteral: 7{{.*}} into BinaryOperator: +({{.*}}) at 1
int um = 1 + 7;
-#endif
// CHECK: Delete AccessSpecDecl: public
// CHECK: Delete CXXMethodDecl
diff --git a/test/Tooling/clang-diff-html.test b/test/Tooling/clang-diff-html.test
new file mode 100644
index 0000000000..9b0d6ebb18
--- /dev/null
+++ b/test/Tooling/clang-diff-html.test
@@ -0,0 +1,36 @@
+// RUN: clang-diff -html %S/Inputs/clang-diff-basic-src.cpp %S/clang-diff-basic.cpp -- | FileCheck %s
+
+// CHECK: <pre><div id='L' class='code'><span id='L0' tid='R0' title='TranslationUnitDecl
+// CHECK-NEXT: 0 -> 0'>
+
+// match, update
+// CHECK: <span id='L[[L:[0-9]+]]' tid='R[[R:[0-9]+]]' title='NamespaceDecl
+// CHECK-NEXT: [[L]] -> [[R]]
+// CHECK-NEXT: src;' class='u'>namespace src {
+
+// match, move
+// CHECK: <span id='L[[L:[0-9]+]]' tid='R[[R:[0-9]+]]' title='FunctionDecl
+// CHECK-NEXT: [[L]] -> [[R]]
+// CHECK-NEXT: foo(void (void))' class='m'>void foo()
+
+// match
+// CHECK: <span id='L[[L:[0-9]+]]' tid='R[[R:[0-9]+]]' title='FunctionDecl
+// CHECK-NEXT: [[L]] -> [[R]]
+// CHECK-NEXT: main(void (void))'>void main()
+
+// deletion
+// CHECK: <span id='L[[L:[0-9]+]]' tid='R-1' title='IntegerLiteral
+// CHECK-NEXT: [[L]] -> -1
+// CHECK-NEXT: 4' class='d'>4</span>
+
+// update + move
+// CHECK: 2' class='u m'>2</span>
+
+// insertion
+// CHECK: <span id='R[[R:[0-9]+]]' tid='L-1' title='StringLiteral
+// CHECK-NEXT: -1 -> [[R]]
+// CHECK-NEXT: Bar' class='i'>&quot;Bar&quot;</span>
+
+// comments
+// CHECK: // CHECK: Insert IfStmt{{.*}} into IfStmt
+// CHECK: // CHECK: Delete AccessSpecDecl: public