| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.source.error_processor; | 5 library analyzer.test.source.error_processor; |
| 6 | 6 |
| 7 import 'package:analyzer/source/analysis_options_provider.dart'; | 7 import 'package:analyzer/source/analysis_options_provider.dart'; |
| 8 import 'package:analyzer/source/error_processor.dart'; | 8 import 'package:analyzer/source/error_processor.dart'; |
| 9 import 'package:analyzer/src/context/context.dart'; | 9 import 'package:analyzer/src/context/context.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 AnalysisError unused_local_variable = new AnalysisError( | 32 AnalysisError unused_local_variable = new AnalysisError( |
| 33 new TestSource(), 0, 1, HintCode.UNUSED_LOCAL_VARIABLE, [ | 33 new TestSource(), 0, 1, HintCode.UNUSED_LOCAL_VARIABLE, [ |
| 34 ['x'] | 34 ['x'] |
| 35 ]); | 35 ]); |
| 36 | 36 |
| 37 AnalysisError use_of_void_result = | 37 AnalysisError use_of_void_result = |
| 38 new AnalysisError(new TestSource(), 0, 1, HintCode.USE_OF_VOID_RESULT, [ | 38 new AnalysisError(new TestSource(), 0, 1, HintCode.USE_OF_VOID_RESULT, [ |
| 39 ['x'] | 39 ['x'] |
| 40 ]); | 40 ]); |
| 41 | 41 |
| 42 AnalysisError non_bool_operand = new AnalysisError( |
| 43 new TestSource(), 0, 1, StaticTypeWarningCode.NON_BOOL_OPERAND, [ |
| 44 ['x'] |
| 45 ]); |
| 46 |
| 42 oneTimeSetup(); | 47 oneTimeSetup(); |
| 43 | 48 |
| 44 setUp(() { | 49 setUp(() { |
| 45 context = new TestContext(); | 50 context = new TestContext(); |
| 46 }); | 51 }); |
| 47 | 52 |
| 48 group('ErrorProcessor', () { | 53 group('ErrorProcessor', () { |
| 49 test('configureOptions', () { | 54 test('configureOptions', () { |
| 50 configureOptions(''' | 55 configureOptions(''' |
| 51 analyzer: | 56 analyzer: |
| 52 errors: | 57 errors: |
| 53 invalid_assignment: error # severity ERROR | 58 invalid_assignment: error # severity ERROR |
| 54 missing_return: false # ignore | 59 missing_return: false # ignore |
| 55 unused_local_variable: true # skipped | 60 unused_local_variable: true # skipped |
| 56 use_of_void_result: unsupported_action # skipped | 61 use_of_void_result: unsupported_action # skipped |
| 57 '''); | 62 '''); |
| 58 expect(getProcessor(invalid_assignment).severity, ErrorSeverity.ERROR); | 63 expect(getProcessor(invalid_assignment).severity, ErrorSeverity.ERROR); |
| 59 expect(getProcessor(missing_return).severity, isNull); | 64 expect(getProcessor(missing_return).severity, isNull); |
| 60 expect(getProcessor(unused_local_variable), isNull); | 65 expect(getProcessor(unused_local_variable), isNull); |
| 61 expect(getProcessor(use_of_void_result), isNull); | 66 expect(getProcessor(use_of_void_result), isNull); |
| 62 }); | 67 }); |
| 63 | 68 |
| 64 test('upgrades static type warnings to errors in strong mode', () { | 69 test('upgrades static type warnings to errors in strong mode', () { |
| 65 configureOptions(''' | 70 configureOptions(''' |
| 66 analyzer: | 71 analyzer: |
| 67 strong-mode: true | 72 strong-mode: true |
| 68 '''); | 73 '''); |
| 69 expect(getProcessor(invalid_assignment).severity, ErrorSeverity.ERROR); | 74 expect(getProcessor(non_bool_operand).severity, ErrorSeverity.ERROR); |
| 75 }); |
| 76 |
| 77 test('does not upgrade other warnings to errors in strong mode', () { |
| 78 configureOptions(''' |
| 79 analyzer: |
| 80 strong-mode: true |
| 81 '''); |
| 82 expect(getProcessor(unused_local_variable), isNull); |
| 70 }); | 83 }); |
| 71 }); | 84 }); |
| 72 | 85 |
| 73 group('ErrorConfig', () { | 86 group('ErrorConfig', () { |
| 74 var config = ''' | 87 var config = ''' |
| 75 analyzer: | 88 analyzer: |
| 76 errors: | 89 errors: |
| 77 invalid_assignment: unsupported_action # should be skipped | 90 invalid_assignment: unsupported_action # should be skipped |
| 78 missing_return: false | 91 missing_return: false |
| 79 unused_local_variable: error | 92 unused_local_variable: error |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 void oneTimeSetup() { | 160 void oneTimeSetup() { |
| 148 List<Plugin> plugins = <Plugin>[]; | 161 List<Plugin> plugins = <Plugin>[]; |
| 149 plugins.addAll(AnalysisEngine.instance.requiredPlugins); | 162 plugins.addAll(AnalysisEngine.instance.requiredPlugins); |
| 150 plugins.add(AnalysisEngine.instance.commandLinePlugin); | 163 plugins.add(AnalysisEngine.instance.commandLinePlugin); |
| 151 plugins.add(AnalysisEngine.instance.optionsPlugin); | 164 plugins.add(AnalysisEngine.instance.optionsPlugin); |
| 152 ExtensionManager manager = new ExtensionManager(); | 165 ExtensionManager manager = new ExtensionManager(); |
| 153 manager.processPlugins(plugins); | 166 manager.processPlugins(plugins); |
| 154 } | 167 } |
| 155 | 168 |
| 156 class TestContext extends AnalysisContextImpl {} | 169 class TestContext extends AnalysisContextImpl {} |
| OLD | NEW |