Skip to content
Snippets Groups Projects
Unverified Commit 600dd0c4 authored by Nate Bosch's avatar Nate Bosch Committed by GitHub
Browse files

Remove special handling for errors during parse (#985)

This is a holdback from Dart 1 where some syntax or type errors were not
reported until runtime.
parent c0470b54
No related branches found
No related tags found
No related merge requests found
...@@ -7,13 +7,9 @@ import "dart:isolate"; ...@@ -7,13 +7,9 @@ import "dart:isolate";
import "package:stream_channel/stream_channel.dart"; import "package:stream_channel/stream_channel.dart";
import "package:test_core/src/runner/plugin/remote_platform_helpers.dart"; import "package:test_core/src/runner/plugin/remote_platform_helpers.dart";
import "package:test_core/src/runner/vm/catch_isolate_errors.dart";
/// Bootstraps a vm test to communicate with the test runner. /// Bootstraps a vm test to communicate with the test runner.
void internalBootstrapVmTest(Function getMain(), SendPort sendPort) { void internalBootstrapVmTest(Function getMain(), SendPort sendPort) {
var channel = serializeSuite(() { var channel = serializeSuite(getMain);
catchIsolateErrors();
return getMain();
});
IsolateChannel.connectSend(sendPort).pipe(channel); IsolateChannel.connectSend(sendPort).pipe(channel);
} }
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import 'dart:isolate';
import 'package:stack_trace/stack_trace.dart';
/// Capture any top-level errors (mostly lazy syntax errors, since other are
/// caught below) and report them to the parent isolate.
void catchIsolateErrors() {
var errorPort = ReceivePort();
// Treat errors non-fatal because otherwise they'll be double-printed.
Isolate.current.setErrorsFatal(false);
Isolate.current.addErrorListener(errorPort.sendPort);
errorPort.listen((message) {
// Masquerade as an IsolateSpawnException because that's what this would
// be if the error had been detected statically.
var error = IsolateSpawnException(message[0] as String);
var stackTrace =
message[1] == null ? Trace([]) : Trace.parse(message[1] as String);
Zone.current.handleUncaughtError(error, stackTrace);
});
}
...@@ -115,15 +115,11 @@ Future<Isolate> _spawnDataIsolate(String path, SendPort message) async { ...@@ -115,15 +115,11 @@ Future<Isolate> _spawnDataIsolate(String path, SendPort message) async {
import "package:stream_channel/stream_channel.dart"; import "package:stream_channel/stream_channel.dart";
import "package:test_core/src/runner/plugin/remote_platform_helpers.dart"; import "package:test_core/src/runner/plugin/remote_platform_helpers.dart";
import "package:test_core/src/runner/vm/catch_isolate_errors.dart";
import "${p.toUri(p.absolute(path))}" as test; import "${p.toUri(p.absolute(path))}" as test;
void main(_, SendPort message) { void main(_, SendPort message) {
var channel = serializeSuite(() { var channel = serializeSuite(() => test.main);
catchIsolateErrors();
return test.main;
});
new IsolateChannel.connectSend(message).pipe(channel); new IsolateChannel.connectSend(message).pipe(channel);
} }
''', message, checked: true); ''', message, checked: true);
......
name: test_core name: test_core
version: 0.2.1+1 version: 0.2.2-dev
author: Dart Team <misc@dartlang.org> author: Dart Team <misc@dartlang.org>
description: A basic library for writing tests and running them on the VM. description: A basic library for writing tests and running them on the VM.
homepage: https://github.com/dart-lang/test/blob/master/pkgs/test_core homepage: https://github.com/dart-lang/test/blob/master/pkgs/test_core
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment