Skip to content

Commit

Permalink
add verbose logging to select hot reload/hot restart tests (#147673)
Browse files Browse the repository at this point in the history
In service of flutter/flutter#146879 and flutter/flutter#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 flutter/flutter#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.
  • Loading branch information
andrewkolos authored May 2, 2024
1 parent bda9eef commit 13beab1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/flutter_tools/lib/src/devfs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions packages/flutter_tools/lib/src/resident_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void main() {
});

testWithoutContext('hot restart works without error', () async {
await flutter.run();
await flutter.run(verbose: true);
await flutter.hotRestart();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -538,6 +540,7 @@ class FlutterRunTestDriver extends FlutterTestDriver {
startPaused: startPaused,
pauseOnExceptions: pauseOnExceptions,
script: script,
verbose: verbose,
);
}

Expand Down Expand Up @@ -578,13 +581,15 @@ class FlutterRunTestDriver extends FlutterTestDriver {
bool withDebugger = false,
bool startPaused = false,
bool pauseOnExceptions = false,
bool verbose = false,
int? attachPort,
}) async {
assert(!startPaused || withDebugger);
await super._setupProcess(
args,
script: script,
withDebugger: withDebugger,
verbose: verbose,
);

final Completer<void> prematureExitGuard = Completer<void>();
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 13beab1

Please sign in to comment.