Open andypeters opened 3 months ago
Hi @andypeters, this is a known limitation, there is some work happening here to try improve it:
https://github.com/Shopify/ruby-lsp/pull/2230
(I moved the issue to ruby-lsp-rails
, but I'm going to move it back since this is a more general problem)
Hey thanks @andyw8! Dang, I missed looking at active pull requests. My instinct told me you all knew about it, but you never know. All good and happy to hear you all are trying to get it working. I'll subscribe to that pull request and follow along.
This issue is being marked as stale because there was no activity in the last 2 months
I took a look at what it would take to do this, wanted to leave my thoughts here as a guide to either myself picking this up at some point in the future or someone else motivated to give it a try.
Running tests as a single combined process is not hard (at least for rspec, i assume its the same for minitest). It's just providing a different line reference in the run command. The rspec addon/plugin/whatever already provides the command for the test groups, they just get skipped because those TestRun instances don't have the 'example' tag on them. The request for running the tests includes the specific TestRun thats associated with the codelens action, so you can update the code to just execute that command and not traverse the children looking for examples.
The real issue with implementing this is parsing the output (and applying it to the TestRun items to make the UI show the results). And this comes up in multiple ways. It's easy to attach the output to a test when its just a single test per process. But when you run them together, you need to pull apart the output. Since different runners format the output differently, we'd need different parsers. Currently the parsing occurs on the client side of the extension, which doesn't have addon support like the server does (so rspec parsing would have to live apart from its addon repo). And of course, even the test output can be unexpected, if the project uses custom formatters. So no matter how good the parser is that gets shipped, it will have holes.
I think we'd get better mileage by trying to run the tests in parallel. Or investigating whether something like spring could be used to bypass the startup time of the tests.
Description:
When running a test class in the VScode Test Explorer, the tests take quite a while to complete. It seems they are running one at a time starting with the last test first (visually from the bottom up). Additionally, it indicates running in a single process per test.
If this is known or expected, I'm sorry I missed the mention. I scoped out the issue list here and shopify/ruby-lsp-rails as best I could. There were a few somewhat related regarding speed to rspec tests, but I know that is an extension so I thought it fitting to report in regard to minitest here. One being this: https://github.com/Shopify/ruby-lsp/issues/2049
Reproduction steps
test/models/foo_test.
Run / Run in Terminal / Debug
appear.test_helper.rb
:Grasping at straws, I went bonkers and nuclear 💥
.vscode
:rm -rf ~/.vscode
Library/Application Support/Code
. (or is it visual studio code - can't remember because its gone 😆 )Gifs for ya from a throw away rails app
Screenshot for "running in a single process"
Using very basic test. ie:
My environment
FWIW, this is the result on a handful of projects which are all up-to-date with Rails 7 using minitest. I'm using asdf and for this throw away project
ruby 3.3.2
.Here are the details for the throwaway rails project:
Output from VSCode for ruby-lsp:
Gem list for lsp:
Bundle list (just in case you want more details and a longer description :-) ):