add verbose logging to select hot reload/hot restart tests (#147673)

In service of https://github.com/flutter/flutter/issues/146879 and https://github.com/flutter/flutter/issues/145812. In these issues, we see what appears to be the flutter tool getting stuck somewhere during hot reload. It may help if we knew were exactly where we are getting stuck (preparing assets, writing them to device, etc.).

This PR adds a new parameter to `FlutterTestDriver::run`, `verbose`. When verbose is set, `FlutterTestDriver` will run `flutter` with `--verbose` in its tests. Keep in mind that `FlutterTestDriver` only prints logs from `flutter` when a test fails, so this shouldn't spam the logs of passing tests.

This PR sets the parameter when invoking the flaky tests from https://github.com/flutter/flutter/issues/146879 and #145812, so we should see more detailed logs in future flakes.

While this is a low risk PR, you can verify the change by intentionally breaking hot reload code, clearing the cached tool binaries, and then running either of these tests.
This commit is contained in:
Andrew Kolos 2024-05-01 21:03:32 -07:00 committed by GitHub
parent bda9eef950
commit 13beab1ecc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 12 additions and 3 deletions

View File

@ -732,6 +732,7 @@ class DevFS {
return UpdateFSReport();
}
_logger.printTrace('Pending asset builds completed. Writing dirty entries.');
if (dirtyEntries.isNotEmpty) {
await (devFSWriter ?? _httpWriter).write(dirtyEntries, _baseUri!, _httpWriter);
}

View File

@ -573,6 +573,7 @@ class FlutterDevice {
}) async {
final Status devFSStatus = globals.logger.startProgress(
'Syncing files to device ${device!.name}...',
progressId: 'devFS.update',
);
UpdateFSReport report;
try {

View File

@ -81,7 +81,7 @@ void main() {
});
testWithoutContext('hot restart works without error', () async {
await flutter.run();
await flutter.run(verbose: true);
await flutter.hotRestart();
});

View File

@ -90,12 +90,13 @@ abstract class FlutterTestDriver {
List<String> arguments, {
String? script,
bool withDebugger = false,
bool verbose = false,
}) async {
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
if (withDebugger) {
arguments.add('--start-paused');
}
if (_printDebugOutputToStdOut) {
if (verbose || _printDebugOutputToStdOut) {
arguments.add('--verbose');
}
if (script != null) {
@ -509,6 +510,7 @@ class FlutterRunTestDriver extends FlutterTestDriver {
bool expressionEvaluation = true,
bool structuredErrors = false,
bool serveObservatory = false,
bool verbose = false,
String? script,
List<String>? additionalCommandArgs,
}) async {
@ -538,6 +540,7 @@ class FlutterRunTestDriver extends FlutterTestDriver {
startPaused: startPaused,
pauseOnExceptions: pauseOnExceptions,
script: script,
verbose: verbose,
);
}
@ -578,6 +581,7 @@ class FlutterRunTestDriver extends FlutterTestDriver {
bool withDebugger = false,
bool startPaused = false,
bool pauseOnExceptions = false,
bool verbose = false,
int? attachPort,
}) async {
assert(!startPaused || withDebugger);
@ -585,6 +589,7 @@ class FlutterRunTestDriver extends FlutterTestDriver {
args,
script: script,
withDebugger: withDebugger,
verbose: verbose,
);
final Completer<void> prematureExitGuard = Completer<void>();
@ -796,12 +801,14 @@ class FlutterTestTestDriver extends FlutterTestDriver {
String? script,
bool withDebugger = false,
bool pauseOnExceptions = false,
bool verbose = false,
Future<void> Function()? beforeStart,
}) async {
await super._setupProcess(
args,
script: script,
withDebugger: withDebugger,
verbose: verbose,
);
// Stash the PID so that we can terminate the VM more reliably than using

View File

@ -25,7 +25,7 @@ void main() {
await project.setUpIn(tempDir);
flutter = FlutterRunTestDriver(tempDir);
await flutter.run(withDebugger: true);
await flutter.run(withDebugger: true, verbose: true);
final int? port = flutter.vmServicePort;
expect(port != null, true);
vmService = await vmServiceConnectUri('ws://localhost:$port/ws');