Skip to content

Debugging tests doesn't work with dev containers #2

@Tabby

Description

@Tabby

As reported by @navels: connorshea#90 (comment)

When attempting to debug a test in a dev container, the following error is logged:

{
  "label": "RubyTestExplorer.TestRunner.startDebugSession",
  "level": "error",
  "message": "Cannot debug without a folder opened",
  "time": "2023-03-29T17:40:05.608Z"
}
{
  "label": "RubyTestExplorer.TestRunner",
  "level": "info",
  "message": "Running command: {\n  command: 'bundle exec rdebug-ide --host 127.0.0.1 --port 1240 -- $EXT_DIR/debug_rspec.rb --require /home/lee.nave/.vscode-server/extensions/connorshea.vscode-ruby-test-adapter-0.10.0/ruby/custom_formatter.rb --format CustomFormatter',\n  args: [Array]\n}",
  "time": "2023-03-29T17:40:05.609Z"
}

This is an issue with the way files and workspaces are handled. The current implementation is a bit kludgy and naive, and definitely is something I've been planning on improving at some point, though it hasn't been high on my prioritisation.

As it stands, workspaces are handled like this:

  • On plugin initialisation, the guessWorkspaceFolder method in main.ts checks to see if we have any workspace folders open by looking at the length of vscode.workspace.workspaceFolders
    • If there's exactly one open we use that
    • If there's more than one it... apparently looks for the first one that contains 'src/vs/loader.js'?? I have no idea what I was doing when I made that change. Looks entirely wrong to me now.
  • In the test runner, it checks to see if we've found a workspace folder to use, and if there isn't one it gives the error that was logged above
    • This is fine for the majority of projects opened locally, but I've always known it'll need extending to handle opened files without a workspace folder

So I think there's a couple of things here to fix

  • Fix the code that searches for workspaces so that when there's more than one it actually does the right thing and looks for any workspace folders that are ruby projects we can run tests in, instead of whatever it's doing now
  • Look at the VSC docs on how remote environments (SSH, dev containers, WSL) present their workspace folders and update our code to make sure that if they're not just in the vscode.workspace.workspaceFolders array, that we also check the places they get put as well

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions