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

Unified Diff: pkg/front_end/test/src/base/processed_options_test.dart

Issue 2625533002: Add code to ProcessedOptions to fetch the SDK summary bundle. (Closed)
Patch Set: 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/front_end/test/src/base/processed_options_test.dart
diff --git a/pkg/front_end/test/src/base/processed_options_test.dart b/pkg/front_end/test/src/base/processed_options_test.dart
index 76151dd0339b5c2aa303d5b1de50557bfca4aeae..94941f1cd5efcd498721f53f61d5fd5e663a5e08 100644
--- a/pkg/front_end/test/src/base/processed_options_test.dart
+++ b/pkg/front_end/test/src/base/processed_options_test.dart
@@ -2,6 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'dart:async';
+
+import 'package:analyzer/src/summary/format.dart';
import 'package:front_end/compiler_options.dart';
import 'package:front_end/memory_file_system.dart';
import 'package:front_end/src/base/processed_options.dart';
@@ -19,6 +22,17 @@ main() {
class ProcessedOptionsTest {
final fileSystem = new MemoryFileSystem(pathos.posix, Uri.parse('file:///'));
+ PackageBundleBuilder _mockSdkSummary;
+
+ PackageBundleBuilder get mockSdkSummary => _mockSdkSummary ??=
+ new PackageBundleBuilder(apiSignature: 'mock summary signature');
+
+ Future<Null> checkMockSummary(CompilerOptions raw) async {
+ var processed = new ProcessedOptions(raw);
+ var sdkSummary = await processed.getSdkSummary();
+ expect(sdkSummary.apiSignature, mockSdkSummary.apiSignature);
+ }
+
test_compileSdk_false() {
for (var value in [false, true]) {
var raw = new CompilerOptions()..compileSdk = value;
@@ -35,6 +49,39 @@ class ProcessedOptionsTest {
expect(processed.fileSystem, same(fileSystem));
}
+ test_getSdkSummary_sdkLocationProvided_noTrailingSlash() async {
+ var uri = Uri.parse('file:///sdk');
+ writeMockSummaryTo(Uri.parse('$uri/lib/_internal/strong.sum'));
+ checkMockSummary(new CompilerOptions()
+ ..fileSystem = fileSystem
+ ..sdkRoot = uri);
+ }
+
+ test_getSdkSummary_sdkLocationProvided_spec() async {
+ var uri = Uri.parse('file:///sdk');
+ writeMockSummaryTo(Uri.parse('$uri/lib/_internal/spec.sum'));
+ checkMockSummary(new CompilerOptions()
+ ..fileSystem = fileSystem
+ ..strongMode = false
+ ..sdkRoot = uri);
+ }
+
+ test_getSdkSummary_sdkLocationProvided_trailingSlash() async {
+ var uri = Uri.parse('file:///sdk');
+ writeMockSummaryTo(Uri.parse('$uri/lib/_internal/strong.sum'));
+ checkMockSummary(new CompilerOptions()
+ ..fileSystem = fileSystem
+ ..sdkRoot = Uri.parse('$uri/'));
+ }
+
+ test_getSdkSummary_summaryLocationProvided() async {
+ var uri = Uri.parse('file:///sdkSummary');
+ writeMockSummaryTo(uri);
+ checkMockSummary(new CompilerOptions()
+ ..fileSystem = fileSystem
+ ..sdkSummary = uri);
+ }
+
test_getUriResolver_explicitPackagesFile() async {
// This .packages file should be ignored.
fileSystem
@@ -82,4 +129,8 @@ class ProcessedOptionsTest {
var uriResolver = await processed.getUriResolver();
expect(uriResolver.packages, isEmpty);
}
+
+ void writeMockSummaryTo(Uri uri) {
+ fileSystem.entityForUri(uri).writeAsBytesSync(mockSdkSummary.toBuffer());
+ }
}

Powered by Google App Engine
This is Rietveld 408576698