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

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

Issue 2986303003: Switch FE to use the libraries.json format. (Closed)
Patch Set: fix issues found on bots Created 3 years, 4 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 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');
« no previous file with comments | « pkg/front_end/test/src/base/libraries_specification_test.dart ('k') | pkg/front_end/test/src/incremental/file_state_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698