Note when --enable-vmservice is required and skip otherwise. (#167579)

Our CI system runs with `--enable-vmservice`, but the default (i.e. for
`flutter test`) does not.

Closes https://github.com/flutter/flutter/issues/136079.
This commit is contained in:
Matan Lurey 2025-04-22 12:50:01 -07:00 committed by GitHub
parent 731d2d9e77
commit b94e21b439
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View File

@ -0,0 +1,17 @@
// Copyright 2014 The Flutter Authors. 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:developer' as developer;
import 'package:flutter_test/flutter_test.dart';
Future<bool> hasVmServiceEnabled() async {
final developer.ServiceProtocolInfo info = await developer.Service.getInfo();
final bool result = info.serverUri != null;
if (!result) {
// ignore: avoid_print
print('Run test suite with --enable-vmservice to enable this test.');
}
return result;
}

View File

@ -7,6 +7,8 @@ import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import '_requires_vm_service.dart';
class SocketExceptionHttpClient extends Fake implements HttpClient {
@override
Future<HttpClientRequest> openUrl(String method, Uri url) {
@ -29,5 +31,5 @@ Future<void> main() async {
fail('Did not expect a socket exception.');
}
expect(gotStateError, true);
});
}, skip: !(await hasVmServiceEnabled())); // [intended] avoid local failures
}