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

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

Issue 2664893003: improve analysis options include test (Closed)
Patch Set: merge Created 3 years, 10 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 | « no previous file | 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/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/src/command_line/arguments.dart'; 9 import 'package:analyzer/src/command_line/arguments.dart';
10 import 'package:analyzer/src/context/builder.dart'; 10 import 'package:analyzer/src/context/builder.dart';
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 analyzer: 626 analyzer:
627 language: 627 language:
628 enableSuperMixins : true 628 enableSuperMixins : true
629 '''); 629 ''');
630 630
631 AnalysisOptions options = builder.getAnalysisOptions(path); 631 AnalysisOptions options = builder.getAnalysisOptions(path);
632 _expectEqualOptions(options, expected); 632 _expectEqualOptions(options, expected);
633 } 633 }
634 634
635 void test_getAnalysisOptions_includes() { 635 void test_getAnalysisOptions_includes() {
636 MockLintRule mockLintRule = new MockLintRule('mock_lint_rule');
637 Registry.ruleRegistry.register(mockLintRule);
638 MockLintRule mockLintRule2 = new MockLintRule('mock_lint_rule2');
639 Registry.ruleRegistry.register(mockLintRule2);
640 MockLintRule mockLintRule3 = new MockLintRule('mock_lint_rule3');
641 Registry.ruleRegistry.register(mockLintRule3);
642
636 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); 643 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl();
644 defaultOptions.enableSuperMixins = false;
637 builderOptions.defaultOptions = defaultOptions; 645 builderOptions.defaultOptions = defaultOptions;
638 AnalysisOptionsImpl expected = new AnalysisOptionsImpl(); 646 AnalysisOptionsImpl expected = new AnalysisOptionsImpl();
639 expected.enableSuperMixins = true; 647 expected.enableSuperMixins = true;
648 expected.lint = true;
649 expected.lintRules = <Linter>[mockLintRule, mockLintRule2, mockLintRule3];
640 resourceProvider.newFile( 650 resourceProvider.newFile(
641 resourceProvider.convertPath('/mypkgs/somepkg/lib/here.yaml'), 651 resourceProvider.convertPath('/mypkgs/somepkg/lib/here.yaml'),
642 ''' 652 '''
643 two: {boo: newt} 653 linter:
654 rules:
655 - mock_lint_rule3
644 '''); 656 ''');
645 String path = resourceProvider.convertPath('/some/directory/path'); 657 String path = resourceProvider.convertPath('/some/directory/path');
646 resourceProvider.newFile( 658 resourceProvider.newFile(
647 pathContext.join(path, '.packages'), 659 pathContext.join(path, '.packages'),
648 ''' 660 '''
649 somepkg:../../../mypkgs/somepkg/lib 661 somepkg:../../../mypkgs/somepkg/lib
650 '''); 662 ''');
651 resourceProvider.newFile( 663 resourceProvider.newFile(
652 pathContext.join(path, 'bar.yaml'), 664 pathContext.join(path, 'bar.yaml'),
653 ''' 665 '''
654 include: package:somepkg/here.yaml 666 include: package:somepkg/here.yaml
655 foo: {bar: baz} 667 analyzer:
668 language:
669 enableSuperMixins : true
670 linter:
671 rules:
672 - mock_lint_rule2
656 '''); 673 ''');
657 String filePath = 674 String filePath =
658 pathContext.join(path, AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); 675 pathContext.join(path, AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE);
659 resourceProvider.newFile( 676 resourceProvider.newFile(
660 filePath, 677 filePath,
661 ''' 678 '''
662 include: bar.yaml 679 include: bar.yaml
663 analyzer: 680 linter:
664 language: 681 rules:
665 enableSuperMixins : true 682 - mock_lint_rule
666 '''); 683 ''');
667 684
668 AnalysisOptions options = builder.getAnalysisOptions(path); 685 AnalysisOptions options = builder.getAnalysisOptions(path);
669 _expectEqualOptions(options, expected); 686 _expectEqualOptions(options, expected);
670 } 687 }
671 688
672 void test_getAnalysisOptions_invalid() { 689 void test_getAnalysisOptions_invalid() {
673 String path = resourceProvider.convertPath('/some/directory/path'); 690 String path = resourceProvider.convertPath('/some/directory/path');
674 String filePath = 691 String filePath =
675 pathContext.join(path, AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); 692 pathContext.join(path, AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 class MockLintRule implements LintRule { 851 class MockLintRule implements LintRule {
835 final String _name; 852 final String _name;
836 853
837 MockLintRule(this._name); 854 MockLintRule(this._name);
838 855
839 @override 856 @override
840 String get name => _name; 857 String get name => _name;
841 858
842 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 859 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
843 } 860 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698