Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: pkg/analysis_server/test/single_context_manager_test.dart

Issue 2518873002: Use an import prefix in the analysis server tests; this fixes some issues conflicting with the (Closed)
Patch Set: use path prefix Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analysis_server/test/integration/analysis/package_root_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.analysis_server.src.single_context_manager; 5 library test.analysis_server.src.single_context_manager;
6 6
7 import 'dart:core'; 7 import 'dart:core';
8 8
9 import 'package:analysis_server/src/single_context_manager.dart'; 9 import 'package:analysis_server/src/single_context_manager.dart';
10 import 'package:analyzer/file_system/memory_file_system.dart'; 10 import 'package:analyzer/file_system/memory_file_system.dart';
11 import 'package:analyzer/src/generated/engine.dart'; 11 import 'package:analyzer/src/generated/engine.dart';
12 import 'package:analyzer/src/generated/sdk.dart'; 12 import 'package:analyzer/src/generated/sdk.dart';
13 import 'package:analyzer/src/generated/source.dart'; 13 import 'package:analyzer/src/generated/source.dart';
14 import 'package:analyzer/src/generated/source_io.dart'; 14 import 'package:analyzer/src/generated/source_io.dart';
15 import 'package:analyzer/src/util/glob.dart'; 15 import 'package:analyzer/src/util/glob.dart';
16 import 'package:linter/src/plugin/linter_plugin.dart'; 16 import 'package:linter/src/plugin/linter_plugin.dart';
17 import 'package:path/path.dart'; 17 import 'package:path/path.dart' as path;
18 import 'package:plugin/manager.dart'; 18 import 'package:plugin/manager.dart';
19 import 'package:plugin/plugin.dart'; 19 import 'package:plugin/plugin.dart';
20 import 'package:test/test.dart'; 20 import 'package:test/test.dart';
21 import 'package:test_reflective_loader/test_reflective_loader.dart'; 21 import 'package:test_reflective_loader/test_reflective_loader.dart';
22 22
23 import 'context_manager_test.dart' show TestContextManagerCallbacks; 23 import 'context_manager_test.dart' show TestContextManagerCallbacks;
24 import 'mocks.dart'; 24 import 'mocks.dart';
25 25
26 main() { 26 main() {
27 defineReflectiveSuite(() { 27 defineReflectiveSuite(() {
28 defineReflectiveTests(SingleContextManagerTest); 28 defineReflectiveTests(SingleContextManagerTest);
29 }); 29 });
30 } 30 }
31 31
32 @reflectiveTest 32 @reflectiveTest
33 class SingleContextManagerTest { 33 class SingleContextManagerTest {
34 MemoryResourceProvider resourceProvider = new MemoryResourceProvider(); 34 MemoryResourceProvider resourceProvider = new MemoryResourceProvider();
35 35
36 TestUriResolver packageResolver; 36 TestUriResolver packageResolver;
37 TestContextManagerCallbacks callbacks; 37 TestContextManagerCallbacks callbacks;
38 SingleContextManager manager; 38 SingleContextManager manager;
39 39
40 List<Glob> get analysisFilesGlobs { 40 List<Glob> get analysisFilesGlobs {
41 List<String> patterns = <String>[ 41 List<String> patterns = <String>[
42 '**/*.${AnalysisEngine.SUFFIX_DART}', 42 '**/*.${AnalysisEngine.SUFFIX_DART}',
43 '**/*.${AnalysisEngine.SUFFIX_HTML}', 43 '**/*.${AnalysisEngine.SUFFIX_HTML}',
44 ]; 44 ];
45 return patterns 45 return patterns
46 .map((pattern) => new Glob(posix.separator, pattern)) 46 .map((pattern) => new Glob(path.posix.separator, pattern))
47 .toList(); 47 .toList();
48 } 48 }
49 49
50 String newFile(List<String> pathComponents, [String content = '']) { 50 String newFile(List<String> pathComponents, [String content = '']) {
51 String filePath = posix.joinAll(pathComponents); 51 String filePath = path.posix.joinAll(pathComponents);
52 resourceProvider.newFile(filePath, content); 52 resourceProvider.newFile(filePath, content);
53 return filePath; 53 return filePath;
54 } 54 }
55 55
56 String newFolder(List<String> pathComponents) { 56 String newFolder(List<String> pathComponents) {
57 String folderPath = posix.joinAll(pathComponents); 57 String folderPath = path.posix.joinAll(pathComponents);
58 resourceProvider.newFolder(folderPath); 58 resourceProvider.newFolder(folderPath);
59 return folderPath; 59 return folderPath;
60 } 60 }
61 61
62 void setUp() { 62 void setUp() {
63 packageResolver = new TestUriResolver(); 63 packageResolver = new TestUriResolver();
64 64
65 _processRequiredPlugins(); 65 _processRequiredPlugins();
66 DartSdkManager sdkManager = new DartSdkManager('', false); 66 DartSdkManager sdkManager = new DartSdkManager('', false);
67 manager = new SingleContextManager(resourceProvider, sdkManager, 67 manager = new SingleContextManager(resourceProvider, sdkManager,
(...skipping 24 matching lines...) Expand all
92 <String>[project], <String>[excludedPath], <String, String>{}); 92 <String>[project], <String>[excludedPath], <String, String>{});
93 expect(manager.isIgnored('$excludedPath/file.dart'), isTrue); 93 expect(manager.isIgnored('$excludedPath/file.dart'), isTrue);
94 } 94 }
95 95
96 void test_isIgnored_true_notInRoot() { 96 void test_isIgnored_true_notInRoot() {
97 String root1 = '/context/root1'; 97 String root1 = '/context/root1';
98 String root2 = '/context/root2'; 98 String root2 = '/context/root2';
99 resourceProvider.newFolder(root1); 99 resourceProvider.newFolder(root1);
100 resourceProvider.newFolder(root2); 100 resourceProvider.newFolder(root2);
101 manager.setRoots(<String>[root1, root2], <String>[], <String, String>{}); 101 manager.setRoots(<String>[root1, root2], <String>[], <String, String>{});
102 expect(manager.isIgnored('$context/root3/file.dart'), isTrue); 102 expect(manager.isIgnored('/context/root3/file.dart'), isTrue);
103 } 103 }
104 104
105 void test_isInAnalysisRoot_false_inExcludedPath() { 105 void test_isInAnalysisRoot_false_inExcludedPath() {
106 String project = '/project'; 106 String project = '/project';
107 String excludedPath = '/project/excluded'; 107 String excludedPath = '/project/excluded';
108 resourceProvider.newFolder(project); 108 resourceProvider.newFolder(project);
109 manager.setRoots( 109 manager.setRoots(
110 <String>[project], <String>[excludedPath], <String, String>{}); 110 <String>[project], <String>[excludedPath], <String, String>{});
111 expect(manager.isInAnalysisRoot('$excludedPath/file.dart'), isFalse); 111 expect(manager.isInAnalysisRoot('$excludedPath/file.dart'), isFalse);
112 } 112 }
113 113
114 void test_isInAnalysisRoot_false_notInRoot() { 114 void test_isInAnalysisRoot_false_notInRoot() {
115 String root1 = '/context/root1'; 115 String root1 = '/context/root1';
116 String root2 = '/context/root2'; 116 String root2 = '/context/root2';
117 resourceProvider.newFolder(root1); 117 resourceProvider.newFolder(root1);
118 resourceProvider.newFolder(root2); 118 resourceProvider.newFolder(root2);
119 manager.setRoots(<String>[root1, root2], <String>[], <String, String>{}); 119 manager.setRoots(<String>[root1, root2], <String>[], <String, String>{});
120 expect(manager.isInAnalysisRoot('$context/root3/file.dart'), isFalse); 120 expect(manager.isInAnalysisRoot('/context/root3/file.dart'), isFalse);
121 } 121 }
122 122
123 void test_isInAnalysisRoot_true() { 123 void test_isInAnalysisRoot_true() {
124 String project = '/project'; 124 String project = '/project';
125 resourceProvider.newFolder(project); 125 resourceProvider.newFolder(project);
126 manager.setRoots(<String>[project], <String>[], <String, String>{}); 126 manager.setRoots(<String>[project], <String>[], <String, String>{});
127 expect(manager.isInAnalysisRoot('$project/file.dart'), isTrue); 127 expect(manager.isInAnalysisRoot('$project/file.dart'), isTrue);
128 } 128 }
129 129
130 void test_refresh() { 130 void test_refresh() {
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 manager.processPlugins(plugins); 539 manager.processPlugins(plugins);
540 } 540 }
541 } 541 }
542 542
543 class TestUriResolver extends UriResolver { 543 class TestUriResolver extends UriResolver {
544 @override 544 @override
545 Source resolveAbsolute(Uri uri, [Uri actualUri]) { 545 Source resolveAbsolute(Uri uri, [Uri actualUri]) {
546 return null; 546 return null;
547 } 547 }
548 } 548 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/integration/analysis/package_root_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698