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

VS Code: Different working dir for Test Run and Debug #14537

Closed
izderadicka opened this issue Apr 9, 2023 · 1 comment
Closed

VS Code: Different working dir for Test Run and Debug #14537

izderadicka opened this issue Apr 9, 2023 · 1 comment
Labels
A-vscode vscode plugin issues C-bug Category: bug

Comments

@izderadicka
Copy link

rust-analyzer version: 0.3.1463-standalone
rustc version: rustc 1.65.0 (897e37553 2022-11-02)

I have workspace project with libraries defined in Cargo.toml like this:

[workspace]
members = ["crates/*"]

When running a test in on of workspace member library collection, which start like this:

#[test]
    fn test_creation() {
        let base_path = PathBuf::from("../../test_data");
        println!("Current dir is {:?}", std::env::current_dir().unwrap());
        assert!(base_path.is_dir());
       // ...
}

I do get different results when using "Run Test" and "Debug" annotations links (above test function).
"Run Test" is using library package dir (project_dir/crates/collection) as current_dir and is ok, "Debug" is using project dir as working dir and fails.
The former is also behavior if test is run from cmd line:

cargo test -p collection test_creation -- --nocapture

where also package dir is used as working dir.

Same is happening when using predefined configuration in launch.json "Debug unit tests in library 'collection'", however that can be fixed by changing cwd to "${workspaceFolder}/crates/collection".

This inconsistency should be fixed and "Debug" should use same working directory as "Run Test".
Also generated debug configs for workspace libraries in launch.json should reflect that.

@izderadicka izderadicka added the C-bug Category: bug label Apr 9, 2023
@Veykril Veykril added the A-vscode vscode plugin issues label Apr 9, 2023
@flodiebold
Copy link
Member

Duplicate of #13022.

@flodiebold flodiebold closed this as not planned Won't fix, can't repro, duplicate, stale Apr 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-vscode vscode plugin issues C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants