Unverified Commit f8c9e1bb authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] de-flake integration tests (#60221)

The vm_service_integration test flake is caused by trying to call the method before the framework is initialized (and the extension added). The run errors failure is caused by the error taking some time to propagate to the harness
parent c36c4293
......@@ -31,10 +31,27 @@ void main() {
test('flutter run reports an early error in an application', () async {
final StringBuffer stdout = StringBuffer();
_flutter.stdout.listen(stdout.writeln);
await _flutter.run(startPaused: true, withDebugger: true, structuredErrors: true);
await _flutter.resume();
final Completer<void> completer = Completer<void>();
bool lineFound = false;
await Future<void>(() async {
_flutter.stdout.listen((String line) {
stdout.writeln(line);
if (line.startsWith('Another exception was thrown') && !lineFound) {
lineFound = true;
completer.complete();
}
});
await completer.future;
}).timeout(const Duration(seconds: 15), onTimeout: () {
// Complete anyway in case we don't see the 'Another exception' line.
completer.complete();
});
await _flutter.stop();
expect(stdout.toString(), contains(_exceptionStart));
......
......@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'dart:io'; // ignore: dart_io_import
import 'package:file/file.dart';
......@@ -89,7 +90,7 @@ void main() {
});
test('ext.flutter.brightnessOverride can toggle window brightness', () async {
final IsolateRef isolate = (await vmService.getVM()).isolates.first;
final Isolate isolate = await waitForExtension(vmService);
final Response response = await vmService.callServiceExtension(
'ext.flutter.brightnessOverride',
isolateId: isolate.id,
......@@ -129,3 +130,20 @@ void main() {
// TODO(devoncarew): These tests fail on cirrus-ci windows.
}, skip: Platform.isWindows);
}
Future<Isolate> waitForExtension(VmService vmService) async {
final Completer<void> completer = Completer<void>();
await vmService.streamListen(EventStreams.kExtension);
vmService.onExtensionEvent.listen((Event event) {
if (event.json['extensionKind'] == 'Flutter.FrameworkInitialization') {
completer.complete();
}
});
final IsolateRef isolateRef = (await vmService.getVM()).isolates.first;
final Isolate isolate = await vmService.getIsolate(isolateRef.id);
if (isolate.extensionRPCs.contains('ext.flutter.brightnessOverride')) {
return isolate;
}
await completer.future;
return isolate;
}
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