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

Unified Diff: lib/src/runner/reporter/compact.dart

Issue 1083433002: More gracefully handle load errors. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 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 | « lib/src/runner/loader.dart ('k') | test/runner/browser/compiler_pool_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/runner/reporter/compact.dart
diff --git a/lib/src/runner/reporter/compact.dart b/lib/src/runner/reporter/compact.dart
index 9099a3d390f7f80eb3264eddf5b9f5c69f1cc530..6f686eac9d80d0682ba41e91da754d63b3708399 100644
--- a/lib/src/runner/reporter/compact.dart
+++ b/lib/src/runner/reporter/compact.dart
@@ -6,12 +6,14 @@ library test.runner.reporter.compact;
import 'dart:async';
import 'dart:io';
+import 'dart:isolate';
import '../../backend/live_test.dart';
import '../../backend/state.dart';
import '../../backend/suite.dart';
import '../../utils.dart';
import '../engine.dart';
+import '../load_exception.dart';
/// The maximum console line length.
///
@@ -21,6 +23,9 @@ const _lineLength = 100;
/// A reporter that prints test results to the console in a single
/// continuously-updating line.
class CompactReporter {
+ /// Whether the reporter should emit terminal color escapes.
+ final bool _color;
+
/// The terminal escape for green text, or the empty string if this is Windows
/// or not outputting to a terminal.
final String _green;
@@ -78,6 +83,7 @@ class CompactReporter {
_multiplePlatforms =
suites.map((suite) => suite.platform).toSet().length > 1,
_engine = new Engine(suites, concurrency: concurrency),
+ _color = color,
_green = color ? '\u001b[32m' : '',
_red = color ? '\u001b[31m' : '',
_noColor = color ? '\u001b[0m' : '' {
@@ -114,8 +120,21 @@ class CompactReporter {
if (!_printedNewline) print('');
_printedNewline = true;
- print(indent(error.error.toString()));
- print(indent(terseChain(error.stackTrace).toString()));
+ if (error.error is! LoadException) {
+ print(indent(error.error.toString()));
+ print(indent(terseChain(error.stackTrace).toString()));
+ return;
+ }
+
+ print(indent(error.error.toString(color: _color)));
+
+ // Only print stack traces for load errors that come from the user's code.
+ if (error.error.innerError is! IOException &&
+ error.error.innerError is! IsolateSpawnException &&
+ error.error.innerError is! FormatException &&
+ error.error.innerError is! String) {
+ print(indent(terseChain(error.stackTrace).toString()));
+ }
});
liveTest.onPrint.listen((line) {
« no previous file with comments | « lib/src/runner/loader.dart ('k') | test/runner/browser/compiler_pool_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698