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

Unified Diff: lib/src/runner/vm/isolate_listener.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 | « lib/src/runner/load_exception.dart ('k') | test/runner/runner_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/runner/vm/isolate_listener.dart
diff --git a/lib/src/runner/vm/isolate_listener.dart b/lib/src/runner/vm/isolate_listener.dart
index 9b83af30f311876eb0b7813b4a6176455eb8ed67..bb3429114df0c00db248799d61feca6916815b18 100644
--- a/lib/src/runner/vm/isolate_listener.dart
+++ b/lib/src/runner/vm/isolate_listener.dart
@@ -7,6 +7,8 @@ library test.runner.vm.isolate_listener;
import 'dart:isolate';
import 'dart:async';
+import 'package:stack_trace/stack_trace.dart';
+
import '../../backend/declarer.dart';
import '../../backend/metadata.dart';
import '../../backend/suite.dart';
@@ -34,6 +36,24 @@ class IsolateListener {
/// [metadata] is the suite-level metadata defined at the top of the file.
static Future start(SendPort sendPort, Metadata metadata, Function getMain())
async {
+ // Capture any top-level errors (mostly lazy syntax errors, since other are
+ // caught below) and report them to the parent isolate. We set errors
+ // non-fatal because otherwise they'll be double-printed.
+ var errorPort = new ReceivePort();
+ Isolate.current.setErrorsFatal(false);
+ Isolate.current.addErrorListener(errorPort.sendPort);
+ errorPort.listen((message) {
+ // Masquerade as an IsoalteSpawnException because that's what this would
+ // be if the error had been detected statically.
+ var error = new IsolateSpawnException(message[0]);
+ var stackTrace =
+ message[1] == null ? new Trace([]) : new Trace.parse(message[1]);
+ sendPort.send({
+ "type": "error",
+ "error": RemoteException.serialize(error, stackTrace)
+ });
+ });
+
var main;
try {
main = getMain();
« no previous file with comments | « lib/src/runner/load_exception.dart ('k') | test/runner/runner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698