Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix testing packages with multiple targets #19005

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

duncanawoods
Copy link

@duncanawoods duncanawoods commented Jan 22, 2025

This PR fixes #18955 and other bugs related to RA executing the wrong test and/or assigning results incorrectly.

It makes test execution aware of the difference between packages and targets.

It removes the need to use hack_recover_crate_name to match test output to tests.

  • request::handle_run_test
    • no longer tries (and fails) to reduce a list of tests to a single pattern
  • test_runner::CargoTestHandle
    • no longer runs patterns against the workspace and now always runs tests in the correct target
  • CargoActor
    • is extended to take a parser that has the required context for parsing tool output correctly
  • main_loop
    • every CargoTestMessage in the event queue now contains the required information to assign to correct test

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 22, 2025
@duncanawoods duncanawoods force-pushed the 18955---fix-running-tests-for-packages-with-multiple-targets branch from d1acee6 to 9e4161c Compare January 22, 2025 22:15
@rustbot rustbot added has-merge-commits S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 7, 2025
@rustbot

This comment has been minimized.

@HKalbasi
Copy link
Member

HKalbasi commented Feb 7, 2025

Ah sorry I forgot this. Now that the hack_recover_crate_name is gone, this actually reduces the amount of workarounds so I'm happy to merge this if you remove the merge commits.

@duncanawoods duncanawoods force-pushed the 18955---fix-running-tests-for-packages-with-multiple-targets branch from adcd9cf to c756cb6 Compare February 7, 2025 12:16
@rustbot rustbot removed has-merge-commits S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 7, 2025
fix test running by invoking cargo per package

remove hack_recover_crate_name

make clippy happy
@duncanawoods duncanawoods force-pushed the 18955---fix-running-tests-for-packages-with-multiple-targets branch from c756cb6 to 1a9da62 Compare February 7, 2025 12:17
@duncanawoods
Copy link
Author

duncanawoods commented Feb 7, 2025

Oh that's great, thank you @HKalbasi !

Do you have any thoughts about adding some testing to this feature?

Having seen the dizzying number of permutations of how tests are defined and how they might be invoked I'm nervous about regressions. I'm thinking of an integration test using a sample workspace that tries to define every type of test and we might be able to simulate vscode interaction with "code --command" .

@HKalbasi
Copy link
Member

HKalbasi commented Feb 7, 2025

If you want to add some end to end tests, look at https://github.com/rust-lang/rust-analyzer/blob/master/crates/rust-analyzer/tests/slow-tests/main.rs which creates a cargo project and communicate with rust-analyzer using lsp. But those tests slowdown CI so I would suggest having at most one test about test-explorer there (which can test many operations, most of the time is spent on the loading) and test other corner cases using unit tests that takes some hard coded json of cargo and/or assert text of the cargo commands instead of executing them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VSCode Test Explorer - bugs running tests for packages with multiple targets
3 participants