Unverified Commit 118f6123 authored by Kenzie Schmoll's avatar Kenzie Schmoll Committed by GitHub

Return the existing DevTools server from DevToolsLauncher.serve if one is already running. (#74271)

* Return the existing DevTools server from DevToolsLauncher.serve if one is already running.
parent 831ee22b
......@@ -172,7 +172,9 @@ class DevtoolsServerLauncher extends DevtoolsLauncher {
@override
Future<DevToolsServerAddress> serve() async {
if (activeDevToolsServer == null) {
await launch(null);
}
return activeDevToolsServer;
}
......
......@@ -120,6 +120,55 @@ void main() {
expect(address.port, 9100);
});
testWithoutContext('DevtoolsLauncher does not launch a new DevTools instance if one is already active', () async {
final Completer<void> completer = Completer<void>();
final DevtoolsLauncher launcher = DevtoolsServerLauncher(
pubExecutable: 'pub',
logger: logger,
platform: platform,
persistentToolState: persistentToolState,
processManager: FakeProcessManager.list(<FakeCommand>[
const FakeCommand(
command: <String>[
'pub',
'global',
'activate',
'devtools',
],
stdout: 'Activated DevTools 0.9.5',
),
const FakeCommand(
command: <String>[
'pub',
'global',
'list',
],
stdout: 'devtools 0.9.6',
),
FakeCommand(
command: const <String>[
'pub',
'global',
'run',
'devtools',
'--no-launch-browser',
],
stdout: 'Serving DevTools at http://127.0.0.1:9100\n',
completer: completer,
),
]),
);
DevToolsServerAddress address = await launcher.serve();
expect(address.host, '127.0.0.1');
expect(address.port, 9100);
// Call `serve` again and verify that the already running server is returned.
address = await launcher.serve();
expect(address.host, '127.0.0.1');
expect(address.port, 9100);
});
testWithoutContext('DevtoolsLauncher does not activate DevTools if it was recently activated', () async {
persistentToolState.lastDevToolsActivationTime = DateTime.now();
final DevtoolsLauncher launcher = DevtoolsServerLauncher(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment