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/plugin/options.dart'; | 9 import 'package:analyzer/plugin/options.dart'; |
10 import 'package:analyzer/src/context/builder.dart'; | 10 import 'package:analyzer/src/context/builder.dart'; |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 (plugin.optionsProcessorExtensionPoint as ExtensionPointImpl) | 548 (plugin.optionsProcessorExtensionPoint as ExtensionPointImpl) |
549 .add(processor); | 549 .add(processor); |
550 AnalysisContext context = engine.createAnalysisContext(); | 550 AnalysisContext context = engine.createAnalysisContext(); |
551 AnalysisOptions options = builder.getAnalysisOptions(context, path); | 551 AnalysisOptions options = builder.getAnalysisOptions(context, path); |
552 _expectEqualOptions(options, expected); | 552 _expectEqualOptions(options, expected); |
553 } finally { | 553 } finally { |
554 plugin.registerExtensionPoints((_) {}); | 554 plugin.registerExtensionPoints((_) {}); |
555 } | 555 } |
556 } | 556 } |
557 | 557 |
| 558 void test_getAnalysisOptions_includes() { |
| 559 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); |
| 560 defaultOptions.enableGenericMethods = true; |
| 561 builderOptions.defaultOptions = defaultOptions; |
| 562 AnalysisOptionsImpl expected = new AnalysisOptionsImpl(); |
| 563 expected.enableSuperMixins = true; |
| 564 expected.enableGenericMethods = true; |
| 565 resourceProvider.newFile( |
| 566 resourceProvider.convertPath('/mypkgs/somepkg/lib/here.yaml'), |
| 567 ''' |
| 568 two: {boo: newt} |
| 569 '''); |
| 570 String path = resourceProvider.convertPath('/some/directory/path'); |
| 571 resourceProvider.newFile( |
| 572 pathContext.join(path, '.packages'), |
| 573 ''' |
| 574 somepkg:/mypkgs/somepkg/lib |
| 575 '''); |
| 576 resourceProvider.newFile( |
| 577 pathContext.join(path, 'bar.yaml'), |
| 578 ''' |
| 579 include: package:somepkg/here.yaml |
| 580 foo: {bar: baz} |
| 581 '''); |
| 582 String filePath = |
| 583 pathContext.join(path, AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); |
| 584 resourceProvider.newFile( |
| 585 filePath, |
| 586 ''' |
| 587 include: bar.yaml |
| 588 analyzer: |
| 589 language: |
| 590 enableSuperMixins : true |
| 591 '''); |
| 592 |
| 593 AnalysisEngine engine = AnalysisEngine.instance; |
| 594 OptionsPlugin plugin = engine.optionsPlugin; |
| 595 plugin.registerExtensionPoints((_) {}); |
| 596 try { |
| 597 _TestOptionsProcessor processor = new _TestOptionsProcessor(); |
| 598 processor.expectedOptions = <String, Object>{ |
| 599 'analyzer': { |
| 600 'language': {'enableSuperMixins': true} |
| 601 }, |
| 602 'foo': {'bar': 'baz'}, |
| 603 'two': {'boo': 'newt'}, |
| 604 }; |
| 605 (plugin.optionsProcessorExtensionPoint as ExtensionPointImpl) |
| 606 .add(processor); |
| 607 AnalysisContext context = engine.createAnalysisContext(); |
| 608 AnalysisOptions options = builder.getAnalysisOptions(context, path); |
| 609 _expectEqualOptions(options, expected); |
| 610 } finally { |
| 611 plugin.registerExtensionPoints((_) {}); |
| 612 } |
| 613 } |
| 614 |
558 void test_getAnalysisOptions_invalid() { | 615 void test_getAnalysisOptions_invalid() { |
559 String path = resourceProvider.convertPath('/some/directory/path'); | 616 String path = resourceProvider.convertPath('/some/directory/path'); |
560 String filePath = | 617 String filePath = |
561 pathContext.join(path, AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); | 618 pathContext.join(path, AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); |
562 resourceProvider.newFile(filePath, ';'); | 619 resourceProvider.newFile(filePath, ';'); |
563 | 620 |
564 AnalysisEngine engine = AnalysisEngine.instance; | 621 AnalysisEngine engine = AnalysisEngine.instance; |
565 OptionsPlugin plugin = engine.optionsPlugin; | 622 OptionsPlugin plugin = engine.optionsPlugin; |
566 plugin.registerExtensionPoints((_) {}); | 623 plugin.registerExtensionPoints((_) {}); |
567 try { | 624 try { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 fail('Unexpected invocation of optionsProcessed'); | 800 fail('Unexpected invocation of optionsProcessed'); |
744 } | 801 } |
745 expect(options, hasLength(expectedOptions.length)); | 802 expect(options, hasLength(expectedOptions.length)); |
746 for (String key in expectedOptions.keys) { | 803 for (String key in expectedOptions.keys) { |
747 expect(options.containsKey(key), isTrue, reason: 'missing key $key'); | 804 expect(options.containsKey(key), isTrue, reason: 'missing key $key'); |
748 expect(options[key], expectedOptions[key], | 805 expect(options[key], expectedOptions[key], |
749 reason: 'values for key $key do not match'); | 806 reason: 'values for key $key do not match'); |
750 } | 807 } |
751 } | 808 } |
752 } | 809 } |
OLD | NEW |