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

Unified Diff: lib/src/runner/load_exception.dart

Issue 1172213002: Improve the capture and display of syntax errors in VM tests. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years, 6 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 | « CHANGELOG.md ('k') | lib/src/runner/vm/isolate_listener.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/runner/load_exception.dart
diff --git a/lib/src/runner/load_exception.dart b/lib/src/runner/load_exception.dart
index 06068ca4cd0188a395aa14174ac043603ca97783..dc740c3dbdef7b46ecec678b5bdf3fdea3bf6e2a 100644
--- a/lib/src/runner/load_exception.dart
+++ b/lib/src/runner/load_exception.dart
@@ -11,6 +11,11 @@ import 'package:source_span/source_span.dart';
import '../utils.dart';
+/// A regular expression for matching filename annotations in
+/// [IsolateSpawnException] messages.
+final _isolateFileRegExp =
+ new RegExp(r"^'(file:/[^']+)': (error|warning): ", multiLine: true);
+
class LoadException implements Exception {
final String path;
@@ -26,9 +31,11 @@ class LoadException implements Exception {
var innerString = getErrorMessage(innerError);
if (innerError is IsolateSpawnException) {
- // If this is a parse error, get rid of the noisy preamble.
- innerString = innerString
- .replaceFirst("'${p.toUri(p.absolute(path))}': error: ", "");
+ // If this is a parse error, clean up the noisy filename annotations.
+ innerString = innerString.replaceAllMapped(_isolateFileRegExp, (match) {
+ if (p.fromUri(match[1]) == p.absolute(path)) return "";
+ return "${p.prettyUri(match[1])}: ";
+ });
// If this is a file system error, get rid of both the preamble and the
// useless stack trace.
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/runner/vm/isolate_listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698