foneandrew / ruby-spec-runner

Run specific rspec & minitest tests from within vscode
MIT License
9 stars 3 forks source link

Adding debug option to use integrated debugger #5

Closed mstate closed 5 months ago

mstate commented 1 year ago

First I wanted to thank you for such a great extension!!!

I was thinking it would be really helpful to have a "Debug" option next to the "Run" in the RSpec files. The idea would be that, when you ran using "Debug", it would execute a "Launch Configuration" that would automatically connect the vscode-rdbg extension to the new Ruby Debug gem. So, for every test you ran, you would be able to set breakpoints using the dots in the VSCode sidebar, and have all the local debugging capabilities in the debug panel.

I would love to contribute a PR (and will try when I can find some time). But, so far, I've found the VSCode API to start the debugger. A DebugConfiguration could be generated dynamically based on the file/line number with an rdbg type like:

{
  "type": "rdbg",
  "request": "launch",
  "name": "RSpec Selected Line",
  "program": "rspec",
  "programArgs": [
    "-f",
    "p",
    "-f",
    "j",
    "--out",
   "/tmp/tmp-790-eqDk0IUzDA8t-.json",
    "${relativeFile}:${lineNumber}"
  ],
  "useBundler": true
}

I can do this now, but have to manually attach every time I run a test.

foneandrew commented 1 year ago

Ooooh yeah brilliant idea. I just started using that shopify ruby extension too but haven't hooked into the debugger stuff. If I find some time I would be keen to look into it (for my own learning) but am also super happy to accept PRs for it if you beat me there.

87948157a8f7771317c847cec1a7c72f

mstate commented 1 year ago

Work in progress. Your contributions are certainly welcome. Let me know and I'll add you as a contributor.

launch-rdbg-spec-debugger branch on fork

foneandrew commented 1 year ago

Ah nice. Looking good so far. I noticed that you editor replaced a bunch of quotation marks in some files. This is my bad cause I didn't add the rule for it to eslint. Have pushed a change to main branch with the quotes rule setup to prevent this.

Also when you auto-format files are you able to put those changes in a separate commit? Just cause it makes it hard to see the actual change amongst all the other linting changes.

mstate commented 1 year ago

Will rebase and try to keep it separate.

On Sun, Apr 16, 2023, 5:49 p.m. Andrew Fone @.***> wrote:

Ah nice. Looking good so far. I noticed that you editor replaced a bunch of quotation marks in some files. This is my bad cause I didn't add the rule for it to eslint. Have pushed a change to main branch with the quotes rule setup to prevent this.

Also when you auto-format files are you able to put those changes in a separate commit? Just cause it makes it hard to see the actual change amongst all the other linting changes.

— Reply to this email directly, view it on GitHub https://github.com/foneandrew/ruby-spec-runner/issues/5#issuecomment-1510497322, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAASS7N35YPNTICRVPWNIHTXBRSM3ANCNFSM6AAAAAAW3DUZ7A . You are receiving this because you authored the thread.Message ID: @.***>

foneandrew commented 1 year ago

Hey I have added a first go at getting debugging working. Only managed to get it going for rspec as minitest wasn't attaching the debugger properly ¯_(ツ)_/¯.

Thanks for the api docs you shared, they were a huuuuuuge help. Basically I am relying on one of two vscode ruby debugging extensions (configurable) to attach the debugger, Rdbg and Ruby LSP. 3.6.0 should be live with the debugging soon. Let me know what you think!