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

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

Issue 2894283002: Reapply CL: first step for modular support in fasta (Closed)
Patch Set: new changes since first CL Created 3 years, 7 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 e968c8abbe69d8774b3e99bac18b3799da3a8f7f..365c5f2ce5d38e4f63bc1abeee6fd284a79f5ca3 100644
--- a/pkg/front_end/test/src/base/processed_options_test.dart
+++ b/pkg/front_end/test/src/base/processed_options_test.dart
@@ -4,10 +4,13 @@
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';
+import 'package:front_end/src/fasta/fasta.dart' show ByteSink;
+import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter;
+import 'package:kernel/kernel.dart' show Program, Library;
+
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -21,16 +24,10 @@ main() {
class ProcessedOptionsTest {
final fileSystem = new MemoryFileSystem(Uri.parse('file:///'));
- PackageBundleBuilder _mockSdkSummary;
+ Program _mockOutline;
- 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);
- }
+ Program get mockSummary => _mockOutline ??=
+ new Program(libraries: [new Library(Uri.parse('file:///a/b.dart'))]);
test_compileSdk_false() {
for (var value in [false, true]) {
@@ -48,31 +45,6 @@ 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);
@@ -81,6 +53,19 @@ class ProcessedOptionsTest {
..sdkSummary = uri);
}
+ void writeMockSummaryTo(Uri uri) {
+ var sink = new ByteSink();
+ new BinaryPrinter(sink).writeProgramFile(mockSummary);
+ fileSystem.entityForUri(uri).writeAsBytesSync(sink.builder.takeBytes());
+ }
+
+ Future<Null> checkMockSummary(CompilerOptions raw) async {
+ var processed = new ProcessedOptions(raw);
+ var sdkSummary = await processed.sdkSummaryProgram;
+ expect(sdkSummary.libraries.single.importUri,
+ mockSummary.libraries.single.importUri);
+ }
+
test_getUriTranslator_explicitPackagesFile() async {
// This .packages file should be ignored.
fileSystem
@@ -128,8 +113,4 @@ class ProcessedOptionsTest {
var uriTranslator = await processed.getUriTranslator();
expect(uriTranslator.packages, isEmpty);
}
-
- void writeMockSummaryTo(Uri uri) {
- fileSystem.entityForUri(uri).writeAsBytesSync(mockSdkSummary.toBuffer());
- }
}

Powered by Google App Engine
This is Rietveld 408576698