Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Execute all test controller items in one go #667

Closed
wants to merge 1 commit into from

Conversation

vinistock
Copy link
Member

Motivation

Currently, each test item in the controller is executed in a separate process, which is a bit wasteful given that we only display the tests for the current file.

We can instead execute all tests in a single command and then just parse the output to show to the user.

Implementation

The basic idea is:

  1. Flatten the test list. Initially, the test items are nested (i.e.: test methods are inside classes). We need a flat list that only includes the specific examples that will be executed
  2. Then we generated the command to execute all selected examples in one go. For Minitest and test-unit, that means creating a big regex that will match all selected examples. For Rails, it just means adding all paths and line numbers (e.g.: test/foo_test.rb:5 test/foo_test.rb:15...)
  3. If all tests pass, then we just update that they all passed. If something fails, then we need to parse the output, match the failure message with the test item and only fail those

Manual Tests

Suggested repos:

  • ruby-lsp -> minitest
  • ruby-lsp-rails -> rails
  • yarp -> test-unit
  1. Open any test file
  2. Execute tests, verify that all results show up simultaneously
  3. Introduce an intentional failure
  4. Run the tests
  5. Verify the failure shows up with the correct message

@vinistock vinistock added the enhancement New feature or request label Jun 29, 2023
@vinistock vinistock added this to the 2023-Q2 milestone Jun 29, 2023
@vinistock vinistock self-assigned this Jun 29, 2023
@vinistock vinistock requested a review from a team as a code owner June 29, 2023 20:13
Copy link
Contributor

@KaanOzkan KaanOzkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't get the failures to show up when I run all tests in a file. For both exceptions and incorrect assertions.

Screenshot 2023-06-30 at 3 14 35 PM

name,
uri
);
let testItem;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting Variable 'testItem' implicitly has type 'any' in some locations where its type cannot be determined. locally from TS lsp.

@vinistock vinistock modified the milestones: 2023-Q2, 2023-Q3 Jul 14, 2023
@vinistock
Copy link
Member Author

This is quite complicated to get right and feels a bit too rigid. I'm closing this for now.

@vinistock vinistock closed this Jul 31, 2023
@vinistock vinistock deleted the vs/run_all_filtered_tests_at_the_same_time branch July 31, 2023 17:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants