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

This flag will allow for Observatory to be served by the VM service once it is disabled by default in the Dart SDK.
This commit is contained in:
Ben Konyi
2023-01-25 12:46:08 -05:00
committed by GitHub
parent cd34fa6d4c
commit 6cd4fa45e2
16 changed files with 308 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);
},
);