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

Unified Diff: pkg/analysis_server/test/analysis_server_test.dart

Issue 2937323003: Remove ability to disable new analysis driver (Closed)
Patch Set: Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/test/analysis_abstract.dart ('k') | pkg/analysis_server/test/context_manager_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/analysis_server_test.dart
diff --git a/pkg/analysis_server/test/analysis_server_test.dart b/pkg/analysis_server/test/analysis_server_test.dart
index 5ba35a60a583d9191caab3c5935931421ce8ed9e..39ab01899a4295b007c4abd9eff3d23e9ec4c524 100644
--- a/pkg/analysis_server/test/analysis_server_test.dart
+++ b/pkg/analysis_server/test/analysis_server_test.dart
@@ -8,7 +8,6 @@ import 'package:analysis_server/protocol/protocol.dart';
import 'package:analysis_server/protocol/protocol_generated.dart';
import 'package:analysis_server/src/analysis_server.dart';
import 'package:analysis_server/src/constants.dart';
-import 'package:analysis_server/src/context_manager.dart';
import 'package:analysis_server/src/domain_server.dart';
import 'package:analysis_server/src/operation/operation.dart';
import 'package:analysis_server/src/plugin/server_plugin.dart';
@@ -16,7 +15,6 @@ import 'package:analyzer/exception/exception.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/file_system/memory_file_system.dart';
import 'package:analyzer/instrumentation/instrumentation.dart';
-import 'package:analyzer/source/package_map_resolver.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/source.dart';
@@ -43,84 +41,6 @@ class AnalysisServerTest {
MemoryResourceProvider resourceProvider;
MockPackageMapProvider packageMapProvider;
- /**
- * Verify that getAnalysisContextForSource returns the correct contexts even
- * for sources that are included by multiple contexts.
- *
- * See dartbug.com/21898
- */
- Future fail_getAnalysisContextForSource_crossImports() {
- // Subscribe to STATUS so we'll know when analysis is done.
- server.serverServices = [ServerService.STATUS].toSet();
- // Analyze project foo containing foo.dart and project bar containing
- // bar.dart.
- resourceProvider.newFolder('/foo');
- resourceProvider.newFolder('/bar');
- File foo = resourceProvider.newFile(
- '/foo/foo.dart',
- '''
-libary foo;
-import "../bar/bar.dart";
-''');
- Source fooSource = foo.createSource();
- File bar = resourceProvider.newFile(
- '/bar/bar.dart',
- '''
-library bar;
-import "../foo/foo.dart";
-''');
- Source barSource = bar.createSource();
- server.setAnalysisRoots('0', ['/foo', '/bar'], [], {});
- return server.onAnalysisComplete.then((_) {
- expect(server.statusAnalyzing, isFalse);
- // Make sure getAnalysisContext returns the proper context for each.
- AnalysisContext fooContext =
- server.getAnalysisContextForSource(fooSource);
- expect(fooContext, isNotNull);
- AnalysisContext barContext =
- server.getAnalysisContextForSource(barSource);
- expect(barContext, isNotNull);
- expect(fooContext, isNot(same(barContext)));
- expect(fooContext.getKindOf(fooSource), SourceKind.LIBRARY);
- expect(fooContext.getKindOf(barSource), SourceKind.UNKNOWN);
- expect(barContext.getKindOf(fooSource), SourceKind.UNKNOWN);
- expect(barContext.getKindOf(barSource), SourceKind.LIBRARY);
- });
- }
-
- /**
- * Verify that getAnalysisContextForSource returns the correct contexts even
- * for sources that haven't been analyzed yet.
- *
- * See dartbug.com/21898
- */
- Future fail_getAnalysisContextForSource_unanalyzed() {
- // Subscribe to STATUS so we'll know when analysis is done.
- server.serverServices = [ServerService.STATUS].toSet();
- // Analyze project foo containing foo.dart and project bar containing
- // bar.dart.
- resourceProvider.newFolder('/foo');
- resourceProvider.newFolder('/bar');
- File foo = resourceProvider.newFile('/foo/foo.dart', 'library lib;');
- Source fooSource = foo.createSource();
- File bar = resourceProvider.newFile('/bar/bar.dart', 'library lib;');
- Source barSource = bar.createSource();
- server.setAnalysisRoots('0', ['/foo', '/bar'], [], {});
- AnalysisContext fooContext = server.getAnalysisContextForSource(fooSource);
- expect(fooContext, isNotNull);
- AnalysisContext barContext = server.getAnalysisContextForSource(barSource);
- expect(barContext, isNotNull);
- expect(fooContext, isNot(same(barContext)));
- return server.onAnalysisComplete.then((_) {
- expect(server.statusAnalyzing, isFalse);
- // Make sure getAnalysisContext returned the proper context for each.
- expect(fooContext.getKindOf(fooSource), SourceKind.LIBRARY);
- expect(fooContext.getKindOf(barSource), SourceKind.UNKNOWN);
- expect(barContext.getKindOf(fooSource), SourceKind.UNKNOWN);
- expect(barContext.getKindOf(barSource), SourceKind.LIBRARY);
- });
- }
-
void processRequiredPlugins(ServerPlugin serverPlugin) {
List<Plugin> plugins = <Plugin>[];
plugins.addAll(AnalysisEngine.instance.requiredPlugins);
@@ -150,71 +70,6 @@ import "../foo/foo.dart";
rethrowExceptions: true);
}
- Future test_contextDisposed() {
- resourceProvider.newFolder('/foo');
- resourceProvider.newFile('/foo/bar.dart', 'library lib;');
- server.setAnalysisRoots('0', ['/foo'], [], {});
- AnalysisContext context;
- return pumpEventQueue()
- .then((_) {
- context = server.getAnalysisContext('/foo/bar.dart');
- server.setAnalysisRoots('1', [], [], {});
- })
- .then((_) => pumpEventQueue())
- .then((_) {
- expect(context.isDisposed, isTrue);
- });
- }
-
- Future test_contextsChangedEvent() {
- resourceProvider.newFolder('/foo');
-
- bool wasAdded = false;
- bool wasChanged = false;
- bool wasRemoved = false;
- server.onContextsChanged.listen((ContextsChangedEvent event) {
- wasAdded = event.added.length == 1;
- if (wasAdded) {
- expect(event.added[0], isNotNull);
- }
- wasChanged = event.changed.length == 1;
- if (wasChanged) {
- expect(event.changed[0], isNotNull);
- }
- wasRemoved = event.removed.length == 1;
- if (wasRemoved) {
- expect(event.removed[0], isNotNull);
- }
- });
-
- server.setAnalysisRoots('0', ['/foo'], [], {});
- return pumpEventQueue().then((_) {
- expect(wasAdded, isTrue);
- expect(wasChanged, isFalse);
- expect(wasRemoved, isFalse);
-
- wasAdded = false;
- wasChanged = false;
- wasRemoved = false;
- server.setAnalysisRoots('0', ['/foo'], [], {'/foo': '/bar'});
- return pumpEventQueue();
- }).then((_) {
- expect(wasAdded, isFalse);
- expect(wasChanged, isTrue);
- expect(wasRemoved, isFalse);
-
- wasAdded = false;
- wasChanged = false;
- wasRemoved = false;
- server.setAnalysisRoots('0', [], [], {});
- return pumpEventQueue();
- }).then((_) {
- expect(wasAdded, isFalse);
- expect(wasChanged, isFalse);
- expect(wasRemoved, isTrue);
- });
- }
-
Future test_echo() {
server.handlers = [new EchoHandler()];
var request = new Request('my22', 'echo');
@@ -224,99 +79,6 @@ import "../foo/foo.dart";
});
}
- Future test_getAnalysisContextForSource() {
- // Subscribe to STATUS so we'll know when analysis is done.
- server.serverServices = [ServerService.STATUS].toSet();
- // Analyze project foo containing foo.dart and project bar containing
- // bar.dart.
- resourceProvider.newFolder('/foo');
- resourceProvider.newFolder('/bar');
- File foo = resourceProvider.newFile('/foo/foo.dart', 'library lib;');
- Source fooSource = foo.createSource();
- File bar = resourceProvider.newFile('/bar/bar.dart', 'library lib;');
- Source barSource = bar.createSource();
- server.setAnalysisRoots('0', ['/foo', '/bar'], [], {});
- return server.onAnalysisComplete.then((_) {
- expect(server.statusAnalyzing, isFalse);
- // Make sure getAnalysisContext returns the proper context for each.
- AnalysisContext fooContext =
- server.getAnalysisContextForSource(fooSource);
- expect(fooContext, isNotNull);
- AnalysisContext barContext =
- server.getAnalysisContextForSource(barSource);
- expect(barContext, isNotNull);
- expect(fooContext, isNot(same(barContext)));
- expect(fooContext.getKindOf(fooSource), SourceKind.LIBRARY);
- expect(fooContext.getKindOf(barSource), SourceKind.UNKNOWN);
- expect(barContext.getKindOf(fooSource), SourceKind.UNKNOWN);
- expect(barContext.getKindOf(barSource), SourceKind.LIBRARY);
- });
- }
-
- test_getContextSourcePair_nested() {
- String dir1Path = '/dir1';
- String dir2Path = dir1Path + '/dir2';
- String filePath = dir2Path + '/file.dart';
- resourceProvider.newFile('$dir1Path/.packages', '');
- resourceProvider.newFile('$dir2Path/.packages', '');
- resourceProvider.newFile(filePath, 'library lib;');
- // create contexts
- server.setAnalysisRoots('0', [dir1Path], [], {});
- // get pair
- ContextSourcePair pair = server.getContextSourcePair(filePath);
- _assertContextOfFolder(pair.context, dir2Path);
- Source source = pair.source;
- expect(source, isNotNull);
- expect(source.uri.scheme, 'file');
- expect(source.fullName, filePath);
- }
-
- test_getContextSourcePair_nonFile() {
- String dirPath = '/dir';
- Folder dir = resourceProvider.newFolder(dirPath);
-
- AnalysisContext context = AnalysisEngine.instance.createAnalysisContext();
- _configureSourceFactory(context);
- server.folderMap[dir] = context;
-
- ContextSourcePair pair = server.getContextSourcePair(dirPath);
- expect(pair, isNotNull);
- expect(pair.context, isNull);
- expect(pair.source, isNull);
- }
-
- test_getContextSourcePair_simple() {
- String dirPath = '/dir';
- String filePath = dirPath + '/file.dart';
- resourceProvider.newFile(filePath, 'library lib;');
- // create contexts
- server.setAnalysisRoots('0', [dirPath], [], {});
- // get pair
- ContextSourcePair pair = server.getContextSourcePair(filePath);
- _assertContextOfFolder(pair.context, dirPath);
- Source source = pair.source;
- expect(source, isNotNull);
- expect(source.uri.scheme, 'file');
- expect(source.fullName, filePath);
- }
-
- test_getContextSourcePair_withPackagesFile() {
- String dirPath = '/dir';
- String packagesFilePath = dirPath + '/.packages';
- resourceProvider.newFile(packagesFilePath, 'dir:lib/');
- String filePath = dirPath + '/lib/file.dart';
- resourceProvider.newFile(filePath, 'library lib;');
- // create contexts
- server.setAnalysisRoots('0', [dirPath], [], {});
- // get pair
- ContextSourcePair pair = server.getContextSourcePair(filePath);
- _assertContextOfFolder(pair.context, dirPath);
- Source source = pair.source;
- expect(source, isNotNull);
- expect(source.uri.scheme, 'package');
- expect(source.fullName, filePath);
- }
-
/**
* Test that having multiple analysis contexts analyze the same file doesn't
* cause that file to receive duplicate notifications when it's modified.
@@ -364,59 +126,6 @@ import "../foo/foo.dart";
}
}
- test_operationsRemovedOnContextDisposal() async {
- resourceProvider.newFolder('/foo');
- resourceProvider.newFile('/foo/baz.dart', 'library lib;');
- resourceProvider.newFolder('/bar');
- resourceProvider.newFile('/bar/baz.dart', 'library lib;');
- server.setAnalysisRoots('0', ['/foo', '/bar'], [], {});
- await pumpEventQueue();
- AnalysisContext contextFoo = server.getAnalysisContext('/foo/baz.dart');
- AnalysisContext contextBar = server.getAnalysisContext('/bar/baz.dart');
- _MockServerOperation operationFoo = new _MockServerOperation(contextFoo);
- _MockServerOperation operationBar = new _MockServerOperation(contextBar);
- server.scheduleOperation(operationFoo);
- server.scheduleOperation(operationBar);
- server.setAnalysisRoots('1', ['/foo'], [], {});
- await pumpEventQueue();
- expect(operationFoo.isComplete, isTrue);
- expect(operationBar.isComplete, isFalse);
- }
-
- Future test_prioritySourcesChangedEvent() {
- resourceProvider.newFolder('/foo');
-
- int eventCount = 0;
- Source firstSource = null;
- server.onPriorityChange.listen((PriorityChangeEvent event) {
- ++eventCount;
- firstSource = event.firstSource;
- });
-
- server.setAnalysisRoots('0', ['/foo'], [], {});
- return pumpEventQueue().then((_) {
- expect(eventCount, 0);
-
- server.setPriorityFiles('1', ['/foo/bar.dart']);
- return pumpEventQueue();
- }).then((_) {
- expect(eventCount, 1);
- expect(firstSource.fullName, '/foo/bar.dart');
-
- server.setPriorityFiles('2', ['/foo/b1.dart', '/foo/b2.dart']);
- return pumpEventQueue();
- }).then((_) {
- expect(eventCount, 2);
- expect(firstSource.fullName, '/foo/b1.dart');
-
- server.setPriorityFiles('17', []);
- return pumpEventQueue();
- }).then((_) {
- expect(eventCount, 3);
- expect(firstSource, isNull);
- });
- }
-
void test_rethrowExceptions() {
Exception exceptionToThrow = new Exception('test exception');
MockServerOperation operation =
@@ -526,24 +235,6 @@ analyzer:
expect(response.error, isNotNull);
});
}
-
- void _assertContextOfFolder(
- AnalysisContext context, String expectedFolderPath) {
- Folder expectedFolder = resourceProvider.newFolder(expectedFolderPath);
- ContextInfo expectedContextInfo =
- (server.contextManager as ContextManagerImpl)
- .getContextInfoFor(expectedFolder);
- expect(expectedContextInfo, isNotNull);
- expect(context, same(expectedContextInfo.context));
- }
-
- void _configureSourceFactory(AnalysisContext context) {
- var resourceUriResolver = new ResourceUriResolver(resourceProvider);
- var packageUriResolver = new PackageMapUriResolver(
- resourceProvider, packageMapProvider.packageMap);
- context.sourceFactory =
- new SourceFactory([packageUriResolver, resourceUriResolver]);
- }
}
class EchoHandler implements RequestHandler {
@@ -555,22 +246,3 @@ class EchoHandler implements RequestHandler {
return null;
}
}
-
-/**
- * A [ServerOperation] that does nothing but keep track of whether or not it
- * has been performed.
- */
-class _MockServerOperation implements ServerOperation {
- final AnalysisContext context;
- bool isComplete = false;
-
- _MockServerOperation(this.context);
-
- @override
- ServerOperationPriority get priority => ServerOperationPriority.ANALYSIS;
-
- @override
- void perform(AnalysisServer server) {
- isComplete = true;
- }
-}
« no previous file with comments | « pkg/analysis_server/test/analysis_abstract.dart ('k') | pkg/analysis_server/test/context_manager_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698