| 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
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ff34028afb3a28f5e4016854996fbbc401cbcb11
|
| --- /dev/null
|
| +++ b/pkg/front_end/test/src/base/processed_options_test.dart
|
| @@ -0,0 +1,82 @@
|
| +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
|
| +// 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 '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:path/path.dart' as pathos;
|
| +import 'package:test/test.dart';
|
| +import 'package:test_reflective_loader/test_reflective_loader.dart';
|
| +
|
| +main() {
|
| + defineReflectiveSuite(() {
|
| + defineReflectiveTests(ProcessedOptionsTest);
|
| + });
|
| +}
|
| +
|
| +@reflectiveTest
|
| +class ProcessedOptionsTest {
|
| + final fileSystem = new MemoryFileSystem(pathos.posix, '/');
|
| +
|
| + test_compileSdk_false() {
|
| + for (var value in [false, true]) {
|
| + var raw = new CompilerOptions()..compileSdk = value;
|
| + var processed = new ProcessedOptions(raw);
|
| + expect(processed.compileSdk, value);
|
| + }
|
| + }
|
| +
|
| + test_fileSystem_noBazelRoots() {
|
| + // When no bazel roots are specified, the filesystem should be passed
|
| + // through unmodified.
|
| + var raw = new CompilerOptions()..fileSystem = fileSystem;
|
| + var processed = new ProcessedOptions(raw);
|
| + expect(processed.fileSystem, same(fileSystem));
|
| + }
|
| +
|
| + test_getUriResolver_explicitPackagesFile() async {
|
| + // This .packages file should be ignored.
|
| + fileSystem.entityForPath('/.packages').writeAsStringSync('foo:bar\n');
|
| + // This one should be used.
|
| + fileSystem
|
| + .entityForPath('/explicit.packages')
|
| + .writeAsStringSync('foo:baz\n');
|
| + var raw = new CompilerOptions()
|
| + ..fileSystem = fileSystem
|
| + ..packagesFilePath = '/explicit.packages';
|
| + var processed = new ProcessedOptions(raw);
|
| + var uriResolver = await processed.getUriResolver();
|
| + expect(uriResolver.packages, {'foo': Uri.parse('file:///baz/')});
|
| + expect(uriResolver.pathContext, same(fileSystem.context));
|
| + }
|
| +
|
| + test_getUriResolver_explicitPackagesFile_withBaseLocation() async {
|
| + // This .packages file should be ignored.
|
| + fileSystem.entityForPath('/.packages').writeAsStringSync('foo:bar\n');
|
| + // This one should be used.
|
| + fileSystem
|
| + .entityForPath('/base/location/explicit.packages')
|
| + .writeAsStringSync('foo:baz\n');
|
| + var raw = new CompilerOptions()
|
| + ..fileSystem = fileSystem
|
| + ..packagesFilePath = '/base/location/explicit.packages';
|
| + var processed = new ProcessedOptions(raw);
|
| + var uriResolver = await processed.getUriResolver();
|
| + expect(
|
| + uriResolver.packages, {'foo': Uri.parse('file:///base/location/baz/')});
|
| + expect(uriResolver.pathContext, same(fileSystem.context));
|
| + }
|
| +
|
| + test_getUriResolver_noPackages() async {
|
| + // .packages file should be ignored.
|
| + fileSystem.entityForPath('/.packages').writeAsStringSync('foo:bar\n');
|
| + var raw = new CompilerOptions()
|
| + ..fileSystem = fileSystem
|
| + ..packagesFilePath = '';
|
| + var processed = new ProcessedOptions(raw);
|
| + var uriResolver = await processed.getUriResolver();
|
| + expect(uriResolver.packages, isEmpty);
|
| + expect(uriResolver.pathContext, same(fileSystem.context));
|
| + }
|
| +}
|
|
|