Shopify / ruby-lsp

An opinionated language server for Ruby
https://shopify.github.io/ruby-lsp/
MIT License
1.59k stars 157 forks source link

VScode file explorer - running test that was copy/pasted from another test in same file will instead run the original test. #2639

Open adwidner opened 1 month ago

adwidner commented 1 month ago

Description

Description

If I copy/paste a test in a ruby file then try to run the test copy, it will instead run the original test, regardless of me changing the test name and assertions. Closing and re-opening the file fixes the issue. I came across the issue when I copy/pasted a test that had 90% of the code I needed for a new test I was writing.

Reproduction steps

  1. Open Ruby project in VSCode
  2. Open a Ruby test file
  3. Run a test that has more than 1 assertion
  4. See that the test passes
  5. Copy and paste the test in the same file
  6. Update the title of the test copy
  7. Delete one of the assertions from the test copy
  8. Update one of the assertions from the test copy to fail
  9. Run the test copy

Expected: The test copy runs, has one failure and one less assertion

Actual: The test passes with the same amount of assertions as original test

You can see in the video that the test running animation is also weird for the test copy

https://github.com/user-attachments/assets/5ee1623d-2e6d-4be0-9e80-2792fc2c06b6

Ruby LSP Information

VS Code Version

1.93.1

Ruby LSP Extension Version

0.8.1

Ruby LSP Server Version

0.18.3

Ruby LSP Addons

Ruby Version

3.3.2

Ruby Version Manager

none

Installed Extensions

Click to expand - Bookmarks (13.5.0) - vscode-glimmer (0.0.6) - vscode-eslint (3.0.10) - gitlens (15.5.1) - EditorConfig (0.16.4) - haml (1.4.1) - vscode-rdbg (0.2.2) - vscode-ember-unstable (3.0.55) - vscode-glimmer-syntax (1.0.35) - vscode-scss (0.10.0) - ruby (0.28.1) - ruby-extensions-pack (0.1.12) - ruby-lsp (0.8.1) - sorbet-vscode-extension (0.3.37) - vscode-ruby (0.28.0)

Ruby LSP Settings

Click to expand ##### Workspace ```json {} ``` ##### User ```json { "enableExperimentalFeatures": false, "enabledFeatures": { "codeActions": true, "diagnostics": true, "documentHighlights": true, "documentLink": true, "documentSymbols": true, "foldingRanges": true, "formatting": true, "hover": true, "inlayHint": true, "onTypeFormatting": true, "selectionRanges": true, "semanticHighlighting": true, "completion": true, "codeLens": true, "definition": true, "workspaceSymbol": true, "signatureHelp": true, "typeHierarchy": true }, "featuresConfiguration": {}, "addonSettings": {}, "rubyVersionManager": { "identifier": "auto" }, "customRubyCommand": "", "formatter": "auto", "linters": null, "bundleGemfile": "", "testTimeout": 30, "branch": "", "pullDiagnosticsOn": "both", "useBundlerCompose": false, "bypassTypechecker": false, "rubyExecutablePath": "", "indexing": {}, "erbSupport": true } ```
vinistock commented 3 weeks ago

Thank you for the bug report! I suspect this may be related to #2522, which fixed this for Minitest. We may need to introduce unique IDs for the tests to ensure that the explorer is not confusing the examples.