diff options
author | Alex Lorenz <arphaman@gmail.com> | 2017-09-14 10:06:52 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2017-09-14 10:06:52 +0000 |
commit | 5a2269c689fbe654ff15a8783bd61b1047353b67 (patch) | |
tree | eaebdcfa15e9243d14d3f31794f96cff20267337 /test/Refactor | |
parent | f9eb14961ddd9a48da63cdb792d06386287a5dfd (diff) |
[refactor] add clang-refactor tool with initial testing support and
local-rename action
This commit introduces the clang-refactor tool alongside the local-rename action
which uses the existing renaming engine used by clang-rename. The tool
doesn't actually perform the source transformations yet, it just provides
testing support. This commit also moves only one test from clang-rename over to
test/Refactor. I will continue to move the other tests throughout
development of clang-refactor.
The following options are supported by clang-refactor:
-v: use verbose output
-selection: The source range that corresponds to the portion of the source
that's selected (currently only special command test:<file> is supported).
Please note that a follow-up commit will migrate clang-refactor to
libTooling's common option parser, so clang-refactor will be able to use
the common interface with compilation database and options like -p, -extra-arg,
etc.
The testing support provided by clang-refactor is described below:
When -selection=test:<file> is given, clang-refactor will parse the selection
commands from that file. The selection commands are grouped and the specified
refactoring action invoked by the tool. Each command in a group is expected to
produce an identical result. The precise syntax for the selection commands is
described in a comment in TestSupport.h.
Differential Revision: https://reviews.llvm.org/D36574
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@313244 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Refactor')
-rw-r--r-- | test/Refactor/LocalRename/Field.cpp | 9 | ||||
-rw-r--r-- | test/Refactor/tool-common-options.c | 6 | ||||
-rw-r--r-- | test/Refactor/tool-test-support.c | 41 |
3 files changed, 56 insertions, 0 deletions
diff --git a/test/Refactor/LocalRename/Field.cpp b/test/Refactor/LocalRename/Field.cpp new file mode 100644 index 0000000000..db8ada5fcc --- /dev/null +++ b/test/Refactor/LocalRename/Field.cpp @@ -0,0 +1,9 @@ +// RUN: clang-refactor local-rename -selection=test:%s -no-dbs %s | FileCheck %s + +class Baz { + int /*range=*/Foo; // CHECK: int /*range=*/Bar; +public: + Baz(); +}; + +Baz::Baz() : /*range=*/Foo(0) {} // CHECK: Baz::Baz() : /*range=*/Bar(0) {}; diff --git a/test/Refactor/tool-common-options.c b/test/Refactor/tool-common-options.c new file mode 100644 index 0000000000..e20c290ae7 --- /dev/null +++ b/test/Refactor/tool-common-options.c @@ -0,0 +1,6 @@ +// RUN: not clang-refactor 2>&1 | FileCheck --check-prefix=MISSING_ACTION %s +// MISSING_ACTION: error: no refactoring action given +// MISSING_ACTION-NEXT: note: the following actions are supported: + +// RUN: not clang-refactor local-rename -no-dbs 2>&1 | FileCheck --check-prefix=MISSING_SOURCES %s +// MISSING_SOURCES: error: must provide paths to the source files when '-no-dbs' is used diff --git a/test/Refactor/tool-test-support.c b/test/Refactor/tool-test-support.c new file mode 100644 index 0000000000..3eb8d22f51 --- /dev/null +++ b/test/Refactor/tool-test-support.c @@ -0,0 +1,41 @@ +// RUN: clang-refactor local-rename -selection=test:%s -no-dbs -v %s 2>&1 | FileCheck %s + +/*range=*/int test; + +/*range named=*/int test2; + +/*range= +1*/int test3; + +/* range = +100 */int test4; + +/*range named =+0*/int test5; + +// CHECK: Test selection group '': +// CHECK-NEXT: 100-100 +// CHECK-NEXT: 153-153 +// CHECK-NEXT: 192-192 +// CHECK-NEXT: Test selection group 'named': +// CHECK-NEXT: 127-127 +// CHECK-NEXT: 213-213 + +// The following invocations are in the default group: + +// CHECK: invoking action 'local-rename': +// CHECK-NEXT: -selection={{.*}}tool-test-support.c:3:11 + +// CHECK: invoking action 'local-rename': +// CHECK-NEXT: -selection={{.*}}tool-test-support.c:7:15 + +// CHECK: invoking action 'local-rename': +// CHECK-NEXT: -selection={{.*}}tool-test-support.c:9:29 + + +// The following invocations are in the 'named' group, and they follow +// the default invocation even if some of their ranges occur prior to the +// ranges from the default group because the groups are tested one-by-one: + +// CHECK: invoking action 'local-rename': +// CHECK-NEXT: -selection={{.*}}tool-test-support.c:5:17 + +// CHECK: invoking action 'local-rename': +// CHECK-NEXT: -selection={{.*}}tool-test-support.c:11:20 |