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

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

Issue 2618633006: Create a wrapper class to handle CompilerOptions in a uniform way. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « pkg/front_end/lib/src/base/processed_options.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
+ }
+}
« no previous file with comments | « pkg/front_end/lib/src/base/processed_options.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698