| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer.test.src.context.context_builder_test; | 5 library analyzer.test.src.context.context_builder_test; |
| 6 | 6 |
| 7 import 'package:analyzer/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
| 8 import 'package:analyzer/file_system/memory_file_system.dart'; | 8 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 9 import 'package:analyzer/source/package_map_resolver.dart'; | 9 import 'package:analyzer/source/package_map_resolver.dart'; |
| 10 import 'package:analyzer/src/command_line/arguments.dart'; | 10 import 'package:analyzer/src/command_line/arguments.dart'; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 builder = new ContextBuilder(resourceProvider, sdkManager, contentCache, | 98 builder = new ContextBuilder(resourceProvider, sdkManager, contentCache, |
| 99 options: builderOptions); | 99 options: builderOptions); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void createFile(String path, String content) { | 102 void createFile(String path, String content) { |
| 103 resourceProvider.newFile(path, content); | 103 resourceProvider.newFile(path, content); |
| 104 } | 104 } |
| 105 | 105 |
| 106 @override | 106 @override |
| 107 void setUp() { | 107 void setUp() { |
| 108 resourceProvider = new MemoryResourceProvider( | 108 resourceProvider = new MemoryResourceProvider(); |
| 109 // On Windows, ensure that the current drive matches | |
| 110 // the drive inserted by MemoryResourceProvider.convertPath | |
| 111 // so that packages are mapped to the correct drive | |
| 112 context: path.style == path.Style.windows | |
| 113 ? new path.Context(current: 'C:\\') | |
| 114 : null); | |
| 115 pathContext = resourceProvider.pathContext; | 109 pathContext = resourceProvider.pathContext; |
| 116 new MockSdk(resourceProvider: resourceProvider); | 110 new MockSdk(resourceProvider: resourceProvider); |
| 117 sdkManager = | 111 sdkManager = |
| 118 new DartSdkManager(resourceProvider.convertPath('/sdk'), false); | 112 new DartSdkManager(resourceProvider.convertPath('/sdk'), false); |
| 119 contentCache = new ContentCache(); | 113 contentCache = new ContentCache(); |
| 120 builder = new ContextBuilder(resourceProvider, sdkManager, contentCache, | 114 builder = new ContextBuilder(resourceProvider, sdkManager, contentCache, |
| 121 options: builderOptions); | 115 options: builderOptions); |
| 122 } | 116 } |
| 123 | 117 |
| 124 @failingTest | 118 @failingTest |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 _expectEqualOptions(options, expected); | 715 _expectEqualOptions(options, expected); |
| 722 } | 716 } |
| 723 | 717 |
| 724 void test_getAnalysisOptions_default_flutter() { | 718 void test_getAnalysisOptions_default_flutter() { |
| 725 _defineMockLintRules(); | 719 _defineMockLintRules(); |
| 726 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); | 720 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); |
| 727 builderOptions.defaultOptions = defaultOptions; | 721 builderOptions.defaultOptions = defaultOptions; |
| 728 AnalysisOptionsImpl expected = new AnalysisOptionsImpl(); | 722 AnalysisOptionsImpl expected = new AnalysisOptionsImpl(); |
| 729 expected.lint = true; | 723 expected.lint = true; |
| 730 expected.lintRules = <Linter>[_mockLintRule]; | 724 expected.lintRules = <Linter>[_mockLintRule]; |
| 731 String packagesFilePath = | |
| 732 resourceProvider.convertPath('/some/directory/path/.packages'); | |
| 733 print('>>> packages: $packagesFilePath'); | |
| 734 createFile(packagesFilePath, 'flutter:/pkg/flutter/lib/'); | |
| 735 String optionsFilePath = resourceProvider | |
| 736 .convertPath('/pkg/flutter/lib/analysis_options_user.yaml'); | |
| 737 print('>>> options: $optionsFilePath'); | |
| 738 createFile( | 725 createFile( |
| 739 optionsFilePath, | 726 resourceProvider.convertPath('/some/directory/path/.packages'), |
| 727 ''' |
| 728 flutter:/pkg/flutter/lib/ |
| 729 '''); |
| 730 createFile( |
| 731 resourceProvider |
| 732 .convertPath('/pkg/flutter/lib/analysis_options_user.yaml'), |
| 740 ''' | 733 ''' |
| 741 linter: | 734 linter: |
| 742 rules: | 735 rules: |
| 743 - mock_lint_rule | 736 - mock_lint_rule |
| 744 '''); | 737 '''); |
| 745 String projPath = resourceProvider.convertPath('/some/directory/path'); | 738 AnalysisOptions options = builder.getAnalysisOptions( |
| 746 AnalysisOptions options = builder.getAnalysisOptions(projPath); | 739 resourceProvider.convertPath('/some/directory/path')); |
| 747 // TODO(danrubel) fix on Windows | 740 // TODO(danrubel) fix on Windows |
| 748 if (resourceProvider.absolutePathContext.separator != r'\') { | 741 if (resourceProvider.absolutePathContext.separator != r'\') { |
| 749 _expectEqualOptions(options, expected); | 742 _expectEqualOptions(options, expected); |
| 750 } else { | |
| 751 // echo some debugging information | |
| 752 print('>>> projPath: $projPath'); | |
| 753 print('>>> ${builderOptions.defaultAnalysisOptionsFilePath}'); | |
| 754 print('>>> getOptionsFile: ${builder.getOptionsFile(projPath)}'); | |
| 755 _expectEqualOptions(options, expected); | |
| 756 fail('>>>>>>> Fail to echo test output on bots <<<<<<<'); | |
| 757 } | 743 } |
| 758 } | 744 } |
| 759 | 745 |
| 760 void test_getAnalysisOptions_default_noOverrides() { | 746 void test_getAnalysisOptions_default_noOverrides() { |
| 761 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); | 747 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); |
| 762 defaultOptions.enableLazyAssignmentOperators = true; | 748 defaultOptions.enableLazyAssignmentOperators = true; |
| 763 builderOptions.defaultOptions = defaultOptions; | 749 builderOptions.defaultOptions = defaultOptions; |
| 764 AnalysisOptionsImpl expected = new AnalysisOptionsImpl(); | 750 AnalysisOptionsImpl expected = new AnalysisOptionsImpl(); |
| 765 expected.enableLazyAssignmentOperators = true; | 751 expected.enableLazyAssignmentOperators = true; |
| 766 String path = resourceProvider.convertPath('/some/directory/path'); | 752 String path = resourceProvider.convertPath('/some/directory/path'); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 class _MockLintRule implements LintRule { | 1013 class _MockLintRule implements LintRule { |
| 1028 final String _name; | 1014 final String _name; |
| 1029 | 1015 |
| 1030 _MockLintRule(this._name); | 1016 _MockLintRule(this._name); |
| 1031 | 1017 |
| 1032 @override | 1018 @override |
| 1033 String get name => _name; | 1019 String get name => _name; |
| 1034 | 1020 |
| 1035 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 1021 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 1036 } | 1022 } |
| OLD | NEW |