Change analysis_server tests to use /project/test.dart as the test file.

Correspondingly all files that were referenced using relative URI(s)
also put into /project, which is the contextRoot for the test
AnalysisDriver.

This will let us (in a following CL) start checking that the element
being renamed is defined inside the current workspace (the set of
analysis roots). Currently the context root is hardcoded as /project.

R=brianwilkerson@google.com

Change-Id: I9dca3509af1be13c9016bf03d4a4b95d71bc9374
Reviewed-on: https://dart-review.googlesource.com/56031
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2018-05-22 00:31:22 +00:00 committed by commit-bot@chromium.org
parent e71bd048e5
commit 9696c9dcd0
12 changed files with 65 additions and 65 deletions

View file

@ -31,7 +31,7 @@ class AbstractSingleUnitTest extends AbstractContextTest {
@override
void setUp() {
super.setUp();
testFile = resourceProvider.convertPath('/test.dart');
testFile = resourceProvider.convertPath('/project/test.dart');
}
void addTestSource(String code, [Uri uri]) {

View file

@ -104,7 +104,7 @@ class AssistProcessorTest extends AbstractSingleUnitTest {
}
test_addTypeAnnotation_BAD_privateType_closureParameter() async {
addSource('/my_lib.dart', '''
addSource('/project/my_lib.dart', '''
library my_lib;
class A {}
class _B extends A {}
@ -120,7 +120,7 @@ main() {
}
test_addTypeAnnotation_BAD_privateType_declaredIdentifier() async {
addSource('/my_lib.dart', '''
addSource('/project/my_lib.dart', '''
library my_lib;
class A {}
class _B extends A {}
@ -141,7 +141,7 @@ class A<T> {
test_addTypeAnnotation_BAD_privateType_list() async {
// This is now failing because we're suggesting "List" rather than nothing.
// Is it really better to produce nothing?
addSource('/my_lib.dart', '''
addSource('/project/my_lib.dart', '''
library my_lib;
class A {}
class _B extends A {}
@ -162,7 +162,7 @@ main() {
}
test_addTypeAnnotation_BAD_privateType_variable() async {
addSource('/my_lib.dart', '''
addSource('/project/my_lib.dart', '''
library my_lib;
class A {}
class _B extends A {}
@ -279,7 +279,7 @@ main(List<String> items) {
}
test_addTypeAnnotation_declaredIdentifier_OK_addImport_dartUri() async {
addSource('/my_lib.dart', r'''
addSource('/project/my_lib.dart', r'''
import 'dart:async';
List<Future<int>> getFutures() => null;
''');
@ -416,7 +416,7 @@ class A<T> {
}
test_addTypeAnnotation_local_OK_addImport_dartUri() async {
addSource('/my_lib.dart', r'''
addSource('/project/my_lib.dart', r'''
import 'dart:async';
Future<int> getFutureInt() => null;
''');
@ -438,7 +438,7 @@ main() {
test_addTypeAnnotation_local_OK_addImport_notLibraryUnit() async {
// prepare library
addSource('/my_lib.dart', r'''
addSource('/project/my_lib.dart', r'''
import 'dart:async';
Future<int> getFutureInt() => null;
''');
@ -455,8 +455,8 @@ main() {
}
''';
// add sources
addSource('/app.dart', appCode);
testSource = addSource('/test.dart', testCode);
addSource('/project/app.dart', appCode);
testSource = addSource('/project/test.dart', testCode);
// resolve
await resolveTestUnit(testCode);
// prepare the assist
@ -465,7 +465,7 @@ main() {
change = assist.change;
// verify
{
var testFileEdit = change.getFileEdit(convertPath('/app.dart'));
var testFileEdit = change.getFileEdit(convertPath('/project/app.dart'));
var resultCode = SourceEdit.applySequence(appCode, testFileEdit.edits);
expect(resultCode, '''
library my_app;
@ -476,7 +476,7 @@ part 'test.dart';
''');
}
{
var testFileEdit = change.getFileEdit(convertPath('/test.dart'));
var testFileEdit = change.getFileEdit(convertPath('/project/test.dart'));
var resultCode = SourceEdit.applySequence(testCode, testFileEdit.edits);
expect(resultCode, '''
part of my_app;
@ -488,10 +488,10 @@ main() {
}
test_addTypeAnnotation_local_OK_addImport_relUri() async {
addSource('/aa/bbb/lib_a.dart', r'''
addSource('/project/aa/bbb/lib_a.dart', r'''
class MyClass {}
''');
addSource('/ccc/lib_b.dart', r'''
addSource('/project/ccc/lib_b.dart', r'''
import '../aa/bbb/lib_a.dart';
MyClass newMyClass() => null;
''');

View file

@ -1100,7 +1100,7 @@ build() {
test_addMissingRequiredArg_cons_single() async {
_addMetaPackageSource();
addSource('/libA.dart', r'''
addSource('/project/libA.dart', r'''
library libA;
import 'package:meta/meta.dart';
@ -1128,7 +1128,7 @@ main() {
test_addMissingRequiredArg_cons_single_closure() async {
_addMetaPackageSource();
addSource('/libA.dart', r'''
addSource('/project/libA.dart', r'''
library libA;
import 'package:meta/meta.dart';
@ -1158,7 +1158,7 @@ main() {
test_addMissingRequiredArg_cons_single_closure_2() async {
_addMetaPackageSource();
addSource('/libA.dart', r'''
addSource('/project/libA.dart', r'''
library libA;
import 'package:meta/meta.dart';
@ -1188,7 +1188,7 @@ main() {
test_addMissingRequiredArg_cons_single_closure_3() async {
_addMetaPackageSource();
addSource('/libA.dart', r'''
addSource('/project/libA.dart', r'''
library libA;
import 'package:meta/meta.dart';
@ -1218,7 +1218,7 @@ main() {
test_addMissingRequiredArg_cons_single_closure_4() async {
_addMetaPackageSource();
addSource('/libA.dart', r'''
addSource('/project/libA.dart', r'''
library libA;
import 'package:meta/meta.dart';
@ -1248,7 +1248,7 @@ main() {
test_addMissingRequiredArg_cons_single_list() async {
_addMetaPackageSource();
addSource('/libA.dart', r'''
addSource('/project/libA.dart', r'''
library libA;
import 'package:meta/meta.dart';
@ -1495,13 +1495,13 @@ main(A a) {
}
test_changeToStaticAccess_method_importType() async {
addSource('/libA.dart', r'''
addSource('/project/libA.dart', r'''
library libA;
class A {
static foo() {}
}
''');
addSource('/libB.dart', r'''
addSource('/project/libB.dart', r'''
library libB;
import 'libA.dart';
class B extends A {}
@ -1556,13 +1556,13 @@ main(A a) {
}
test_changeToStaticAccess_property_importType() async {
addSource('/libA.dart', r'''
addSource('/project/libA.dart', r'''
library libA;
class A {
static get foo => null;
}
''');
addSource('/libB.dart', r'''
addSource('/project/libB.dart', r'''
library libB;
import 'libA.dart';
class B extends A {}
@ -1748,7 +1748,7 @@ library my.lib;
class A {}
''';
addSource('/lib.dart', libCode);
addSource('/project/lib.dart', libCode);
await resolveTestUnit('''
import 'lib.dart' as lib;
@ -1764,7 +1764,7 @@ main() {
List<SourceFileEdit> fileEdits = change.edits;
expect(fileEdits, hasLength(1));
SourceFileEdit fileEdit = change.edits[0];
expect(fileEdit.file, convertPath('/lib.dart'));
expect(fileEdit.file, convertPath('/project/lib.dart'));
expect(SourceEdit.applySequence(libCode, fileEdit.edits), r'''
library my.lib;
@ -2165,11 +2165,11 @@ class B extends A {
}
test_createConstructorSuperImplicit_importType() async {
addSource('/libA.dart', r'''
addSource('/project/libA.dart', r'''
library libA;
class A {}
''');
addSource('/libB.dart', r'''
addSource('/project/libB.dart', r'''
library libB;
import 'libA.dart';
class B {
@ -2314,7 +2314,7 @@ main(A a) {
}
test_createField_getter_qualified_instance_differentLibrary() async {
addSource('/other.dart', '''
addSource('/project/other.dart', '''
/**
* A comment to push the offset of the braces for the following class
* declaration past the end of the content of the test file. Used to catch an
@ -2343,7 +2343,7 @@ class A {
int test;
}
''',
target: '/other.dart');
target: '/project/other.dart');
}
test_createField_getter_qualified_instance_dynamicType() async {
@ -2493,11 +2493,11 @@ main(A a) {
}
test_createField_importType() async {
addSource('/libA.dart', r'''
addSource('/project/libA.dart', r'''
library libA;
class A {}
''');
addSource('/libB.dart', r'''
addSource('/project/libB.dart', r'''
library libB;
import 'libA.dart';
A getA() => null;
@ -2938,7 +2938,7 @@ main(A a) {
}
test_createGetter_qualified_instance_differentLibrary() async {
addSource('/other.dart', '''
addSource('/project/other.dart', '''
/**
* A comment to push the offset of the braces for the following class
* declaration past the end of the content of the test file. Used to catch an
@ -2967,7 +2967,7 @@ class A {
int get test => null;
}
''',
target: '/other.dart');
target: '/project/other.dart');
}
test_createGetter_qualified_instance_dynamicType() async {
@ -3879,11 +3879,11 @@ int test(double a, String b) {
}
test_creationFunction_forFunctionType_importType() async {
addSource('/libA.dart', r'''
addSource('/project/libA.dart', r'''
library libA;
class A {}
''');
addSource('/libB.dart', r'''
addSource('/project/libB.dart', r'''
library libB;
import 'libA.dart';
useFunction(int g(A a)) {}
@ -5370,7 +5370,7 @@ void process(List<int> items) {
}
test_undefinedFunction_create_importType() async {
addSource('/lib.dart', r'''
addSource('/project/lib.dart', r'''
library lib;
import 'dart:async';
Future getFuture() => null;
@ -6082,8 +6082,8 @@ export 'test3.dart';
class D {
}
''';
addSource('/test2.dart', code2);
addSource('/test3.dart', r'''
addSource('/project/test2.dart', code2);
addSource('/project/test3.dart', r'''
library test3;
class E {}
''');
@ -6101,7 +6101,7 @@ main(aaa.D d, aaa.E e) {
List<SourceFileEdit> fileEdits = change.edits;
expect(fileEdits, hasLength(1));
SourceFileEdit fileEdit = change.edits[0];
expect(fileEdit.file, convertPath('/test2.dart'));
expect(fileEdit.file, convertPath('/project/test2.dart'));
expect(SourceEdit.applySequence(code2, fileEdit.edits), r'''
library test2;
import 'test3.dart' as bbb;
@ -6119,7 +6119,7 @@ class D {
}
class E {}
''';
addSource('/test2.dart', code2);
addSource('/project/test2.dart', code2);
await resolveTestUnit('''
library test;
import 'test2.dart' as test2;
@ -6134,7 +6134,7 @@ main(test2.D d, test2.E e) {
List<SourceFileEdit> fileEdits = change.edits;
expect(fileEdits, hasLength(1));
SourceFileEdit fileEdit = change.edits[0];
expect(fileEdit.file, convertPath('/test2.dart'));
expect(fileEdit.file, convertPath('/project/test2.dart'));
expect(SourceEdit.applySequence(code2, fileEdit.edits), r'''
library test2;
class D {

View file

@ -96,8 +96,8 @@ main() {
}
test_remove_unresolvedDirectives() async {
addSource('/existing_part1.dart', 'part of lib;');
addSource('/existing_part2.dart', 'part of lib;');
addSource('/project/existing_part1.dart', 'part of lib;');
addSource('/project/existing_part2.dart', 'part of lib;');
await _computeUnitAndErrors(r'''
library lib;

View file

@ -29,7 +29,7 @@ class RefactoringLocationTest extends AbstractSingleUnitTest {
Element element = findElement('MyClass');
// check
Location location = newLocation_fromElement(element);
expect(location.file, convertPath('/test.dart'));
expect(location.file, convertPath('/project/test.dart'));
expect(location.offset, 6);
expect(location.length, 7);
expect(location.startLine, 1);
@ -52,7 +52,7 @@ class RefactoringLocationTest extends AbstractSingleUnitTest {
sourceRange);
// check
Location location = newLocation_fromMatch(match);
expect(location.file, convertPath('/test.dart'));
expect(location.file, convertPath('/project/test.dart'));
expect(location.offset, sourceRange.offset);
expect(location.length, sourceRange.length);
}
@ -65,7 +65,7 @@ main() {
AstNode node = findNodeAtString('main');
// check
Location location = newLocation_fromNode(node);
expect(location.file, convertPath('/test.dart'));
expect(location.file, convertPath('/project/test.dart'));
expect(location.offset, node.offset);
expect(location.length, node.length);
}
@ -75,7 +75,7 @@ main() {
SourceRange sourceRange = new SourceRange(10, 20);
// check
Location location = newLocation_fromUnit(testUnit, sourceRange);
expect(location.file, convertPath('/test.dart'));
expect(location.file, convertPath('/project/test.dart'));
expect(location.offset, sourceRange.offset);
expect(location.length, sourceRange.length);
}

View file

@ -87,7 +87,7 @@ main(A a, B b, C c, D d) {
}
test_change_multipleFiles() async {
await indexUnit('/other.dart', r'''
await indexUnit('/project/other.dart', r'''
class A {
int get test => 1;
}

View file

@ -89,7 +89,7 @@ main(A a, B b, C c, D d) {
}
test_change_multipleFiles() async {
await indexUnit('/other.dart', r'''
await indexUnit('/project/other.dart', r'''
class A {
int test() => 1;
}

View file

@ -2837,7 +2837,7 @@ void res() {
}
void _addLibraryReturningAsync() {
addSource('/asyncLib.dart', r'''
addSource('/project/asyncLib.dart', r'''
library asyncLib;
import 'dart:async';
Future<int> newFuture() => null;

View file

@ -157,7 +157,7 @@ class A {
test() {}
}
''');
await indexUnit('/lib.dart', '''
await indexUnit('/project/lib.dart', '''
library my.lib;
import 'test.dart';
@ -356,7 +356,7 @@ class A {
newName() {} // marker
}
''';
await indexUnit('/lib.dart', libCode);
await indexUnit('/project/lib.dart', libCode);
await indexTestUnit('''
import 'lib.dart';
class B extends A {

View file

@ -40,7 +40,7 @@ library my.app;
}
test_createChange() async {
addSource('/part.dart', '''
addSource('/project/part.dart', '''
part of my.app;
''');
await indexTestUnit('''
@ -57,13 +57,13 @@ part 'part.dart';
library the.new.name;
part 'part.dart';
''');
assertFileChangeResult('/part.dart', '''
assertFileChangeResult('/project/part.dart', '''
part of the.new.name;
''');
}
test_createChange_hasWhitespaces() async {
addSource('/part.dart', '''
addSource('/project/part.dart', '''
part of my . app;
''');
await indexTestUnit('''
@ -80,7 +80,7 @@ part 'part.dart';
library the.new.name;
part 'part.dart';
''');
assertFileChangeResult('/part.dart', '''
assertFileChangeResult('/project/part.dart', '''
part of the.new.name;
''');
}

View file

@ -447,7 +447,7 @@ class A {
A({test});
}
''');
await indexUnit('/test2.dart', '''
await indexUnit('/project/test2.dart', '''
import 'test.dart';
main() {
new A(test: 2);
@ -463,7 +463,7 @@ class A {
A({newName});
}
''');
assertFileChangeResult('/test2.dart', '''
assertFileChangeResult('/project/test2.dart', '''
import 'test.dart';
main() {
new A(newName: 2);
@ -472,7 +472,7 @@ main() {
}
test_createChange_parameter_named_updateHierarchy() async {
await indexUnit('/test2.dart', '''
await indexUnit('/project/test2.dart', '''
library test2;
class A {
void foo({int test: 1}) {
@ -516,7 +516,7 @@ class C extends A {
}
}
''');
assertFileChangeResult('/test2.dart', '''
assertFileChangeResult('/project/test2.dart', '''
library test2;
class A {
void foo({int newName: 1}) {

View file

@ -69,7 +69,7 @@ class B extends A {
await indexTestUnit('''
class Test {}
''');
await indexUnit(convertPath('/lib.dart'), '''
await indexUnit(convertPath('/project/lib.dart'), '''
library my.lib;
import 'test.dart';
@ -109,7 +109,7 @@ class A {
await indexTestUnit('''
class Test {}
''');
await indexUnit(convertPath('/lib.dart'), '''
await indexUnit(convertPath('/project/lib.dart'), '''
library my.lib;
import 'test.dart';
class A {
@ -483,7 +483,7 @@ main() {
}
test_createChange_FunctionElement_imported() async {
await indexUnit('/foo.dart', r'''
await indexUnit('/project/foo.dart', r'''
test() {}
foo() {}
''');
@ -510,7 +510,7 @@ main() {
foo();
}
''');
assertFileChangeResult('/foo.dart', '''
assertFileChangeResult('/project/foo.dart', '''
newName() {}
foo() {}
''');