connorshea / vscode-ruby-test-adapter

A Ruby test adapter extension for the VS Code Test Explorer
https://marketplace.visualstudio.com/items?itemName=connorshea.vscode-ruby-test-adapter
MIT License
83 stars 50 forks source link

Debug test #38

Closed baelter closed 3 years ago

baelter commented 4 years ago

Add support for debugging tests. Branched based on #37

connorshea commented 4 years ago

Could you rebase this now that the other PR is merged? I assume you're using the VSCode-Ruby extension as the Ruby debugger?

baelter commented 4 years ago

Could you rebase this now that the other PR is merged? I assume you're using the VSCode-Ruby extension as the Ruby debugger?

Yes, ruby-debug-ide. Can be made configurable in the future.

Rebased, this PR also adds support for filePattern config for rspec.

baelter commented 4 years ago

ping @connorshea :)

sdaubert commented 4 years ago

@connorshea merging this PR will be awesome

htatche commented 4 years ago

Looking forward for this one :+1:

CezaryGapinski commented 4 years ago

Hi @baelter !

I was trying to use this PR and debug works really good, but I stumbled upon an issue for running single test. When I try to start it, then all other tests were also running.

I suspect this change can cause a problem:

  protected getTestCommand(): string {
    let command: string = (vscode.workspace.getConfiguration('rubyTestExplorer', null).get('rspecCommand') as string);
-    return command || 'bundle exec rspec';
+    const dir = this.getTestDirectory();
+    let pattern = this.getFilePattern().map(p => `${dir}/**/${p}`).join(',')
+    if (command && / (--pattern|-P) /.test(command)) {
+      return command
+    }
+    command = command || `bundle exec rspec`
+    return `${command} --pattern '${pattern}'`;
  }

I think it is something related to --pattern option for rspec and maybe it overwrites default pattern and that's why all tests are run.

Here are logs from Ruby Test Explorer for master branch:

[2020-05-21 15:19:07.077] [INFO] Running single test: /xxxxxxxx/spec/par_map_spec.rb:46
[2020-05-21 15:19:07.077] [INFO] Running command: bundle exec rspec --require /home/xxxxxxxx/.vscode/extensions/connorshea.vscode-ruby-test-adapter-0.7.1/custom_formatter.rb --format CustomFormatter '/xxxxxxxx/spec/par_map_spec.rb:46'

and for your PR:

[2020-05-21 15:21:24.523] [INFO] Running single test: /xxxxxxxx/par_map_spec.rb:46
[2020-05-21 15:21:24.524] [INFO] Running command: bundle exec rspec --pattern './spec//**/*_spec.rb,./spec//**/spec_*.rb' --require /home/xxxxxxxx/.vscode/extensions/connorshea.vscode-ruby-test-adapter-0.7.1/custom_formatter.rb --format CustomFormatter '/xxxxxxxx/par_map_spec.rb:46'

As you can see there is additional --pattern option which can cause a problem.

Can you look at this. Maybe only I have this problem in my configuration :).

Looking forward to use debug test option in the next release :).

baelter commented 4 years ago

Thanks @CezaryGapinski, feel free to make a new PR based on what I wrote. I stopped using this extension.

connorshea commented 3 years ago

Closing this since #51 continues it.