| 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 // TODO(jmesserly): this file needs to be refactored, it's a port from | 5 // TODO(jmesserly): this file needs to be refactored, it's a port from |
| 6 // package:dev_compiler's tests | 6 // package:dev_compiler's tests |
| 7 library test.src.task.strong.strong_test_helper; | 7 library test.src.task.strong.strong_test_helper; |
| 8 | 8 |
| 9 import 'package:analyzer/file_system/file_system.dart'; | 9 import 'package:analyzer/file_system/file_system.dart'; |
| 10 import 'package:analyzer/file_system/memory_file_system.dart'; | 10 import 'package:analyzer/file_system/memory_file_system.dart'; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 new MockDartSdk(mockSdkSources, reportMissing: true).resolver, | 68 new MockDartSdk(mockSdkSources, reportMissing: true).resolver, |
| 69 uriResolver | 69 uriResolver |
| 70 ]); | 70 ]); |
| 71 | 71 |
| 72 // Run the checker on /main.dart. | 72 // Run the checker on /main.dart. |
| 73 Source mainSource = uriResolver.resolveAbsolute(new Uri.file('/main.dart')); | 73 Source mainSource = uriResolver.resolveAbsolute(new Uri.file('/main.dart')); |
| 74 var initialLibrary = | 74 var initialLibrary = |
| 75 context.resolveCompilationUnit2(mainSource, mainSource); | 75 context.resolveCompilationUnit2(mainSource, mainSource); |
| 76 | 76 |
| 77 var collector = new _ErrorCollector(); | 77 var collector = new _ErrorCollector(); |
| 78 var checker = | 78 var checker = new CodeChecker( |
| 79 new CodeChecker(new TypeRules(context.typeProvider), collector); | 79 new TypeRules(context.typeProvider), collector, |
| 80 hints: true); |
| 80 | 81 |
| 81 // Extract expectations from the comments in the test files, and | 82 // Extract expectations from the comments in the test files, and |
| 82 // check that all errors we emit are included in the expected map. | 83 // check that all errors we emit are included in the expected map. |
| 83 var allLibraries = reachableLibraries(initialLibrary.element.library); | 84 var allLibraries = reachableLibraries(initialLibrary.element.library); |
| 84 for (var lib in allLibraries) { | 85 for (var lib in allLibraries) { |
| 85 for (var unit in lib.units) { | 86 for (var unit in lib.units) { |
| 86 var errors = <AnalysisError>[]; | 87 var errors = <AnalysisError>[]; |
| 87 collector.errors = errors; | 88 collector.errors = errors; |
| 88 | 89 |
| 89 var source = unit.source; | 90 var source = unit.source; |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 if (levelName == 'warning') return _MAGENTA_COLOR; | 491 if (levelName == 'warning') return _MAGENTA_COLOR; |
| 491 if (levelName == 'info') return _CYAN_COLOR; | 492 if (levelName == 'info') return _CYAN_COLOR; |
| 492 return null; | 493 return null; |
| 493 } | 494 } |
| 494 | 495 |
| 495 const String _RED_COLOR = '\u001b[31m'; | 496 const String _RED_COLOR = '\u001b[31m'; |
| 496 const String _MAGENTA_COLOR = '\u001b[35m'; | 497 const String _MAGENTA_COLOR = '\u001b[35m'; |
| 497 const String _CYAN_COLOR = '\u001b[36m'; | 498 const String _CYAN_COLOR = '\u001b[36m'; |
| 498 const String GREEN_COLOR = '\u001b[32m'; | 499 const String GREEN_COLOR = '\u001b[32m'; |
| 499 const String NO_COLOR = '\u001b[0m'; | 500 const String NO_COLOR = '\u001b[0m'; |
| OLD | NEW |