Skip to content

Test Debug API: DebugConfigurationProvider.provideDebugAdapter #59107

@weinand

Description

@weinand

Test for #45220, #56646, #57706, #54465:

Complexity: 4

Authors: @weinand

Verify that:

  • the API works as described.
  • specifically verify that the 2 constraints are obeyed:
    • an extension is only allowed to register a DebugConfigurationProvider with a provideDebugAdapter method if the extension defines the debug type. Otherwise an error is thrown.
    • registering more than one DebugConfigurationProvider with a provideDebugAdapter method for a type results in an error.
  • verify that the following cases work:

the default behaviour:

provideDebugAdapter3(session, folder, executable, config): ProviderResult<DebugAdapterDescriptor> {
  return executable;
}

You can add env vars and cwd:

provideDebugAdapter3(session, folder, executable, config): ProviderResult<DebugAdapterDescriptor> {
  return new DebugAdapterExecutable(executable.command, executable.args, { foo: "bar" });
}

You can emulate VS Code's debugServer feature with this:

provideDebugAdapter3(session, folder, executable, config): ProviderResult<DebugAdapterDescriptor> {
  if (typeof config.debugServer === 'number') {
    return newDebugAdapterServer(config.debugServer);
  }
  return executable;
}

You can run the DA as a server automatically:

provideDebugAdapter3(session, folder, executable, config): ProviderResult<DebugAdapterDescriptor> {

  // start server on launch of first debug session
  if (!this._server) {
    // start listening on a random port
    this._server = Net.createServer(socket => {
      const session = new MockDebugSession();
      session.setRunAsServer(true);
      session.start(<NodeJS.ReadableStream>socket, socket);
    }).listen(0);
  }

  // make VS Code connect to debug server instead of launching debug adapter
  return newDebugAdapterServer(this._server.address().port);
}

The last option to return a DebugAdapterImplementation is not yet available because it requires a matching node-module that I did not made available yet.

Metadata

Metadata

Assignees

Labels

debugDebug viewlet, configurations, breakpoints, adapter issuestestplan-item

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions