Update flutter_tools to look for new VM service message (#97683)

* Update flutter_tools to look for new VM service message

The Dart SDK will soon move away from the current Observatory message:

"Observatory listening on ..."

To a new message that no longer references Observatory:

"Dart VM Service listening on ..."

This change updates all tests with mocks to check for the new message
and also adds support for the new message in ProtocolDiscovery.

See https://github.com/dart-lang/sdk/issues/46756

* Fix some parsing locations

* Fix analysis failures

* Update message

* Remove extra comment

* Update message

* Add globals prefix
This commit is contained in:
Ben Konyi
2022-02-15 07:33:57 -08:00
committed by GitHub
parent ee0bbf4789
commit 2a2f973120
18 changed files with 75 additions and 70 deletions

View File

@@ -281,3 +281,7 @@ PreRunValidator get preRunValidator => context.get<PreRunValidator>() ?? const N
// TODO(fujino): Migrate to 'main' https://github.com/flutter/flutter/issues/95041
const String kDefaultFrameworkChannel = 'master';
// Used to build RegExp instances which can detect the VM service message.
const String kServicePrefixRegExp = '(?:Observatory|The Dart VM service is)';
final RegExp kVMServiceMessageRegExp = RegExp(kServicePrefixRegExp + r' listening on ((http|//)[a-zA-Z0-9:/=_\-\.\[\]]+)');

View File

@@ -313,7 +313,7 @@ class IOSDeployDebugger {
// (lldb) run
// success
// 2020-09-15 13:42:25.185474-0700 Runner[477:181141] flutter: Observatory listening on http://127.0.0.1:57782/
// 2020-09-15 13:42:25.185474-0700 Runner[477:181141] flutter: The Dart VM service is listening on http://127.0.0.1:57782/
if (_lldbRun.hasMatch(line)) {
_logger.printTrace(line);
_debuggerState = _IOSDeployDebuggerState.launching;

View File

@@ -757,8 +757,8 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
}
// Match the log prefix (in order to shorten it):
// * Xcode 8: Sep 13 15:28:51 cbracken-macpro localhost Runner[37195]: (Flutter) Observatory listening on http://127.0.0.1:57701/
// * Xcode 9: 2017-09-13 15:26:57.228948-0700 localhost Runner[37195]: (Flutter) Observatory listening on http://127.0.0.1:57701/
// * Xcode 8: Sep 13 15:28:51 cbracken-macpro localhost Runner[37195]: (Flutter) The Dart VM service is listening on http://127.0.0.1:57701/
// * Xcode 9: 2017-09-13 15:26:57.228948-0700 localhost Runner[37195]: (Flutter) The Dart VM service is listening on http://127.0.0.1:57701/
static final RegExp _mapRegex = RegExp(r'\S+ +\S+ +(?:\S+) (.+?(?=\[))\[\d+\]\)?: (\(.*?\))? *(.*)$');
// Jan 31 19:23:28 --- last message repeated 1 time ---

View File

@@ -8,6 +8,7 @@ import 'base/io.dart';
import 'base/logger.dart';
import 'device.dart';
import 'device_port_forwarder.dart';
import 'globals.dart' as globals;
/// Discovers a specific service protocol on a device, and forwards the service
/// protocol device port to the host.
@@ -104,8 +105,7 @@ class ProtocolDiscovery {
}
Match? _getPatternMatch(String line) {
final RegExp r = RegExp(RegExp.escape(serviceName) + r' listening on ((http|//)[a-zA-Z0-9:/=_\-\.\[\]]+)');
return r.firstMatch(line);
return globals.kVMServiceMessageRegExp.firstMatch(line);
}
Uri? _getObservatoryUri(String line) {

View File

@@ -367,7 +367,7 @@ class FlutterDevice {
return;
}
_loggingSubscription = logStream.listen((String line) {
if (!line.contains('Observatory listening on http')) {
if (!line.contains(globals.kVMServiceMessageRegExp)) {
globals.printStatus(line, wrap: false);
}
});

View File

@@ -20,6 +20,7 @@ import '../base/os.dart';
import '../base/platform.dart';
import '../convert.dart';
import '../device.dart';
import '../globals.dart' as globals;
import '../project.dart';
import '../vmservice.dart';
@@ -294,7 +295,6 @@ class FlutterTesterTestDevice extends TestDevice {
@required Process process,
@required Future<void> Function(Uri uri) reportObservatoryUri,
}) {
const String observatoryString = 'Observatory listening on ';
for (final Stream<List<int>> stream in <Stream<List<int>>>[
process.stderr,
process.stdout,
@@ -306,9 +306,10 @@ class FlutterTesterTestDevice extends TestDevice {
(String line) async {
logger.printTrace('test $id: Shell: $line');
if (line.startsWith(observatoryString)) {
final Match match = globals.kVMServiceMessageRegExp.firstMatch(line);
if (match != null) {
try {
final Uri uri = Uri.parse(line.substring(observatoryString.length));
final Uri uri = Uri.parse(match[1]);
if (reportObservatoryUri != null) {
await reportObservatoryUri(uri);
}