Rust: Execute tasks from files ZED_DIRNAME (#13658)

Fixes #13267

Release Notes:

- Fixed Rust tests not working when crates Cargo.toml is not at the root
of a worktree.
This commit is contained in:
Piotr Osiewicz 2024-06-28 22:17:45 +02:00 committed by GitHub
parent b1a0188467
commit f1859e3645
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -420,12 +420,14 @@ impl ContextProvider for RustContextProvider {
"-p".into(), "-p".into(),
RUST_PACKAGE_TASK_VARIABLE.template_value(), RUST_PACKAGE_TASK_VARIABLE.template_value(),
], ],
cwd: Some("$ZED_DIRNAME".to_owned()),
..TaskTemplate::default() ..TaskTemplate::default()
}, },
TaskTemplate { TaskTemplate {
label: "cargo check --workspace --all-targets".into(), label: "cargo check --workspace --all-targets".into(),
command: "cargo".into(), command: "cargo".into(),
args: vec!["check".into(), "--workspace".into(), "--all-targets".into()], args: vec!["check".into(), "--workspace".into(), "--all-targets".into()],
cwd: Some("$ZED_DIRNAME".to_owned()),
..TaskTemplate::default() ..TaskTemplate::default()
}, },
TaskTemplate { TaskTemplate {
@ -444,6 +446,7 @@ impl ContextProvider for RustContextProvider {
"--nocapture".into(), "--nocapture".into(),
], ],
tags: vec!["rust-test".to_owned()], tags: vec!["rust-test".to_owned()],
cwd: Some("$ZED_DIRNAME".to_owned()),
..TaskTemplate::default() ..TaskTemplate::default()
}, },
TaskTemplate { TaskTemplate {
@ -460,6 +463,7 @@ impl ContextProvider for RustContextProvider {
VariableName::Stem.template_value(), VariableName::Stem.template_value(),
], ],
tags: vec!["rust-mod-test".to_owned()], tags: vec!["rust-mod-test".to_owned()],
cwd: Some("$ZED_DIRNAME".to_owned()),
..TaskTemplate::default() ..TaskTemplate::default()
}, },
TaskTemplate { TaskTemplate {
@ -476,6 +480,7 @@ impl ContextProvider for RustContextProvider {
"--bin".into(), "--bin".into(),
RUST_BIN_NAME_TASK_VARIABLE.template_value(), RUST_BIN_NAME_TASK_VARIABLE.template_value(),
], ],
cwd: Some("$ZED_DIRNAME".to_owned()),
tags: vec!["rust-main".to_owned()], tags: vec!["rust-main".to_owned()],
..TaskTemplate::default() ..TaskTemplate::default()
}, },
@ -490,18 +495,21 @@ impl ContextProvider for RustContextProvider {
"-p".into(), "-p".into(),
RUST_PACKAGE_TASK_VARIABLE.template_value(), RUST_PACKAGE_TASK_VARIABLE.template_value(),
], ],
cwd: Some("$ZED_DIRNAME".to_owned()),
..TaskTemplate::default() ..TaskTemplate::default()
}, },
TaskTemplate { TaskTemplate {
label: "cargo run".into(), label: "cargo run".into(),
command: "cargo".into(), command: "cargo".into(),
args: vec!["run".into()], args: vec!["run".into()],
cwd: Some("$ZED_DIRNAME".to_owned()),
..TaskTemplate::default() ..TaskTemplate::default()
}, },
TaskTemplate { TaskTemplate {
label: "cargo clean".into(), label: "cargo clean".into(),
command: "cargo".into(), command: "cargo".into(),
args: vec!["clean".into()], args: vec!["clean".into()],
cwd: Some("$ZED_DIRNAME".to_owned()),
..TaskTemplate::default() ..TaskTemplate::default()
}, },
])) ]))