Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Pass file directory as cwd for Run test of CodeLens #1584

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rls/src/actions/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ pub fn collect_run_actions(ctx: &InitActionContext, file: &Path) -> Vec<RunActio
test_name.to_string(),
],
env: iter::once(("RUST_BACKTRACE".to_string(), "short".to_string())).collect(),
cwd: file.parent().and_then(|dir| dir.to_str()).map(String::from),
},
};
ret.push(run_action);
Expand All @@ -85,6 +86,7 @@ pub struct Cmd {
pub binary: String,
pub args: Vec<String>,
pub env: HashMap<String, String>,
pub cwd: Option<String>,
}

pub struct LineIndex {
Expand Down
3 changes: 2 additions & 1 deletion tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,8 @@ fn client_lens_run() {
arguments: Some(vec![json!({
"args": [ "test", "--", "--nocapture", "test_foo" ],
"binary": "cargo",
"env": { "RUST_BACKTRACE": "short" }
"env": { "RUST_BACKTRACE": "short" },
"cwd": p.root().join("src")
})]),
}),
data: None,
Expand Down