Commit c9e7782a authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Add --record-to option to flutter tools (#7136)

* Add --record-to option to flutter tools

This option will cause flutter tools to record all process
invocations that occur and serialize their stdout and stderr
to files that get added to a "recording" ZIP file. This is
part of an effort to be able to test flutter tools in a hermetic
environment.

As a side-benefit, this recording should prove an excellent
attachment to any bug report.
parent 2563636d
...@@ -13,6 +13,7 @@ import '../android/android_sdk.dart'; ...@@ -13,6 +13,7 @@ import '../android/android_sdk.dart';
import '../base/context.dart'; import '../base/context.dart';
import '../base/logger.dart'; import '../base/logger.dart';
import '../base/process.dart'; import '../base/process.dart';
import '../base/process_manager.dart';
import '../cache.dart'; import '../cache.dart';
import '../dart/package_map.dart'; import '../dart/package_map.dart';
import '../device.dart'; import '../device.dart';
...@@ -93,6 +94,14 @@ class FlutterCommandRunner extends CommandRunner<Null> { ...@@ -93,6 +94,14 @@ class FlutterCommandRunner extends CommandRunner<Null> {
'Name of a build output within the engine out directory, if you are building Flutter locally.\n' 'Name of a build output within the engine out directory, if you are building Flutter locally.\n'
'Use this to select a specific version of the engine if you have built multiple engine targets.\n' 'Use this to select a specific version of the engine if you have built multiple engine targets.\n'
'This path is relative to --local-engine-src-path/out.'); 'This path is relative to --local-engine-src-path/out.');
argParser.addOption('record-to',
help:
'Enables recording of process invocations (including stdout and '
'stderr of all such invocations), and serializes that recording to '
'the specified location.\n'
'If the location is a directory, a ZIP file named `recording.zip` '
'will be created in that directory. Otherwise, a ZIP file will be '
'created with the path specified in this flag.');
} }
@override @override
...@@ -142,6 +151,19 @@ class FlutterCommandRunner extends CommandRunner<Null> { ...@@ -142,6 +151,19 @@ class FlutterCommandRunner extends CommandRunner<Null> {
context.setVariable(Logger, new VerboseLogger()); context.setVariable(Logger, new VerboseLogger());
} }
if (globalResults['record-to'] != null) {
// Turn on recording
String recordToPath = globalResults['record-to'].trim();
FileSystemEntity recordTo;
if (recordToPath.isNotEmpty) {
recordTo = await FileSystemEntity.isDirectory(recordToPath)
? new Directory(recordToPath)
: new File(recordToPath);
}
context.setVariable(ProcessManager,
new RecordingProcessManager(recordTo: recordTo));
}
logger.quiet = globalResults['quiet']; logger.quiet = globalResults['quiet'];
if (globalResults.wasParsed('color')) if (globalResults.wasParsed('color'))
......
...@@ -14,6 +14,7 @@ dependencies: ...@@ -14,6 +14,7 @@ dependencies:
crypto: '>=1.1.1 <3.0.0' crypto: '>=1.1.1 <3.0.0'
file: ^0.1.0 file: ^0.1.0
http: ^0.11.3 http: ^0.11.3
intl: '>=0.14.0 <0.15.0'
json_rpc_2: ^2.0.0 json_rpc_2: ^2.0.0
json_schema: 1.0.6 json_schema: 1.0.6
linter: ^0.1.21 linter: ^0.1.21
......
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