| 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 883dbc995586146497aa3df2e15b6d110a9f38a6..917576f515d56240e7d8817adb9fe9aa72c6c708 100644
|
| --- a/pkg/front_end/test/src/base/processed_options_test.dart
|
| +++ b/pkg/front_end/test/src/base/processed_options_test.dart
|
| @@ -8,6 +8,7 @@ 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:front_end/src/fasta/compiler_context.dart';
|
| import 'package:front_end/src/fasta/fasta_codes.dart';
|
| import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter;
|
| import 'package:kernel/kernel.dart' show Program, Library, CanonicalName;
|
| @@ -17,8 +18,10 @@ import 'package:test/test.dart';
|
| import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|
|
| main() {
|
| - defineReflectiveSuite(() {
|
| - defineReflectiveTests(ProcessedOptionsTest);
|
| + CompilerContext.runWithDefaultOptions((_) {
|
| + defineReflectiveSuite(() {
|
| + defineReflectiveTests(ProcessedOptionsTest);
|
| + });
|
| });
|
| }
|
|
|
| @@ -84,6 +87,58 @@ class ProcessedOptionsTest {
|
| mockSummary.libraries.single.importUri);
|
| }
|
|
|
| + test_getUriTranslator_explicitLibrariesSpec() async {
|
| + fileSystem
|
| + .entityForUri(Uri.parse('file:///.packages'))
|
| + .writeAsStringSync('');
|
| + fileSystem
|
| + .entityForUri(Uri.parse('file:///libraries.json'))
|
| + .writeAsStringSync('{"vm":{"libraries":{"foo":{"uri":"bar.dart"}}}}');
|
| + var raw = new CompilerOptions()
|
| + ..packagesFileUri = Uri.parse('file:///.packages')
|
| + ..fileSystem = fileSystem
|
| + ..librariesSpecificationUri = Uri.parse('file:///libraries.json');
|
| + var processed = new ProcessedOptions(raw);
|
| + var uriTranslator = await processed.getUriTranslator();
|
| + expect(uriTranslator.dartLibraries.libraryInfoFor('foo').uri.path,
|
| + '/bar.dart');
|
| + }
|
| +
|
| + test_getUriTranslator_inferredLibrariesSpec() async {
|
| + fileSystem
|
| + .entityForUri(Uri.parse('file:///.packages'))
|
| + .writeAsStringSync('');
|
| + fileSystem
|
| + .entityForUri(Uri.parse('file:///mysdk/lib/libraries.json'))
|
| + .writeAsStringSync('{"vm":{"libraries":{"foo":{"uri":"bar.dart"}}}}');
|
| + var raw = new CompilerOptions()
|
| + ..fileSystem = fileSystem
|
| + ..packagesFileUri = Uri.parse('file:///.packages')
|
| + ..compileSdk = true
|
| + ..sdkRoot = Uri.parse('file:///mysdk/');
|
| + var processed = new ProcessedOptions(raw);
|
| + var uriTranslator = await processed.getUriTranslator();
|
| + expect(uriTranslator.dartLibraries.libraryInfoFor('foo').uri.path,
|
| + '/mysdk/lib/bar.dart');
|
| + }
|
| +
|
| + test_getUriTranslator_notInferredLibrariesSpec() async {
|
| + fileSystem
|
| + .entityForUri(Uri.parse('file:///.packages'))
|
| + .writeAsStringSync('');
|
| + fileSystem
|
| + .entityForUri(Uri.parse('file:///mysdk/lib/libraries.json'))
|
| + .writeAsStringSync('{"vm":{"libraries":{"foo":{"uri":"bar.dart"}}}}');
|
| + var raw = new CompilerOptions()
|
| + ..fileSystem = fileSystem
|
| + ..packagesFileUri = Uri.parse('file:///.packages')
|
| + ..compileSdk = false // libraries.json is only inferred if true
|
| + ..sdkRoot = Uri.parse('file:///mysdk/');
|
| + var processed = new ProcessedOptions(raw);
|
| + var uriTranslator = await processed.getUriTranslator();
|
| + expect(uriTranslator.dartLibraries.libraryInfoFor('foo'), isNull);
|
| + }
|
| +
|
| checkPackageExpansion(
|
| String packageName, String packageDir, Packages packages) {
|
| var input = Uri.parse('package:$packageName/a.dart');
|
|
|