Chromium Code Reviews| 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..9ad9817d2c93dc73e0c4500e72a4f30adb2ac0ad 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((_) { |
|
Siggi Cherem (dart-lang)
2017/08/03 03:01:39
FYI - this line is not needed for this CL, but hel
|
| + 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":{"path":"bar.dart"}}}}'); |
| + var raw = new CompilerOptions() |
| + ..packagesFileUri = Uri.parse('file:///.packages') |
| + ..fileSystem = fileSystem |
| + ..librariesSpecUri = 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":{"path":"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":{"path":"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'); |