-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
VSCode "Debug" test cwd is workspace root, not package root for tests #13022
Comments
Disclaimer: I have never used JS/TS so take the following as you will From what I can tell, the Debug executing directory is set here and is unconditionally the workspace/open folder root directory. After some changes to the example repo and looking through cargo source:
The target appears to be known in the same scope although I don't know if that's package/folder/something else at this point. Presumably whether it's a run/test(/example/benchmark) or not can be obtained from this E: Tests and benchmarks are definitely run the same way by cargo. This appears to be where the cmd is built for both. |
In addition it doesn't include any of the cargo environment variables that could be used to help normalize a path. For example, |
Debug use cargo workspace root as `cwd` fixes #13022
This reverts commit 4ca86ed.
This reverts commit 4ca86ed.
Fix inconsistent cwd of `run` and `debug` command in client Fix #17012. Also related to #13022 and #15993. When the `kind` of runnable is `bin`, Cargo would use the workspace root as the cwd for the `run` command; otherwise, Cargo defaults to the package root as the cwd for `run`. Initially, r-a assumed the workspace root as the cwd for all runnables in `debug` command, which led to issue #13022. In this case, during unit testing, the `run` command would use the package root while `debug` would use the workspace root, causing inconsistency. PR #15993 addressed this problem by using the package root as the cwd for `debug` command. However, it also resulted in an inconsistency: when executing the `run` command within the main fn of a package (whose target is `bin`), Cargo would use the workspace root, whereas `debug` would use the package root, leading to issue #17012. The preferable approach is to determine the cwd based on the runnable's type. To resolve this, this PR introduces a new `cwd` field within `CargoRunnable`, allowing r-a to decide the appropriate cwd depending on the specific kind of the runnable.
Setup: https://github.com/Crzyrndm/ra-executing-directory
A package nested in a workspace, the tests (unit + integration) just print
std::env::current_dir()
and then panic (so that the print is always visible)cargo test --no-fail-fast
: prints the package root directory for both unit and integration no matter what directory it is run inThis makes debugging tests that need to load a data file quite awkward
rust-analyzer version: rust-lang.rust-analyzer 0.3.1170 (current stable)
rustc version: rustc 1.63.0 (4b91a6ea7 2022-08-08)
Tested OS is Windows 10
relevant settings:
The text was updated successfully, but these errors were encountered: