Fix race condition in readJsonResults (#100243)

This commit is contained in:
Emmanuel Garcia
2022-03-17 13:40:15 -07:00
committed by GitHub
parent 3c6b760e4c
commit 9072a09958
3 changed files with 29 additions and 3 deletions

View File

@@ -152,6 +152,14 @@ abstract class Device {
/// with some prefix.
Stream<String> get logcat;
/// Clears the device logs.
///
/// This is important because benchmarks tests rely on the logs produced by
/// the flutter run command.
///
/// On Android, those logs may contain logs from previous test.
Future<void> clearLogs();
/// Whether this device supports calls to [startLoggingToSink]
/// and [stopLoggingToSink].
bool get canStreamLogs => false;
@@ -667,6 +675,11 @@ class AndroidDevice extends Device {
}
}
@override
Future<void> clearLogs() {
return adb(<String>['logcat', '-c']);
}
@override
Stream<String> get logcat {
final Completer<void> stdoutDone = Completer<void>();
@@ -677,7 +690,7 @@ class AndroidDevice extends Device {
late final StreamController<String> stream;
stream = StreamController<String>(
onListen: () async {
await adb(<String>['logcat', '-c']);
await clearLogs();
final Process process = await startProcess(
adbPath,
// Make logcat less chatty by filtering down to just ActivityManager
@@ -971,6 +984,9 @@ class IosDevice extends Device {
throw UnimplementedError();
}
@override
Future<void> clearLogs() async {}
@override
Future<void> stop(String packageName) async {}
@@ -1007,6 +1023,9 @@ class WindowsDevice extends Device {
@override
Stream<String> get logcat => const Stream<String>.empty();
@override
Future<void> clearLogs() async {}
@override
Future<void> reboot() async { }
@@ -1074,6 +1093,9 @@ class FuchsiaDevice extends Device {
throw UnimplementedError();
}
@override
Future<void> clearLogs() async {}
@override
Future<void> reboot() async {
// Unsupported.
@@ -1142,6 +1164,9 @@ class FakeDevice extends Device {
throw UnimplementedError();
}
@override
Future<void> clearLogs() async {}
@override
Future<void> stop(String packageName) async {}