Commit d87f1981 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

devicelab benchmarks run on Windows (#8814)

* devicelab benchmarks run on Windows

* fix analyzer issue

* fix test

* fix pubspec
parent 4c91b6e7
......@@ -382,9 +382,9 @@ String get adbPath {
throw 'ANDROID_HOME environment variable missing. This variable must '
'point to the Android SDK directory containing platform-tools.';
final File adbPath = file(path.join(androidHome, 'platform-tools/adb'));
final String adbPath = path.join(androidHome, 'platform-tools/adb');
if (!adbPath.existsSync()) throw 'adb not found at: $adbPath';
if (!canRun(adbPath)) throw 'adb not found at: $adbPath';
return adbPath.absolute.path;
return path.absolute(adbPath);
}
......@@ -8,12 +8,14 @@ import 'dart:io';
import 'package:meta/meta.dart';
import 'package:path/path.dart' as path;
import 'package:process/process.dart';
import 'package:stack_trace/stack_trace.dart';
/// Virtual current working directory, which affect functions, such as [exec].
String cwd = Directory.current.path;
List<ProcessInfo> _runningProcesses = <ProcessInfo>[];
ProcessManager _processManager = new LocalProcessManager();
class ProcessInfo {
ProcessInfo(this.command, this.process);
......@@ -118,7 +120,7 @@ void section(String title) {
Future<String> getDartVersion() async {
// The Dart VM returns the version text to stderr.
final ProcessResult result = Process.runSync(dartBin, <String>['--version']);
final ProcessResult result = _processManager.runSync(<String>[dartBin, '--version']);
String version = result.stderr.trim();
// Convert:
......@@ -167,9 +169,8 @@ Future<Process> startProcess(
print('Executing: $command');
environment ??= <String, String>{};
environment['BOT'] = 'true';
final Process process = await Process.start(
executable,
arguments,
final Process process = await _processManager.start(
<String>[executable]..addAll(arguments),
environment: environment,
workingDirectory: workingDirectory ?? cwd,
);
......@@ -448,3 +449,5 @@ Future<int> findAvailablePort() async {
}
}
}
bool canRun(String path) => _processManager.canRun(path);
\ No newline at end of file
......@@ -11,6 +11,7 @@ dependencies:
args: ^0.13.4
meta: ^1.0.4
path: ^1.4.0
process: 2.0.1
stack_trace: ^1.4.0
vm_service_client: '0.2.2+4'
......
......@@ -5,18 +5,22 @@
import 'dart:async';
import 'dart:io';
import 'package:path/path.dart' as path;
import 'package:process/process.dart';
import 'package:test/test.dart';
void main() {
final ProcessManager processManager = new LocalProcessManager();
group('run.dart script', () {
Future<int> runScript(List<String> testNames) async {
final List<String> options = <String>['bin/run.dart'];
for (String testName in testNames) {
options..addAll(<String>['-t', testName]);
}
final ProcessResult scriptProcess = Process.runSync(
'../../bin/cache/dart-sdk/bin/dart',
options,
final String dart = path.absolute(path.join('..', '..', 'bin', 'cache', 'dart-sdk', 'bin', 'dart'));
final ProcessResult scriptProcess = processManager.runSync(
<String>[dart]..addAll(options)
);
return scriptProcess.exitCode;
}
......
......@@ -267,6 +267,7 @@ class AnsiTerminal {
static const int _ENOTTY = 25;
static const int _ENETRESET = 102;
static const int _ERROR_INVALID_PARAMETER = 87;
static const int _INVALID_HANDLE = 6;
/// Setting the line mode can throw for some terminals (with "Operation not
/// supported on socket"), but the error can be safely ignored.
......@@ -275,6 +276,7 @@ class AnsiTerminal {
_ENOTTY,
_ENETRESET,
_ERROR_INVALID_PARAMETER, // TODO(goderbauer): remove when https://github.com/dart-lang/sdk/issues/28599 is fixed
_INVALID_HANDLE,
];
bool supportsColor;
......@@ -284,6 +286,9 @@ class AnsiTerminal {
String clearScreen() => supportsColor ? _clear : '\n\n';
set singleCharMode(bool value) {
// TODO(goderbauer): instead of trying to set lineMode and then catching [_ENOTTY] or [_INVALID_HANDLE],
// we should check beforehand if stdin is connected to a terminal or not
// (requires https://github.com/dart-lang/sdk/issues/29083 to be resolved).
try {
stdin.lineMode = !value;
} on StdinException catch (error) {
......
......@@ -21,7 +21,7 @@ dependencies:
meta: ^1.0.4
mustache: ^0.2.5
package_config: '>=0.1.5 <2.0.0'
platform: 1.0.1
platform: 1.0.2
process: 2.0.1
stack_trace: ^1.4.0
usage: ^3.0.0+1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment