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

Unified Diff: pkg/analyzer_cli/test/reporter_test.dart

Issue 2793813002: Fix an issue with duplicate reported analysis errors. (Closed)
Patch Set: Merge branch 'master' into fix_duplicate_errors Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer_cli/test/errors_reported_once_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_cli/test/reporter_test.dart
diff --git a/pkg/analyzer_cli/test/reporter_test.dart b/pkg/analyzer_cli/test/reporter_test.dart
index 358b570587ad3f24c9479635e5477e9f8b52c5b4..1ffb2694e634ec49bd6e346106a28bf17b5761f5 100644
--- a/pkg/analyzer_cli/test/reporter_test.dart
+++ b/pkg/analyzer_cli/test/reporter_test.dart
@@ -5,6 +5,7 @@
library analyzer_cli.test.formatter;
import 'package:analyzer/analyzer.dart';
+import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer_cli/src/ansi.dart' as ansi;
import 'package:analyzer_cli/src/error_formatter.dart';
import 'package:test/test.dart' hide ErrorFormatter;
@@ -14,48 +15,54 @@ import 'mocks.dart';
main() {
group('reporter', () {
- var out = new StringBuffer();
- var stats = new AnalysisStats();
+ StringBuffer out;
+ AnalysisStats stats;
+ MockCommandLineOptions options;
+ ErrorFormatter reporter;
setUp(() {
ansi.runningTests = true;
- stats.init();
+
+ out = new StringBuffer();
+ stats = new AnalysisStats();
+
+ options = new MockCommandLineOptions();
+ when(options.enableTypeChecks).thenReturn(false);
+ when(options.hintsAreFatal).thenReturn(false);
+ when(options.machineFormat).thenReturn(false);
+ when(options.verbose).thenReturn(false);
+ when(options.color).thenReturn(false);
+
+ reporter = new HumanErrorFormatter(out, options, stats);
});
tearDown(() {
- out.clear();
ansi.runningTests = false;
});
- // Options
- var options = new MockCommandLineOptions();
- when(options.enableTypeChecks).thenReturn(false);
- when(options.hintsAreFatal).thenReturn(false);
- when(options.machineFormat).thenReturn(false);
- when(options.verbose).thenReturn(false);
- when(options.color).thenReturn(false);
-
- var reporter = new ErrorFormatter(out, options, stats);
-
test('error', () {
- var error = mockError(ErrorType.SYNTACTIC_ERROR, ErrorSeverity.ERROR);
+ AnalysisErrorInfo error =
+ mockError(ErrorType.SYNTACTIC_ERROR, ErrorSeverity.ERROR);
reporter.formatErrors([error]);
+ reporter.flush();
expect(out.toString().trim(),
'error • MSG at /foo/bar/baz.dart:3:3 • mock_code');
});
test('hint', () {
- var error = mockError(ErrorType.HINT, ErrorSeverity.INFO);
+ AnalysisErrorInfo error = mockError(ErrorType.HINT, ErrorSeverity.INFO);
reporter.formatErrors([error]);
+ reporter.flush();
expect(out.toString().trim(),
'hint • MSG at /foo/bar/baz.dart:3:3 • mock_code');
});
test('stats', () {
- var error = mockError(ErrorType.HINT, ErrorSeverity.INFO);
+ AnalysisErrorInfo error = mockError(ErrorType.HINT, ErrorSeverity.INFO);
reporter.formatErrors([error]);
+ reporter.flush();
stats.print(out);
expect(
out.toString().trim(),
@@ -83,6 +90,7 @@ MockAnalysisErrorInfo mockError(ErrorType type, ErrorSeverity severity) {
when(code.name).thenReturn('mock_code');
when(error.errorCode).thenReturn(code);
when(error.message).thenReturn('MSG');
+ when(error.offset).thenReturn(20);
var source = new MockSource();
when(source.fullName).thenReturn('/foo/bar/baz.dart');
when(error.source).thenReturn(source);
« no previous file with comments | « pkg/analyzer_cli/test/errors_reported_once_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698