| 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); |
| 109 pathContext = resourceProvider.pathContext; | 115 pathContext = resourceProvider.pathContext; |
| 110 new MockSdk(resourceProvider: resourceProvider); | 116 new MockSdk(resourceProvider: resourceProvider); |
| 111 sdkManager = | 117 sdkManager = |
| 112 new DartSdkManager(resourceProvider.convertPath('/sdk'), false); | 118 new DartSdkManager(resourceProvider.convertPath('/sdk'), false); |
| 113 contentCache = new ContentCache(); | 119 contentCache = new ContentCache(); |
| 114 builder = new ContextBuilder(resourceProvider, sdkManager, contentCache, | 120 builder = new ContextBuilder(resourceProvider, sdkManager, contentCache, |
| 115 options: builderOptions); | 121 options: builderOptions); |
| 116 } | 122 } |
| 117 | 123 |
| 118 @failingTest | 124 @failingTest |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 _expectEqualOptions(options, expected); | 721 _expectEqualOptions(options, expected); |
| 716 } | 722 } |
| 717 | 723 |
| 718 void test_getAnalysisOptions_default_flutter() { | 724 void test_getAnalysisOptions_default_flutter() { |
| 719 _defineMockLintRules(); | 725 _defineMockLintRules(); |
| 720 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); | 726 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); |
| 721 builderOptions.defaultOptions = defaultOptions; | 727 builderOptions.defaultOptions = defaultOptions; |
| 722 AnalysisOptionsImpl expected = new AnalysisOptionsImpl(); | 728 AnalysisOptionsImpl expected = new AnalysisOptionsImpl(); |
| 723 expected.lint = true; | 729 expected.lint = true; |
| 724 expected.lintRules = <Linter>[_mockLintRule]; | 730 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'); |
| 725 createFile( | 738 createFile( |
| 726 resourceProvider.convertPath('/some/directory/path/.packages'), | 739 optionsFilePath, |
| 727 ''' | |
| 728 flutter:/pkg/flutter/lib/ | |
| 729 '''); | |
| 730 createFile( | |
| 731 resourceProvider | |
| 732 .convertPath('/pkg/flutter/lib/analysis_options_user.yaml'), | |
| 733 ''' | 740 ''' |
| 734 linter: | 741 linter: |
| 735 rules: | 742 rules: |
| 736 - mock_lint_rule | 743 - mock_lint_rule |
| 737 '''); | 744 '''); |
| 738 AnalysisOptions options = builder.getAnalysisOptions( | 745 String projPath = resourceProvider.convertPath('/some/directory/path'); |
| 739 resourceProvider.convertPath('/some/directory/path')); | 746 AnalysisOptions options = builder.getAnalysisOptions(projPath); |
| 740 // TODO(danrubel) fix on Windows | 747 // TODO(danrubel) fix on Windows |
| 741 if (resourceProvider.absolutePathContext.separator != r'\') { | 748 if (resourceProvider.absolutePathContext.separator != r'\') { |
| 742 _expectEqualOptions(options, expected); | 749 _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 <<<<<<<'); |
| 743 } | 757 } |
| 744 } | 758 } |
| 745 | 759 |
| 746 void test_getAnalysisOptions_default_noOverrides() { | 760 void test_getAnalysisOptions_default_noOverrides() { |
| 747 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); | 761 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); |
| 748 defaultOptions.enableLazyAssignmentOperators = true; | 762 defaultOptions.enableLazyAssignmentOperators = true; |
| 749 builderOptions.defaultOptions = defaultOptions; | 763 builderOptions.defaultOptions = defaultOptions; |
| 750 AnalysisOptionsImpl expected = new AnalysisOptionsImpl(); | 764 AnalysisOptionsImpl expected = new AnalysisOptionsImpl(); |
| 751 expected.enableLazyAssignmentOperators = true; | 765 expected.enableLazyAssignmentOperators = true; |
| 752 String path = resourceProvider.convertPath('/some/directory/path'); | 766 String path = resourceProvider.convertPath('/some/directory/path'); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 class _MockLintRule implements LintRule { | 1027 class _MockLintRule implements LintRule { |
| 1014 final String _name; | 1028 final String _name; |
| 1015 | 1029 |
| 1016 _MockLintRule(this._name); | 1030 _MockLintRule(this._name); |
| 1017 | 1031 |
| 1018 @override | 1032 @override |
| 1019 String get name => _name; | 1033 String get name => _name; |
| 1020 | 1034 |
| 1021 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 1035 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 1022 } | 1036 } |
| OLD | NEW |