96cf91bea3
Also updated non-migrated libraries to include @dart=2.10. Change-Id: Idcf4e54f9aa37b9b016133144af594cc932418a0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192122 Reviewed-by: Gary Roumanis <grouma@google.com>
44 lines
1.4 KiB
Dart
44 lines
1.4 KiB
Dart
// Copyright (c) 2020, 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.
|
|
|
|
// @dart=2.10
|
|
|
|
import 'dart:convert';
|
|
import 'dart:io';
|
|
|
|
Uri remoteVmServiceUri;
|
|
|
|
Future<Process> spawnDartProcess(
|
|
String script, {
|
|
bool pauseOnStart = true,
|
|
}) async {
|
|
final executable = Platform.executable;
|
|
final tmpDir = await Directory.systemTemp.createTemp('dart_service');
|
|
final serviceInfoUri = tmpDir.uri.resolve('service_info.json');
|
|
final serviceInfoFile = await File.fromUri(serviceInfoUri).create();
|
|
|
|
final arguments = [
|
|
'--disable-dart-dev',
|
|
'--observe=0',
|
|
if (pauseOnStart) '--pause-isolates-on-start',
|
|
'--write-service-info=$serviceInfoUri',
|
|
...Platform.executableArguments,
|
|
Platform.script.resolve(script).toString(),
|
|
];
|
|
final process = await Process.start(executable, arguments);
|
|
process.stdout
|
|
.transform(utf8.decoder)
|
|
.listen((line) => print('TESTEE OUT: $line'));
|
|
process.stderr
|
|
.transform(utf8.decoder)
|
|
.listen((line) => print('TESTEE ERR: $line'));
|
|
while ((await serviceInfoFile.length()) <= 5) {
|
|
await Future.delayed(const Duration(milliseconds: 50));
|
|
}
|
|
final content = await serviceInfoFile.readAsString();
|
|
final infoJson = json.decode(content);
|
|
remoteVmServiceUri = Uri.parse(infoJson['uri']);
|
|
return process;
|
|
}
|