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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'package:front_end/compiler_options.dart';
6 import 'package:front_end/memory_file_system.dart';
7 import 'package:front_end/src/base/processed_options.dart';
8 import 'package:path/path.dart' as pathos;
9 import 'package:test/test.dart';
10 import 'package:test_reflective_loader/test_reflective_loader.dart';
11
12 main() {
13 defineReflectiveSuite(() {
14 defineReflectiveTests(ProcessedOptionsTest);
15 });
16 }
17
18 @reflectiveTest
19 class ProcessedOptionsTest {
20 final fileSystem = new MemoryFileSystem(pathos.posix, '/');
21
22 test_compileSdk_false() {
23 for (var value in [false, true]) {
24 var raw = new CompilerOptions()..compileSdk = value;
25 var processed = new ProcessedOptions(raw);
26 expect(processed.compileSdk, value);
27 }
28 }
29
30 test_fileSystem_noBazelRoots() {
31 // When no bazel roots are specified, the filesystem should be passed
32 // through unmodified.
33 var raw = new CompilerOptions()..fileSystem = fileSystem;
34 var processed = new ProcessedOptions(raw);
35 expect(processed.fileSystem, same(fileSystem));
36 }
37
38 test_getUriResolver_explicitPackagesFile() async {
39 // This .packages file should be ignored.
40 fileSystem.entityForPath('/.packages').writeAsStringSync('foo:bar\n');
41 // This one should be used.
42 fileSystem
43 .entityForPath('/explicit.packages')
44 .writeAsStringSync('foo:baz\n');
45 var raw = new CompilerOptions()
46 ..fileSystem = fileSystem
47 ..packagesFilePath = '/explicit.packages';
48 var processed = new ProcessedOptions(raw);
49 var uriResolver = await processed.getUriResolver();
50 expect(uriResolver.packages, {'foo': Uri.parse('file:///baz/')});
51 expect(uriResolver.pathContext, same(fileSystem.context));
52 }
53
54 test_getUriResolver_explicitPackagesFile_withBaseLocation() async {
55 // This .packages file should be ignored.
56 fileSystem.entityForPath('/.packages').writeAsStringSync('foo:bar\n');
57 // This one should be used.
58 fileSystem
59 .entityForPath('/base/location/explicit.packages')
60 .writeAsStringSync('foo:baz\n');
61 var raw = new CompilerOptions()
62 ..fileSystem = fileSystem
63 ..packagesFilePath = '/base/location/explicit.packages';
64 var processed = new ProcessedOptions(raw);
65 var uriResolver = await processed.getUriResolver();
66 expect(
67 uriResolver.packages, {'foo': Uri.parse('file:///base/location/baz/')});
68 expect(uriResolver.pathContext, same(fileSystem.context));
69 }
70
71 test_getUriResolver_noPackages() async {
72 // .packages file should be ignored.
73 fileSystem.entityForPath('/.packages').writeAsStringSync('foo:bar\n');
74 var raw = new CompilerOptions()
75 ..fileSystem = fileSystem
76 ..packagesFilePath = '';
77 var processed = new ProcessedOptions(raw);
78 var uriResolver = await processed.getUriResolver();
79 expect(uriResolver.packages, isEmpty);
80 expect(uriResolver.pathContext, same(fileSystem.context));
81 }
82 }
OLDNEW
« 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