mirror of
https://github.com/dart-lang/sdk
synced 2024-10-01 18:59:48 +00:00
Revert "[ Service ] Start DDS and serve DevTools when the VM service is started via dart:developer"
This reverts commit 64d4689a78
.
Reason for revert: Platform.executable doesn't return a path, just an executable name, which can cause breakages.
TEST=ci
Original change's description:
> [ Service ] Start DDS and serve DevTools when the VM service is started via dart:developer
>
> TEST=pkg/dds/test/control_web_server_starts_dds_test.dart
>
> Change-Id: I2e51783592912e5a719685f2ab5e7537b7a59586
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366560
> Commit-Queue: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Derek Xu <derekx@google.com>
Change-Id: I4ceaee4b5ca8f5557e90cd914ee69fe9aa5f85a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373381
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
This commit is contained in:
parent
7d22d99b9b
commit
4b88698e48
|
@ -1,51 +0,0 @@
|
||||||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
|
|
||||||
// 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:convert';
|
|
||||||
import 'dart:developer';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:test/test.dart';
|
|
||||||
import 'package:vm_service/vm_service.dart';
|
|
||||||
import 'package:vm_service/vm_service_io.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
HttpClient? client;
|
|
||||||
VmService? service;
|
|
||||||
|
|
||||||
tearDown(() async {
|
|
||||||
client?.close();
|
|
||||||
await service?.dispose();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Enabling the VM service starts DDS and serves DevTools', () async {
|
|
||||||
var serviceInfo = await Service.getInfo();
|
|
||||||
expect(serviceInfo.serverUri, isNull);
|
|
||||||
|
|
||||||
serviceInfo = await Service.controlWebServer(
|
|
||||||
enable: true,
|
|
||||||
silenceOutput: true,
|
|
||||||
);
|
|
||||||
expect(serviceInfo.serverUri, isNotNull);
|
|
||||||
final serverWebSocketUri = serviceInfo.serverWebSocketUri!;
|
|
||||||
service = await vmServiceConnectUri(
|
|
||||||
serverWebSocketUri.toString(),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check that DDS has been launched.
|
|
||||||
final supportedProtocols =
|
|
||||||
(await service!.getSupportedProtocols()).protocols!;
|
|
||||||
expect(supportedProtocols.length, 2);
|
|
||||||
expect(supportedProtocols.map((e) => e.protocolName), contains('DDS'));
|
|
||||||
|
|
||||||
// Check that DevTools assets are accessible.
|
|
||||||
client = HttpClient();
|
|
||||||
final devtoolsRequest = await client!.getUrl(serviceInfo.serverUri!);
|
|
||||||
final devtoolsResponse = await devtoolsRequest.close();
|
|
||||||
expect(devtoolsResponse.statusCode, 200);
|
|
||||||
final devtoolsContent =
|
|
||||||
await devtoolsResponse.transform(utf8.decoder).join();
|
|
||||||
expect(devtoolsContent, startsWith('<!DOCTYPE html>'));
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -15,7 +15,7 @@ Uri? wsServerUri;
|
||||||
|
|
||||||
Future<Null> testeeBefore() async {
|
Future<Null> testeeBefore() async {
|
||||||
print('testee before');
|
print('testee before');
|
||||||
// First grab the URL where the VM service is listening and the
|
// First grab the URL where the observatory is listening on and the
|
||||||
// service protocol version numbers. We expect the URL to be null as
|
// service protocol version numbers. We expect the URL to be null as
|
||||||
// the server has not been started yet.
|
// the server has not been started yet.
|
||||||
ServiceProtocolInfo info = await Service.getInfo();
|
ServiceProtocolInfo info = await Service.getInfo();
|
||||||
|
|
|
@ -96,7 +96,7 @@ class _DebuggingSession {
|
||||||
bool disableServiceAuthCodes,
|
bool disableServiceAuthCodes,
|
||||||
bool enableDevTools,
|
bool enableDevTools,
|
||||||
) async {
|
) async {
|
||||||
final dartDir = File(Platform.executable).parent.path;
|
final dartDir = File(Platform.resolvedExecutable).parent.path;
|
||||||
final executable = [
|
final executable = [
|
||||||
dartDir,
|
dartDir,
|
||||||
'dart${Platform.isWindows ? '.exe' : ''}',
|
'dart${Platform.isWindows ? '.exe' : ''}',
|
||||||
|
@ -133,7 +133,7 @@ class _DebuggingSession {
|
||||||
// is changed to ensure consistency.
|
// is changed to ensure consistency.
|
||||||
const devToolsMessagePrefix =
|
const devToolsMessagePrefix =
|
||||||
'The Dart DevTools debugger and profiler is available at:';
|
'The Dart DevTools debugger and profiler is available at:';
|
||||||
serverPrint('$devToolsMessagePrefix $devToolsUri');
|
print('$devToolsMessagePrefix $devToolsUri');
|
||||||
}
|
}
|
||||||
if (result
|
if (result
|
||||||
case {
|
case {
|
||||||
|
@ -141,7 +141,7 @@ class _DebuggingSession {
|
||||||
'uri': String dtdUri,
|
'uri': String dtdUri,
|
||||||
}
|
}
|
||||||
} when _printDtd) {
|
} when _printDtd) {
|
||||||
serverPrint('The Dart Tooling Daemon (DTD) is available at: $dtdUri');
|
print('The Dart Tooling Daemon (DTD) is available at: $dtdUri');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printError(result['error'] ?? result);
|
printError(result['error'] ?? result);
|
||||||
|
@ -308,37 +308,18 @@ Future<List<Map<String, dynamic>>> listFilesCallback(Uri dirPath) async {
|
||||||
|
|
||||||
Uri? serverInformationCallback() => _lazyServerBoot().serverAddress;
|
Uri? serverInformationCallback() => _lazyServerBoot().serverAddress;
|
||||||
|
|
||||||
Future<void> _toggleWebServer(Server server) async {
|
|
||||||
// Toggle HTTP server.
|
|
||||||
if (server.running) {
|
|
||||||
await server.shutdown(true).then((_) async {
|
|
||||||
ddsInstance?.shutdown();
|
|
||||||
ddsInstance = null;
|
|
||||||
await VMService().clearState();
|
|
||||||
serverFuture = null;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await server.startup().then((_) async {
|
|
||||||
if (_waitForDdsToAdvertiseService) {
|
|
||||||
ddsInstance = _DebuggingSession();
|
|
||||||
await ddsInstance!.start(
|
|
||||||
_ddsIP,
|
|
||||||
_ddsPort.toString(),
|
|
||||||
_authCodesDisabled,
|
|
||||||
_serveDevtools,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<Uri?> webServerControlCallback(bool enable, bool? silenceOutput) async {
|
Future<Uri?> webServerControlCallback(bool enable, bool? silenceOutput) async {
|
||||||
if (silenceOutput != null) {
|
if (silenceOutput != null) {
|
||||||
silentObservatory = silenceOutput;
|
silentObservatory = silenceOutput;
|
||||||
}
|
}
|
||||||
final _server = _lazyServerBoot();
|
final _server = _lazyServerBoot();
|
||||||
if (_server.running != enable) {
|
if (_server.running != enable) {
|
||||||
await _toggleWebServer(_server);
|
if (enable) {
|
||||||
|
await _server.startup();
|
||||||
|
// TODO: if dds is enabled a dds instance needs to be started.
|
||||||
|
} else {
|
||||||
|
await _server.shutdown(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return _server.serverAddress;
|
return _server.serverAddress;
|
||||||
}
|
}
|
||||||
|
@ -348,13 +329,32 @@ void webServerAcceptNewWebSocketConnections(bool enable) {
|
||||||
_server.acceptNewWebSocketConnections = enable;
|
_server.acceptNewWebSocketConnections = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onSignal(ProcessSignal signal) async {
|
_onSignal(ProcessSignal signal) async {
|
||||||
if (serverFuture != null) {
|
if (serverFuture != null) {
|
||||||
// Still waiting.
|
// Still waiting.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final server = _lazyServerBoot();
|
final _server = _lazyServerBoot();
|
||||||
await _toggleWebServer(server);
|
// Toggle HTTP server.
|
||||||
|
if (_server.running) {
|
||||||
|
_server.shutdown(true).then((_) async {
|
||||||
|
ddsInstance?.shutdown();
|
||||||
|
await VMService().clearState();
|
||||||
|
serverFuture = null;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
_server.startup().then((_) {
|
||||||
|
if (_waitForDdsToAdvertiseService) {
|
||||||
|
ddsInstance = _DebuggingSession()
|
||||||
|
..start(
|
||||||
|
_ddsIP,
|
||||||
|
_ddsPort.toString(),
|
||||||
|
_authCodesDisabled,
|
||||||
|
_serveDevtools,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer? _registerSignalHandlerTimer;
|
Timer? _registerSignalHandlerTimer;
|
||||||
|
@ -400,10 +400,18 @@ main() {
|
||||||
// can be delivered and waiting loaders can be cancelled.
|
// can be delivered and waiting loaders can be cancelled.
|
||||||
VMService();
|
VMService();
|
||||||
if (_autoStart) {
|
if (_autoStart) {
|
||||||
assert(server == null);
|
|
||||||
final _server = _lazyServerBoot();
|
final _server = _lazyServerBoot();
|
||||||
assert(!_server.running);
|
_server.startup().then((_) {
|
||||||
_toggleWebServer(_server);
|
if (_waitForDdsToAdvertiseService) {
|
||||||
|
ddsInstance = _DebuggingSession()
|
||||||
|
..start(
|
||||||
|
_ddsIP,
|
||||||
|
_ddsPort.toString(),
|
||||||
|
_authCodesDisabled,
|
||||||
|
_serveDevtools,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
// It's just here to push an event on the event loop so that we invoke the
|
// It's just here to push an event on the event loop so that we invoke the
|
||||||
// scheduled microtasks.
|
// scheduled microtasks.
|
||||||
Timer.run(() {});
|
Timer.run(() {});
|
||||||
|
|
Loading…
Reference in a new issue