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

Side by Side Diff: pkg/analyzer/test/src/context/builder_test.dart

Issue 2976473003: add analysis server --flutter-repo startup flag (Closed)
Patch Set: address comments Created 3 years, 5 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/analyzer/lib/src/context/builder.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
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/context/context_root.dart'; 7 import 'package:analyzer/context/context_root.dart';
8 import 'package:analyzer/file_system/file_system.dart'; 8 import 'package:analyzer/file_system/file_system.dart';
9 import 'package:analyzer/file_system/memory_file_system.dart'; 9 import 'package:analyzer/file_system/memory_file_system.dart';
10 import 'package:analyzer/source/package_map_resolver.dart'; 10 import 'package:analyzer/source/package_map_resolver.dart';
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 /** 71 /**
72 * The path to the default SDK, or `null` if the test has not explicitly 72 * The path to the default SDK, or `null` if the test has not explicitly
73 * invoked [createDefaultSdk]. 73 * invoked [createDefaultSdk].
74 */ 74 */
75 String defaultSdkPath = null; 75 String defaultSdkPath = null;
76 76
77 _MockLintRule _mockLintRule; 77 _MockLintRule _mockLintRule;
78 _MockLintRule _mockLintRule2; 78 _MockLintRule _mockLintRule2;
79 _MockLintRule _mockLintRule3; 79 _MockLintRule _mockLintRule3;
80 _MockLintRule _mockPublicMemberApiDocs;
80 81
81 Uri convertedDirectoryUri(String directoryPath) { 82 Uri convertedDirectoryUri(String directoryPath) {
82 return new Uri.directory(resourceProvider.convertPath(directoryPath), 83 return new Uri.directory(resourceProvider.convertPath(directoryPath),
83 windows: pathContext.style == path.windows.style); 84 windows: pathContext.style == path.windows.style);
84 } 85 }
85 86
86 void createDefaultSdk(Folder sdkDir) { 87 void createDefaultSdk(Folder sdkDir) {
87 defaultSdkPath = pathContext.join(sdkDir.path, 'default', 'sdk'); 88 defaultSdkPath = pathContext.join(sdkDir.path, 'default', 'sdk');
88 String librariesFilePath = pathContext.join(defaultSdkPath, 'lib', 89 String librariesFilePath = pathContext.join(defaultSdkPath, 'lib',
89 '_internal', 'sdk_library_metadata', 'lib', 'libraries.dart'); 90 '_internal', 'sdk_library_metadata', 'lib', 'libraries.dart');
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 ''' 765 '''
765 linter: 766 linter:
766 rules: 767 rules:
767 - mock_lint_rule 768 - mock_lint_rule
768 '''); 769 ''');
769 String projPath = resourceProvider.convertPath('/some/directory/path'); 770 String projPath = resourceProvider.convertPath('/some/directory/path');
770 AnalysisOptions options = builder.getAnalysisOptions(projPath); 771 AnalysisOptions options = builder.getAnalysisOptions(projPath);
771 _expectEqualOptions(options, expected); 772 _expectEqualOptions(options, expected);
772 } 773 }
773 774
775 void test_getAnalysisOptions_default_flutter_repo() {
776 _defineMockLintRules();
777 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl();
778 builderOptions.defaultOptions = defaultOptions;
779 AnalysisOptionsImpl expected = new AnalysisOptionsImpl();
780 expected.lint = true;
781 expected.lintRules = <Linter>[_mockLintRule, _mockPublicMemberApiDocs];
782 String packagesFilePath =
783 resourceProvider.convertPath('/some/directory/path/.packages');
784 createFile(packagesFilePath, 'flutter:/pkg/flutter/lib/');
785 String optionsFilePath = resourceProvider
786 .convertPath('/pkg/flutter/lib/analysis_options_user.yaml');
787 createFile(
788 optionsFilePath,
789 '''
790 linter:
791 rules:
792 - mock_lint_rule
793 ''');
794 String projPath = resourceProvider.convertPath('/some/directory/path');
795 AnalysisOptions options;
796 try {
797 ContextBuilderOptions.flutterRepo = true;
798 options = builder.getAnalysisOptions(projPath);
799 } finally {
800 ContextBuilderOptions.flutterRepo = false;
801 }
802 _expectEqualOptions(options, expected);
803 }
804
774 void test_getAnalysisOptions_default_noOverrides() { 805 void test_getAnalysisOptions_default_noOverrides() {
775 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); 806 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl();
776 defaultOptions.enableLazyAssignmentOperators = true; 807 defaultOptions.enableLazyAssignmentOperators = true;
777 builderOptions.defaultOptions = defaultOptions; 808 builderOptions.defaultOptions = defaultOptions;
778 AnalysisOptionsImpl expected = new AnalysisOptionsImpl(); 809 AnalysisOptionsImpl expected = new AnalysisOptionsImpl();
779 expected.enableLazyAssignmentOperators = true; 810 expected.enableLazyAssignmentOperators = true;
780 String path = resourceProvider.convertPath('/some/directory/path'); 811 String path = resourceProvider.convertPath('/some/directory/path');
781 String filePath = 812 String filePath =
782 pathContext.join(path, AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); 813 pathContext.join(path, AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE);
783 resourceProvider.newFile( 814 resourceProvider.newFile(
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 expect(result.path, filePath); 1036 expect(result.path, filePath);
1006 } 1037 }
1007 1038
1008 _defineMockLintRules() { 1039 _defineMockLintRules() {
1009 _mockLintRule = new _MockLintRule('mock_lint_rule'); 1040 _mockLintRule = new _MockLintRule('mock_lint_rule');
1010 Registry.ruleRegistry.registerDefault(_mockLintRule); 1041 Registry.ruleRegistry.registerDefault(_mockLintRule);
1011 _mockLintRule2 = new _MockLintRule('mock_lint_rule2'); 1042 _mockLintRule2 = new _MockLintRule('mock_lint_rule2');
1012 Registry.ruleRegistry.registerDefault(_mockLintRule2); 1043 Registry.ruleRegistry.registerDefault(_mockLintRule2);
1013 _mockLintRule3 = new _MockLintRule('mock_lint_rule3'); 1044 _mockLintRule3 = new _MockLintRule('mock_lint_rule3');
1014 Registry.ruleRegistry.register(_mockLintRule3); 1045 Registry.ruleRegistry.register(_mockLintRule3);
1046 _mockPublicMemberApiDocs = new _MockLintRule('public_member_api_docs');
1047 Registry.ruleRegistry.register(_mockPublicMemberApiDocs);
1015 } 1048 }
1016 1049
1017 void _expectEqualOptions( 1050 void _expectEqualOptions(
1018 AnalysisOptionsImpl actual, AnalysisOptionsImpl expected) { 1051 AnalysisOptionsImpl actual, AnalysisOptionsImpl expected) {
1019 // TODO(brianwilkerson) Consider moving this to AnalysisOptionsImpl.==. 1052 // TODO(brianwilkerson) Consider moving this to AnalysisOptionsImpl.==.
1020 expect(actual.analyzeFunctionBodiesPredicate, 1053 expect(actual.analyzeFunctionBodiesPredicate,
1021 same(expected.analyzeFunctionBodiesPredicate)); 1054 same(expected.analyzeFunctionBodiesPredicate));
1022 expect(actual.dart2jsHint, expected.dart2jsHint); 1055 expect(actual.dart2jsHint, expected.dart2jsHint);
1023 expect(actual.enableLazyAssignmentOperators, 1056 expect(actual.enableLazyAssignmentOperators,
1024 expected.enableLazyAssignmentOperators); 1057 expected.enableLazyAssignmentOperators);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 class _MockLintRule implements LintRule { 1107 class _MockLintRule implements LintRule {
1075 final String _name; 1108 final String _name;
1076 1109
1077 _MockLintRule(this._name); 1110 _MockLintRule(this._name);
1078 1111
1079 @override 1112 @override
1080 String get name => _name; 1113 String get name => _name;
1081 1114
1082 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 1115 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
1083 } 1116 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/context/builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698