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 365c5f2ce5d38e4f63bc1abeee6fd284a79f5ca3..ca17096c2712207fea948b260d0887dda3e2d6dd 100644 |
| --- a/pkg/front_end/test/src/base/processed_options_test.dart |
| +++ b/pkg/front_end/test/src/base/processed_options_test.dart |
| @@ -9,7 +9,7 @@ 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:kernel/binary/ast_to_binary.dart' show BinaryPrinter; |
| -import 'package:kernel/kernel.dart' show Program, Library; |
| +import 'package:kernel/kernel.dart' show Program, Library, CanonicalName; |
| import 'package:test/test.dart'; |
| import 'package:test_reflective_loader/test_reflective_loader.dart'; |
|
ahe
2017/07/06 13:12:22
Not a big fan of this.
|
| @@ -37,6 +37,22 @@ class ProcessedOptionsTest { |
| } |
| } |
| + test_sdk_summary_inferred() { |
| + // The sdk-summary is inferred by default form sdk-root, when compile-sdk is |
| + // false |
| + var raw = new CompilerOptions() |
| + ..sdkRoot = Uri.parse('file:///sdk/dir/') |
| + ..compileSdk = false; |
| + expect(new ProcessedOptions(raw).sdkSummary, |
| + Uri.parse('file:///sdk/dir/outline.dill')); |
| + |
| + // But it is left null when compile-sdk is true |
| + raw = new CompilerOptions() |
| + ..sdkRoot = Uri.parse('file:///sdk/dir/') |
| + ..compileSdk = true; |
| + expect(new ProcessedOptions(raw).sdkSummary, null); |
| + } |
| + |
| test_fileSystem_noBazelRoots() { |
| // When no bazel roots are specified, the filesystem should be passed |
| // through unmodified. |
| @@ -61,7 +77,7 @@ class ProcessedOptionsTest { |
| Future<Null> checkMockSummary(CompilerOptions raw) async { |
| var processed = new ProcessedOptions(raw); |
| - var sdkSummary = await processed.sdkSummaryProgram; |
| + var sdkSummary = await processed.loadSdkSummary(new CanonicalName.root()); |
| expect(sdkSummary.libraries.single.importUri, |
| mockSummary.libraries.single.importUri); |
| } |
| @@ -113,4 +129,97 @@ class ProcessedOptionsTest { |
| var uriTranslator = await processed.getUriTranslator(); |
| expect(uriTranslator.packages, isEmpty); |
| } |
| + |
| + test_validateOptions_root_exists() async { |
| + var sdkRoot = Uri.parse('file:///sdk/root/'); |
| + fileSystem |
| + // Note: this test is a bit hackish because the memory file system |
| + // doesn't have the notion of directories. |
| + .entityForUri(sdkRoot) |
| + .writeAsStringSync('\n'); |
| + fileSystem |
| + .entityForUri(sdkRoot.resolve('outline.dill')) |
| + .writeAsStringSync('\n'); |
| + |
| + var errors = []; |
| + var raw = new CompilerOptions() |
| + ..sdkRoot = sdkRoot |
| + ..fileSystem = fileSystem |
| + ..onError = (e) => errors.add(e); |
| + var options = new ProcessedOptions(raw); |
| + var result = await options.validateOptions(); |
| + // Note: we check this first so test failures show the cause directly. |
| + expect(errors, isEmpty); |
| + expect(result, isTrue); |
| + } |
| + |
| + test_validateOptions_root_doesnt_exists() async { |
| + var sdkRoot = Uri.parse('file:///sdk/root'); |
| + var errors = []; |
| + var raw = new CompilerOptions() |
| + ..sdkRoot = sdkRoot |
| + ..fileSystem = fileSystem |
| + ..onError = (e) => errors.add(e); |
| + var options = new ProcessedOptions(raw); |
| + expect(await options.validateOptions(), isFalse); |
| + expect('${errors.first}', contains("SDK root directory not found")); |
| + } |
| + |
| + test_validateOptions_summary_exists() async { |
| + var sdkSummary = Uri.parse('file:///sdk/root/outline.dill'); |
| + fileSystem.entityForUri(sdkSummary).writeAsStringSync('\n'); |
| + |
| + var errors = []; |
| + var raw = new CompilerOptions() |
| + ..sdkSummary = sdkSummary |
| + ..fileSystem = fileSystem |
| + ..onError = (e) => errors.add(e); |
| + var options = new ProcessedOptions(raw); |
| + var result = await options.validateOptions(); |
| + expect(errors, isEmpty); |
| + expect(result, isTrue); |
| + } |
| + |
| + test_validateOptions_summary_doesnt_exists() async { |
| + var sdkSummary = Uri.parse('file:///sdk/root/outline.dill'); |
| + var errors = []; |
| + var raw = new CompilerOptions() |
| + ..sdkSummary = sdkSummary |
| + ..fileSystem = fileSystem |
| + ..onError = (e) => errors.add(e); |
| + var options = new ProcessedOptions(raw); |
| + expect(await options.validateOptions(), isFalse); |
| + expect('${errors.first}', contains("SDK summary not found")); |
| + } |
| + |
| + test_validateOptions_inferred_summary_exists() async { |
| + var sdkRoot = Uri.parse('file:///sdk/root/'); |
| + var sdkSummary = Uri.parse('file:///sdk/root/outline.dill'); |
| + fileSystem.entityForUri(sdkRoot).writeAsStringSync('\n'); |
| + fileSystem.entityForUri(sdkSummary).writeAsStringSync('\n'); |
| + |
| + var errors = []; |
| + var raw = new CompilerOptions() |
| + ..sdkRoot = sdkRoot |
| + ..fileSystem = fileSystem |
| + ..onError = (e) => errors.add(e); |
| + var options = new ProcessedOptions(raw); |
| + var result = await options.validateOptions(); |
| + expect(errors, isEmpty); |
| + expect(result, isTrue); |
| + } |
| + |
| + test_validateOptions_inferred_summary_doesnt_exists() async { |
| + var sdkRoot = Uri.parse('file:///sdk/root/'); |
| + var sdkSummary = Uri.parse('file:///sdk/root/outline.dill'); |
| + fileSystem.entityForUri(sdkRoot).writeAsStringSync('\n'); |
| + var errors = []; |
| + var raw = new CompilerOptions() |
| + ..sdkSummary = sdkSummary |
| + ..fileSystem = fileSystem |
| + ..onError = (e) => errors.add(e); |
| + var options = new ProcessedOptions(raw); |
| + expect(await options.validateOptions(), isFalse); |
| + expect('${errors.first}', contains("SDK summary not found")); |
| + } |
| } |