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

Unified Diff: lib/src/util/dart.dart

Issue 1290763003: Drop support for old SDK and shelf versions. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years, 4 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') | lib/src/util/io.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/util/dart.dart
diff --git a/lib/src/util/dart.dart b/lib/src/util/dart.dart
index d609f8915ab53cceee6c30db0bb0ec1605adc6eb..560241c5a77e26bd87d2c5550ffde040d6e65d5e 100644
--- a/lib/src/util/dart.dart
+++ b/lib/src/util/dart.dart
@@ -5,16 +5,12 @@
library test.util.dart;
import 'dart:async';
-import 'dart:io';
import 'dart:isolate';
import 'package:analyzer/analyzer.dart';
-import 'package:path/path.dart' as p;
import 'package:source_span/source_span.dart';
import 'string_literal_iterator.dart';
-import 'io.dart';
-import 'isolate_wrapper.dart';
/// Runs [code] in an isolate.
///
@@ -25,42 +21,16 @@ import 'isolate_wrapper.dart';
///
/// [packageRoot] controls the package root of the isolate. It may be either a
/// [String] or a [Uri].
-Future<IsolateWrapper> runInIsolate(String code, message, {packageRoot,
+Future<Isolate> runInIsolate(String code, message, {packageRoot,
bool checked}) async {
- // TODO(nweiz): load code from a local server rather than from a file.
- var dir = createTempDir();
- var dartPath = p.join(dir, 'runInIsolate.dart');
- new File(dartPath).writeAsStringSync(code);
-
- return await spawnUri(
- p.toUri(dartPath), message,
- packageRoot: packageRoot,
- checked: checked,
- onExit: () => new Directory(dir).deleteSync(recursive: true));
-}
-
-/// Like [Isolate.spawnUri], except that [uri] and [packageRoot] may be strings,
-/// [checked] mode is silently ignored on older Dart versions, and [onExit] is
-/// run after the isolate is killed.
-///
-/// If the isolate fails to load, [onExit] will also be run.
-Future<IsolateWrapper> spawnUri(uri, message, {packageRoot, bool checked,
- void onExit()}) async {
- if (uri is String) uri = Uri.parse(uri);
if (packageRoot is String) packageRoot = Uri.parse(packageRoot);
- if (onExit == null) onExit = () {};
- try {
- var isolate = supportsIsolateCheckedMode
- ? await Isolate.spawnUri(
- uri, [], message, checked: checked, packageRoot: packageRoot)
- : await Isolate.spawnUri(
- uri, [], message, packageRoot: packageRoot);
- return new IsolateWrapper(isolate, onExit);
- } catch (error) {
- onExit();
- rethrow;
- }
+ return await Isolate.spawnUri(
+ Uri.parse('data:application/dart;charset=utf-8,' + Uri.encodeFull(code)),
+ [],
+ message,
+ packageRoot: packageRoot,
+ checked: checked);
}
// TODO(nweiz): Move this into the analyzer once it starts using SourceSpan
« no previous file with comments | « lib/src/runner/loader.dart ('k') | lib/src/util/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698