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

Side by Side Diff: pkg/analysis_server/test/src/plugin/plugin_watcher_test.dart

Issue 2988343002: Initial support for an explicit plugin list (Closed)
Patch Set: Created 3 years, 4 months 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
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:typed_data'; 6 import 'dart:typed_data';
7 7
8 import 'package:analysis_server/src/plugin/plugin_locator.dart'; 8 import 'package:analysis_server/src/plugin/plugin_locator.dart';
9 import 'package:analysis_server/src/plugin/plugin_manager.dart'; 9 import 'package:analysis_server/src/plugin/plugin_manager.dart';
10 import 'package:analysis_server/src/plugin/plugin_watcher.dart'; 10 import 'package:analysis_server/src/plugin/plugin_watcher.dart';
(...skipping 27 matching lines...) Expand all
38 PluginWatcher watcher; 38 PluginWatcher watcher;
39 39
40 void setUp() { 40 void setUp() {
41 resourceProvider = new MemoryResourceProvider(); 41 resourceProvider = new MemoryResourceProvider();
42 manager = new TestPluginManager(); 42 manager = new TestPluginManager();
43 watcher = new PluginWatcher(resourceProvider, manager); 43 watcher = new PluginWatcher(resourceProvider, manager);
44 } 44 }
45 45
46 test_addedDriver() async { 46 test_addedDriver() async {
47 String pkg1Path = resourceProvider.convertPath('/pkg1'); 47 String pkg1Path = resourceProvider.convertPath('/pkg1');
48 resourceProvider.newFile(
49 resourceProvider.convertPath('/pkg1/lib/test1.dart'), '');
50 resourceProvider.newFile(
51 resourceProvider.convertPath('/pkg2/lib/pkg2.dart'), '');
52 resourceProvider.newFile(
53 resourceProvider.convertPath('/pkg2/pubspec.yaml'), 'name: pkg2');
54 resourceProvider.newFile(
55 resourceProvider.convertPath(
56 '/pkg2/${PluginLocator.toolsFolderName}/${PluginLocator.defaultPlugi nFolderName}/bin/plugin.dart'),
57 '');
58
48 ContextRoot contextRoot = new ContextRoot(pkg1Path, []); 59 ContextRoot contextRoot = new ContextRoot(pkg1Path, []);
49 TestDriver driver = new TestDriver(resourceProvider, contextRoot); 60 TestDriver driver = new TestDriver(resourceProvider, contextRoot);
61 driver.analysisOptions.enabledPluginNames = ['pkg2'];
50 watcher.addedDriver(driver, contextRoot); 62 watcher.addedDriver(driver, contextRoot);
51 expect(manager.addedContextRoots, isEmpty); 63 expect(manager.addedContextRoots, isEmpty);
52 // 64 //
53 // Test to see whether the listener was configured correctly. 65 // Test to see whether the listener was configured correctly.
54 // 66 //
55 // Use a file in the package being analyzed. 67 // Use a file in the package being analyzed.
56 // 68 //
57 resourceProvider.newFile( 69 // await driver.computeResult('package:pkg1/test1.dart');
58 resourceProvider.convertPath('/pkg1/lib/test1.dart'), ''); 70 // expect(manager.addedContextRoots, isEmpty);
59 await driver.computeResult('package:pkg1/test1.dart');
60 expect(manager.addedContextRoots, isEmpty);
61 // 71 //
62 // Use a file that imports a package with a plugin. 72 // Use a file that imports a package with a plugin.
63 // 73 //
64 resourceProvider.newFile( 74 // await driver.computeResult('package:pkg2/pk2.dart');
65 resourceProvider.convertPath('/pkg2/lib/pkg2.dart'), '');
66 resourceProvider.newFile(
67 resourceProvider.convertPath('/pkg2/pubspec.yaml'), 'name: pkg2');
68 resourceProvider.newFile(
69 resourceProvider.convertPath(
70 '/pkg2/${PluginLocator.toolsFolderName}/${PluginLocator.defaultPlugi nFolderName}/bin/plugin.dart'),
71 '');
72 await driver.computeResult('package:pkg2/pk2.dart');
73 // 75 //
74 // Wait until the timer associated with the driver's FileSystemState is 76 // Wait until the timer associated with the driver's FileSystemState is
75 // guaranteed to have expired and the list of changed files will have been 77 // guaranteed to have expired and the list of changed files will have been
76 // delivered. 78 // delivered.
77 // 79 //
78 await new Future.delayed(new Duration(seconds: 1)); 80 await new Future.delayed(new Duration(seconds: 1));
79 expect(manager.addedContextRoots, hasLength(1)); 81 expect(manager.addedContextRoots, hasLength(1));
80 } 82 }
81 83
82 void test_creation() { 84 void test_creation() {
(...skipping 10 matching lines...) Expand all
93 expect(manager.removedContextRoots, equals([contextRoot])); 95 expect(manager.removedContextRoots, equals([contextRoot]));
94 } 96 }
95 } 97 }
96 98
97 class TestDriver implements AnalysisDriver { 99 class TestDriver implements AnalysisDriver {
98 final MemoryResourceProvider resourceProvider; 100 final MemoryResourceProvider resourceProvider;
99 101
100 SourceFactory sourceFactory; 102 SourceFactory sourceFactory;
101 FileSystemState fsState; 103 FileSystemState fsState;
102 AnalysisSession currentSession; 104 AnalysisSession currentSession;
105 AnalysisOptionsImpl analysisOptions = new AnalysisOptionsImpl();
103 106
104 final _resultController = new StreamController<AnalysisResult>(); 107 final _resultController = new StreamController<AnalysisResult>();
105 108
106 TestDriver(this.resourceProvider, ContextRoot contextRoot) { 109 TestDriver(this.resourceProvider, ContextRoot contextRoot) {
107 path.Context pathContext = resourceProvider.pathContext; 110 path.Context pathContext = resourceProvider.pathContext;
108 MockSdk sdk = new MockSdk(resourceProvider: resourceProvider); 111 MockSdk sdk = new MockSdk(resourceProvider: resourceProvider);
109 String packageName = pathContext.basename(contextRoot.root); 112 String packageName = pathContext.basename(contextRoot.root);
110 String libPath = pathContext.join(contextRoot.root, 'lib'); 113 String libPath = pathContext.join(contextRoot.root, 'lib');
111 sourceFactory = new SourceFactory([ 114 sourceFactory = new SourceFactory([
112 new DartUriResolver(sdk), 115 new DartUriResolver(sdk),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 return null; 156 return null;
154 } 157 }
155 158
156 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 159 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
157 160
158 @override 161 @override
159 void removedContextRoot(ContextRoot contextRoot) { 162 void removedContextRoot(ContextRoot contextRoot) {
160 removedContextRoots.add(contextRoot); 163 removedContextRoots.add(contextRoot);
161 } 164 }
162 } 165 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/status/diagnostics.dart ('k') | pkg/analyzer/lib/src/context/context.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698