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

Unified Diff: pkg/analyzer/test/src/dart/analysis/file_state_test.dart

Issue 2653683004: Stop using SDK summary bundle. Analyze dart:xxx as any other libraries. (Closed)
Patch Set: Restore optional SDK bundle. Created 3 years, 11 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
Index: pkg/analyzer/test/src/dart/analysis/file_state_test.dart
diff --git a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
index 296b9c9cefe5162dd1a49df638c3bbc57cc16e84..f492fd6a21cca9c3c6afd0acbfe327eac0e36a19 100644
--- a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
@@ -31,20 +31,22 @@ main() {
@reflectiveTest
class FileSystemStateTest {
- static final MockSdk sdk = new MockSdk();
-
final MemoryResourceProvider provider = new MemoryResourceProvider();
+ MockSdk sdk;
+
final ByteStore byteStore = new MemoryByteStore();
final FileContentOverlay contentOverlay = new FileContentOverlay();
final StringBuffer logBuffer = new StringBuffer();
+ SourceFactory sourceFactory;
PerformanceLog logger;
FileSystemState fileSystemState;
void setUp() {
logger = new PerformanceLog(logBuffer);
- SourceFactory sourceFactory = new SourceFactory([
+ sdk = new MockSdk(resourceProvider: provider);
+ sourceFactory = new SourceFactory([
new DartUriResolver(sdk),
new PackageMapUriResolver(provider, <String, List<Folder>>{
'aaa': [provider.getFolder(_p('/aaa/lib'))],
@@ -55,7 +57,7 @@ class FileSystemStateTest {
AnalysisOptions analysisOptions = new AnalysisOptionsImpl()
..strongMode = true;
fileSystemState = new FileSystemState(logger, byteStore, contentOverlay,
- provider, sourceFactory, analysisOptions, new Uint32List(0), '');
+ provider, sourceFactory, analysisOptions, new Uint32List(0));
}
test_exportedTopLevelDeclarations_export() {
@@ -260,10 +262,10 @@ class A2 {}
expect(file.uri, FastUri.parse('package:aaa/a.dart'));
expect(file.content, '');
expect(file.contentHash, _md5(''));
- expect(file.importedFiles, isEmpty);
+ expect(_excludeSdk(file.importedFiles), isEmpty);
expect(file.exportedFiles, isEmpty);
expect(file.partedFiles, isEmpty);
- expect(file.directReferencedFiles, isEmpty);
+ expect(_excludeSdk(file.directReferencedFiles), isEmpty);
expect(file.isPart, isFalse);
expect(file.library, isNull);
expect(file.unlinked, isNotNull);
@@ -299,7 +301,7 @@ class A1 {}
expect(file.unlinked.classes, hasLength(1));
expect(file.unlinked.classes[0].name, 'A1');
- expect(file.importedFiles, hasLength(2));
+ expect(_excludeSdk(file.importedFiles), hasLength(2));
expect(file.importedFiles[0].path, a2);
expect(file.importedFiles[0].uri, FastUri.parse('package:aaa/a2.dart'));
expect(file.importedFiles[0].source, isNotNull);
@@ -319,7 +321,7 @@ class A1 {}
expect(file.partedFiles[0].path, a4);
expect(file.partedFiles[0].uri, FastUri.parse('package:aaa/a4.dart'));
- expect(file.directReferencedFiles, hasLength(5));
+ expect(_excludeSdk(file.directReferencedFiles), hasLength(5));
expect(fileSystemState.getFilesForPath(a1), [file]);
}
@@ -343,12 +345,12 @@ part 'd.dart';
part 'not_dart.txt';
''');
FileState file = fileSystemState.getFileForPath(a);
- expect(
- file.importedFiles.map((f) => f.path), unorderedEquals([b, not_dart]));
+ expect(_excludeSdk(file.importedFiles).map((f) => f.path),
+ unorderedEquals([b, not_dart]));
expect(
file.exportedFiles.map((f) => f.path), unorderedEquals([c, not_dart]));
expect(file.partedFiles.map((f) => f.path), unorderedEquals([d, not_dart]));
- expect(fileSystemState.knownFilePaths,
+ expect(_excludeSdk(fileSystemState.knownFilePaths),
unorderedEquals([a, b, c, d, not_dart]));
}
@@ -376,10 +378,10 @@ class A2 {}
expect(file_a2.unlinked.classes, hasLength(1));
expect(file_a2.unlinked.classes[0].name, 'A2');
- expect(file_a2.importedFiles, isEmpty);
+ expect(_excludeSdk(file_a2.importedFiles), isEmpty);
expect(file_a2.exportedFiles, isEmpty);
expect(file_a2.partedFiles, isEmpty);
- expect(file_a2.directReferencedFiles, isEmpty);
+ expect(_excludeSdk(file_a2.directReferencedFiles), isEmpty);
// The library is not known yet.
expect(file_a2.isPart, isTrue);
@@ -389,7 +391,8 @@ class A2 {}
FileState file_a1 = fileSystemState.getFileForPath(a1);
expect(file_a1.partedFiles, hasLength(1));
expect(file_a1.partedFiles[0], same(file_a2));
- expect(file_a1.directReferencedFiles, unorderedEquals([file_a2]));
+ expect(
+ _excludeSdk(file_a1.directReferencedFiles), unorderedEquals([file_a2]));
// Now the part knows its library.
expect(file_a2.library, same(file_a1));
@@ -563,7 +566,8 @@ set _V3(_) {}
fb.transitiveFiles;
fc.transitiveFiles;
fd.transitiveFiles;
- expect(fileSystemState.test.filesWithoutTransitiveFiles, isEmpty);
+ expect(
+ _excludeSdk(fileSystemState.test.filesWithoutTransitiveFiles), isEmpty);
// No imports, so just a single file.
provider.newFile(pa, "");
@@ -646,13 +650,15 @@ set _V3(_) {}
expect(fb.transitiveSignature, isNotNull);
expect(fc.transitiveSignature, isNotNull);
expect(fd.transitiveSignature, isNotNull);
- expect(fileSystemState.test.filesWithoutTransitiveFiles, isEmpty);
+ expect(
+ _excludeSdk(fileSystemState.test.filesWithoutTransitiveFiles), isEmpty);
// Make an update to a.dart that does not change its API signature.
// All transitive signatures are still valid.
provider.newFile(pa, "class A {} // the same API signature");
fa.refresh();
- expect(fileSystemState.test.filesWithoutTransitiveFiles, isEmpty);
+ expect(
+ _excludeSdk(fileSystemState.test.filesWithoutTransitiveFiles), isEmpty);
// Change a.dart API signature, also flush signatures of b.dart and c.dart,
// but d.dart is still OK.
@@ -670,16 +676,26 @@ set _V3(_) {}
void _assertFilesWithoutTransitiveFiles(List<FileState> expected) {
var actual = fileSystemState.test.filesWithoutTransitiveFiles;
- expect(actual, unorderedEquals(expected));
+ expect(_excludeSdk(actual), unorderedEquals(expected));
}
void _assertFilesWithoutTransitiveSignatures(List<FileState> expected) {
var actual = fileSystemState.test.filesWithoutTransitiveSignature;
- expect(actual, unorderedEquals(expected));
+ expect(_excludeSdk(actual), unorderedEquals(expected));
}
void _assertTransitiveFiles(FileState file, List<FileState> expected) {
- expect(file.transitiveFiles, unorderedEquals(expected));
+ expect(_excludeSdk(file.transitiveFiles), unorderedEquals(expected));
+ }
+
+ List<T> _excludeSdk<T>(Iterable<T> files) {
+ return files.where((T file) {
+ if (file is FileState) {
+ return file.uri.scheme != 'dart';
+ } else {
+ return !(file as String).startsWith(_p('/sdk'));
+ }
+ }).toList();
}
String _p(String path) => provider.convertPath(path);
« no previous file with comments | « pkg/analyzer/test/src/dart/analysis/driver_test.dart ('k') | pkg/analyzer/test/src/dart/analysis/search_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698