[flutter_tools] provide --timeout option to flutter drive (#114458)

This commit is contained in:
Christopher Fujino
2022-11-02 11:43:42 -07:00
committed by GitHub
parent 3b0f8335ee
commit 0211df9cfc
5 changed files with 152 additions and 17 deletions

View File

@@ -17,7 +17,14 @@ Future<void> main() async {
final Directory galleryDir = Directory(path.join(galleryParentDir.path, 'gallery'));
try {
await task(NewGalleryPerfTest(galleryDir).run);
await task(
NewGalleryPerfTest(
galleryDir,
// time out after 20 minutes allowing the tool to take a screenshot to debug
// https://github.com/flutter/flutter/issues/114025.
timeoutSeconds: 20 * 60,
).run,
);
} finally {
rmTree(galleryParentDir);
}

View File

@@ -15,6 +15,7 @@ class NewGalleryPerfTest extends PerfTest {
String timelineFileName = 'transitions',
String dartDefine = '',
bool enableImpeller = false,
super.timeoutSeconds,
}) : super(
galleryDir.path,
'test_driver/transitions_perf.dart',

View File

@@ -914,6 +914,7 @@ class PerfTest {
this.device,
this.flutterDriveCallback,
this.enableImpeller = false,
this.timeoutSeconds,
}): _resultFilename = resultFilename;
const PerfTest.e2e(
@@ -929,6 +930,7 @@ class PerfTest {
this.device,
this.flutterDriveCallback,
this.enableImpeller = false,
this.timeoutSeconds,
}) : saveTraceFile = false, timelineFileName = null, _resultFilename = resultFilename;
/// The directory where the app under test is defined.
@@ -963,6 +965,9 @@ class PerfTest {
/// Whether the perf test should enable Impeller.
final bool enableImpeller;
/// Number of seconds to time out the test after, allowing debug callbacks to run.
final int? timeoutSeconds;
/// The keys of the values that need to be reported.
///
/// If it's `null`, then report:
@@ -1020,6 +1025,11 @@ class PerfTest {
'-v',
'--verbose-system-logs',
'--profile',
if (timeoutSeconds != null)
...<String>[
'--timeout',
timeoutSeconds.toString(),
],
if (needsFullTimeline)
'--trace-startup', // Enables "endless" timeline event buffering.
'-t', testTarget,
@@ -1039,7 +1049,7 @@ class PerfTest {
if (flutterDriveCallback != null) {
flutterDriveCallback!(options);
} else {
await flutter('drive', options:options);
await flutter('drive', options: options);
}
final Map<String, dynamic> data = json.decode(
file('${_testOutputDirectory(testDirectory)}/$resultFilename.json').readAsStringSync(),
@@ -1140,7 +1150,7 @@ class PerfTestWithSkSL extends PerfTest {
);
@override
Future<TaskResult> run() async {
Future<TaskResult> run({int? timeoutSeconds}) async {
return inDirectory<TaskResult>(testDirectory, () async {
// Some initializations
_device = await devices.workingDevice;