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

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

Issue 2775633002: Use ansi color in the dartanalyzer cli output. (Closed)
Patch Set: make tests more robust Created 3 years, 9 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/lib/src/options.dart ('k') | pkg/analyzer_cli/test/reporter_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_cli/test/driver_test.dart
diff --git a/pkg/analyzer_cli/test/driver_test.dart b/pkg/analyzer_cli/test/driver_test.dart
index 30cc93ac16f2f66587ac8c0748547e2bb3841231..d5ab1c1956aa41023096467bff92b50b924935b8 100644
--- a/pkg/analyzer_cli/test/driver_test.dart
+++ b/pkg/analyzer_cli/test/driver_test.dart
@@ -14,6 +14,7 @@ import 'package:analyzer/src/error/codes.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/services/lint.dart';
+import 'package:analyzer_cli/src/ansi.dart' as ansi;
import 'package:analyzer_cli/src/driver.dart';
import 'package:analyzer_cli/src/options.dart';
import 'package:cli_util/cli_util.dart' show getSdkDir;
@@ -30,6 +31,7 @@ main() {
/// Base setup.
_setUp() {
+ ansi.runningTests = true;
savedOutSink = outSink;
savedErrorSink = errorSink;
savedExitHandler = exitHandler;
@@ -45,6 +47,7 @@ main() {
errorSink = savedErrorSink;
exitCode = savedExitCode;
exitHandler = savedExitHandler;
+ ansi.runningTests = false;
}
setUp(() => _setUp());
@@ -176,8 +179,8 @@ main() {
test('generates lints', () async {
await runLinter();
- expect(outSink.toString(),
- contains('[lint] Name types using UpperCamelCase'));
+ expect(_bulletToDash(outSink),
+ contains('lint - Name types using UpperCamelCase'));
});
});
@@ -202,8 +205,8 @@ main() {
test('generates lints', () async {
await runLinter();
- expect(outSink.toString(),
- contains('[lint] Name types using UpperCamelCase'));
+ expect(_bulletToDash(outSink),
+ contains('lint - Name types using UpperCamelCase'));
});
});
@@ -287,9 +290,9 @@ linter:
]);
expect(processorFor(missing_return).severity, ErrorSeverity.ERROR);
expect(
- outSink.toString(),
+ _bulletToDash(outSink),
contains(
- "[error] This function declares a return type of 'int'"));
+ "error - This function declares a return type of 'int'"));
expect(
outSink.toString(), contains("1 error and 1 warning found."));
});
@@ -327,8 +330,8 @@ linter:
expect(processorFor(undefined_function).severity,
ErrorSeverity.WARNING);
// Should not be made fatal by `--fatal-warnings`.
- expect(outSink.toString(),
- contains("[warning] The function 'baz' isn't defined"));
+ expect(_bulletToDash(outSink),
+ contains("warning - The function 'baz' isn't defined"));
expect(
outSink.toString(), contains("1 error and 1 warning found."));
});
@@ -568,3 +571,6 @@ class TestSource implements Source {
@override
noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}
+
+/// Normalize text with bullets.
+String _bulletToDash(item) => '$item'.replaceAll('•', '-');
« no previous file with comments | « pkg/analyzer_cli/lib/src/options.dart ('k') | pkg/analyzer_cli/test/reporter_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698