Reland "Add --serve-observatory flag to run, attach, and test (#118402)" (#119529)

* Reland "Add --serve-observatory flag to run, attach, and test (#118402)"

This reverts commit 86ab01d2bd.

* Fix flaky failures

* Fix VM service disappearing failure
This commit is contained in:
Ben Konyi
2023-01-30 16:00:18 -05:00
committed by GitHub
parent 92df6b4bc0
commit 7477d7ac79
16 changed files with 312 additions and 20 deletions

View File

@@ -11,6 +11,7 @@ import 'package:dds/dds.dart';
import 'package:meta/meta.dart';
import 'package:process/process.dart';
import 'package:stream_channel/stream_channel.dart';
import 'package:vm_service/vm_service.dart' as vm_service;
import '../base/file_system.dart';
import '../base/io.dart';
@@ -180,8 +181,15 @@ class FlutterTesterTestDevice extends TestDevice {
compileExpression: compileExpression,
logger: logger,
);
unawaited(localVmService.then((FlutterVmService vmservice) {
unawaited(localVmService.then((FlutterVmService vmservice) async {
logger.printTrace('test $id: Successfully connected to service protocol: $forwardingUri');
if (debuggingOptions.serveObservatory) {
try {
await vmservice.callMethodWrapper('_serveObservatory');
} on vm_service.RPCError {
logger.printWarning('Unable to enable Observatory');
}
}
}));
if (debuggingOptions.startPaused && !machine!) {
@@ -190,6 +198,7 @@ class FlutterTesterTestDevice extends TestDevice {
logger.printStatus(' $forwardingUri');
logger.printStatus('You should first set appropriate breakpoints, then resume the test in the debugger.');
}
_gotProcessObservatoryUri.complete(forwardingUri);
},
);