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

Unified Diff: lib/src/dart.dart

Issue 941123002: Get all tests running via the test runner. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Created 5 years, 10 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 | « no previous file | lib/src/isolate_wrapper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/dart.dart
diff --git a/lib/src/dart.dart b/lib/src/dart.dart
index 5f4aea5fa09a3454a9bce8c7d0adfc3ee547b91a..e59b37f8f395eddf0762e4d6c7efcfb0bf559959 100644
--- a/lib/src/dart.dart
+++ b/lib/src/dart.dart
@@ -11,6 +11,7 @@ import 'dart:isolate';
import 'package:path/path.dart' as p;
import 'io.dart';
+import 'isolate_wrapper.dart';
import 'remote_exception.dart';
/// Runs [code] in an isolate.
@@ -24,23 +25,28 @@ import 'remote_exception.dart';
/// [String] or a [Uri].
Future<Isolate> runInIsolate(String code, message, {packageRoot}) {
// TODO(nweiz): load code from a local server rather than from a file.
- return withTempDir((dir) {
- var dartPath = p.join(dir, 'runInIsolate.dart');
- new File(dartPath).writeAsStringSync(code);
- var port = new ReceivePort();
- return Isolate.spawn(_isolateBuffer, {
- 'replyTo': port.sendPort,
- 'uri': p.toUri(dartPath).toString(),
- 'packageRoot': packageRoot == null ? null : packageRoot.toString(),
- 'message': message
- }).then((isolate) {
- return port.first.then((response) {
- if (response['type'] != 'error') return isolate;
- isolate.kill();
- var asyncError = RemoteException.deserialize(response['error']);
- return new Future.error(asyncError.error, asyncError.stackTrace);
- });
+ var dir = Directory.systemTemp.createTempSync().path;
+ var dartPath = p.join(dir, 'runInIsolate.dart');
+ new File(dartPath).writeAsStringSync(code);
+ var port = new ReceivePort();
+ return Isolate.spawn(_isolateBuffer, {
+ 'replyTo': port.sendPort,
+ 'uri': p.toUri(dartPath).toString(),
+ 'packageRoot': packageRoot == null ? null : packageRoot.toString(),
+ 'message': message
+ }).then((isolate) {
+ return port.first.then((response) {
+ if (response['type'] != 'error') return isolate;
+ isolate.kill();
+ var asyncError = RemoteException.deserialize(response['error']);
+ return new Future.error(asyncError.error, asyncError.stackTrace);
});
+ }).catchError((error) {
+ new Directory(dir).deleteSync(recursive: true);
+ throw error;
+ }).then((isolate) {
+ return new IsolateWrapper(isolate,
+ () => new Directory(dir).deleteSync(recursive: true));
});
}
« no previous file with comments | « no previous file | lib/src/isolate_wrapper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698