[ Gardening ] Fix pkg/vm_service/test/get_supported_protocols_with_dds on AOT

Fixes https://github.com/dart-lang/sdk/issues/54835

Change-Id: I1dc0c585214e8001dfb6f2f0d8f3f07252bf56f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350660
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
This commit is contained in:
Ben Konyi 2024-02-06 17:23:32 +00:00 committed by Commit Queue
parent 6d4204e3f5
commit f4b1d59461
2 changed files with 25 additions and 6 deletions

View file

@ -7,10 +7,22 @@ import 'package:vm_service/vm_service.dart';
import 'common/test_helper.dart';
VMTest expectedProtocolTest(List<String> expectedProtocols) =>
/// [expectMissingProtocol] allows for a single protocol to be missing. See
/// https://github.com/dart-lang/sdk/issues/54835 for context. This test will
/// fail without this flag on AOT configurations when DDS is expected since DDS
/// isn't currently setup to run with dart_precompiled_runtime. This flag is
/// meant to cause this test to fail if
/// https://github.com/dart-lang/sdk/issues/54841 is resolved so this test can
/// be updated.
VMTest expectedProtocolTest(
List<String> expectedProtocols, {
bool expectMissingProtocol = false,
}) =>
(VmService service) async {
final protocols = (await service.getSupportedProtocols()).protocols!;
expect(protocols.length, expectedProtocols.length);
final expectedLength =
expectedProtocols.length - (expectMissingProtocol ? 1 : 0);
expect(protocols.length, expectedLength);
for (final protocol in protocols) {
expect(expectedProtocols.contains(protocol.protocolName), true);
expect(protocol.minor, greaterThan(0));

View file

@ -2,14 +2,21 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:io';
import 'common/test_helper.dart';
import 'get_supported_protocols_common.dart';
final tests = <VMTest>[
expectedProtocolTest(<String>[
'VM Service',
'DDS',
]),
expectedProtocolTest(
<String>[
'VM Service',
'DDS',
],
// See https://github.com/dart-lang/sdk/issues/54841
expectMissingProtocol:
Platform.script.toString().endsWith('out.aotsnapshot'),
),
];
void main([args = const <String>[]]) => runVMTests(