Commit d131a8df authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Fix --keep-app-running default and make devicelab verboser (#10957)

parent 845c1b7f
......@@ -152,7 +152,7 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
results.add(deviceID);
}
} else {
throw 'Failed to parse device from adb output: $line';
throw 'Failed to parse device from adb output: "$line"';
}
}
......@@ -259,6 +259,7 @@ class AndroidDevice implements Device {
Future<Map<String, dynamic>> getMemoryStats(String packageName) async {
final String meminfo = await shellEval('dumpsys', <String>['meminfo', packageName]);
final Match match = new RegExp(r'TOTAL\s+(\d+)').firstMatch(meminfo);
assert(match != null, 'could not parse dumpsys meminfo output');
return <String, dynamic>{
'total_kb': int.parse(match.group(1)),
};
......
......@@ -173,7 +173,7 @@ Future<Process> startProcess(
String workingDirectory,
}) async {
final String command = '$executable ${arguments?.join(" ") ?? ""}';
print('Executing: $command');
print('\nExecuting: $command');
environment ??= <String, String>{};
environment['BOT'] = 'true';
final Process process = await _processManager.start(
......@@ -184,8 +184,8 @@ Future<Process> startProcess(
final ProcessInfo processInfo = new ProcessInfo(command, process);
_runningProcesses.add(processInfo);
process.exitCode.whenComplete(() {
print('\n'); // separate the output of this script from subsequent output to make logs easier to read
process.exitCode.then((int exitCode) {
print('exitcode: $exitCode');
_runningProcesses.remove(processInfo);
});
......@@ -218,15 +218,22 @@ Future<int> exec(
}) async {
final Process process = await startProcess(executable, arguments, environment: environment);
final Completer<Null> stdoutDone = new Completer<Null>();
final Completer<Null> stderrDone = new Completer<Null>();
process.stdout
.transform(UTF8.decoder)
.transform(const LineSplitter())
.listen(print);
.listen((String line) {
print('stdout: $line');
}, onDone: () { stdoutDone.complete(); });
process.stderr
.transform(UTF8.decoder)
.transform(const LineSplitter())
.listen(stderr.writeln);
.listen((String line) {
print('stderr: $line');
}, onDone: () { stderrDone.complete(); });
await Future.wait<Null>(<Future<Null>>[stdoutDone.future, stderrDone.future]);
final int exitCode = await process.exitCode;
if (exitCode != 0 && !canFail)
......@@ -237,7 +244,7 @@ Future<int> exec(
/// Executes a command and returns its standard output as a String.
///
/// Standard error is redirected to the current process' standard error stream.
/// For logging purposes, the command's output is also printed out.
Future<String> eval(
String executable,
List<String> arguments, {
......@@ -245,16 +252,31 @@ Future<String> eval(
bool canFail: false,
}) async {
final Process process = await startProcess(executable, arguments, environment: environment);
process.stderr.listen((List<int> data) {
stderr.add(data);
});
final String output = await UTF8.decodeStream(process.stdout);
final StringBuffer output = new StringBuffer();
final Completer<Null> stdoutDone = new Completer<Null>();
final Completer<Null> stderrDone = new Completer<Null>();
process.stdout
.transform(UTF8.decoder)
.transform(const LineSplitter())
.listen((String line) {
print('stdout: $line');
output.writeln(line);
}, onDone: () { stdoutDone.complete(); });
process.stderr
.transform(UTF8.decoder)
.transform(const LineSplitter())
.listen((String line) {
print('stderr: $line');
}, onDone: () { stderrDone.complete(); });
await Future.wait<Null>(<Future<Null>>[stdoutDone.future, stderrDone.future]);
final int exitCode = await process.exitCode;
if (exitCode != 0 && !canFail)
fail('Executable failed with exit code $exitCode.');
return output.trimRight();
return output.toString().trimRight();
}
Future<int> flutter(String command, {
......
......@@ -41,6 +41,7 @@ class DriveCommand extends RunCommandBase {
DriveCommand() {
argParser.addFlag(
'keep-app-running',
defaultsTo: null,
negatable: true,
help:
'Will keep the Flutter application running when done testing.\n'
......
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