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

Unified Diff: pkg/analyzer/test/src/context/mock_sdk.dart

Issue 2542853003: Create summary files in MockSdk classes (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/test/src/context/mock_sdk.dart
diff --git a/pkg/analyzer/test/src/context/mock_sdk.dart b/pkg/analyzer/test/src/context/mock_sdk.dart
index 464dec037785d7894801e1dc3a182316d2a20489..3d5ee7d9753f036d01cd155576de37fdcc275b73 100644
--- a/pkg/analyzer/test/src/context/mock_sdk.dart
+++ b/pkg/analyzer/test/src/context/mock_sdk.dart
@@ -351,7 +351,9 @@ class MockSdk implements DartSdk {
PackageBundle _bundle;
MockSdk(
- {bool dartAsync: true, resource.MemoryResourceProvider resourceProvider})
+ {bool buildSummaries: true,
+ bool dartAsync: true,
+ resource.MemoryResourceProvider resourceProvider})
: provider = resourceProvider ?? new resource.MemoryResourceProvider(),
sdkLibraries = dartAsync ? _LIBRARIES : [_LIB_CORE],
uriMap = dartAsync ? FULL_URI_MAP : NO_ASYNC_URI_MAP {
@@ -365,6 +367,13 @@ class MockSdk implements DartSdk {
provider.convertPath(
'$sdkRoot/lib/_internal/sdk_library_metadata/lib/libraries.dart'),
librariesContent);
+ if (buildSummaries) {
+ List<int> bytes = _computeLinkedBundleBytes();
+ provider.newFileWithBytes(
+ provider.convertPath('/lib/_internal/spec.sum'), bytes);
+ provider.newFileWithBytes(
+ provider.convertPath('/lib/_internal/strong.sum'), bytes);
+ }
}
@override
@@ -422,13 +431,7 @@ class MockSdk implements DartSdk {
@override
PackageBundle getLinkedBundle() {
if (_bundle == null) {
- List<Source> librarySources = sdkLibraries
- .map((SdkLibrary library) => mapDartUri(library.shortName))
- .toList();
- List<int> bytes = new SummaryBuilder(
- librarySources, context, context.analysisOptions.strongMode)
- .build();
- _bundle = new PackageBundle.fromBuffer(bytes);
+ _bundle = new PackageBundle.fromBuffer(_computeLinkedBundleBytes());
}
return _bundle;
}
@@ -467,6 +470,18 @@ class MockSdk implements DartSdk {
String newContent = updateContent(content);
provider.updateFile(path, newContent);
}
+
+ /**
+ * Compute the bytes in the linked bundle associated with this SDK.
scheglov 2016/12/02 01:15:52 "in the" -> "of the"?
Brian Wilkerson 2016/12/02 15:32:04 Done
+ */
+ List<int> _computeLinkedBundleBytes() {
+ List<Source> librarySources = sdkLibraries
+ .map((SdkLibrary library) => mapDartUri(library.shortName))
+ .toList();
+ return new SummaryBuilder(
+ librarySources, context, context.analysisOptions.strongMode)
+ .build();
+ }
}
class _MockSdkLibrary implements SdkLibrary {

Powered by Google App Engine
This is Rietveld 408576698