Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
python: Respect picked toolchain (when it's not at the root) when running tests (#31150)
Thiago Pachecoaacbb9c2f458
diff --git a/crates/languages/src/python.rs b/crates/languages/src/python.rsindex 5ff9156ed90..0a5c9dfc9eb 100644--- a/crates/languages/src/python.rs+++ b/crates/languages/src/python.rs@@ -379,17 +379,19 @@ impl ContextProvider for PythonContextProvider {};let module_target = self.build_module_target(variables);- let worktree_id = location- .file_location- .buffer- .read(cx)- .file()- .map(|f| f.worktree_id(cx));+ let location_file = location.file_location.buffer.read(cx).file().cloned();+ let worktree_id = location_file.as_ref().map(|f| f.worktree_id(cx));cx.spawn(async move |cx| {let raw_toolchain = if let Some(worktree_id) = worktree_id {+ let file_path = location_file+ .as_ref()+ .and_then(|f| f.path().parent())+ .map(Arc::from)+ .unwrap_or_else(|| Arc::from("".as_ref()));+toolchains- .active_toolchain(worktree_id, Arc::from("".as_ref()), "Python".into(), cx)+ .active_toolchain(worktree_id, file_path, "Python".into(), cx).await.map_or_else(|| String::from("python3"),@@ -398,14 +400,16 @@ impl ContextProvider for PythonContextProvider {} else {String::from("python3")};+let active_toolchain = format!("\"{raw_toolchain}\"");let toolchain = (PYTHON_ACTIVE_TOOLCHAIN_PATH, active_toolchain);- let raw_toolchain = (PYTHON_ACTIVE_TOOLCHAIN_PATH_RAW, raw_toolchain);+ let raw_toolchain_var = (PYTHON_ACTIVE_TOOLCHAIN_PATH_RAW, raw_toolchain);+Ok(task::TaskVariables::from_iter(test_target.into_iter().chain(module_target.into_iter())- .chain([toolchain, raw_toolchain]),+ .chain([toolchain, raw_toolchain_var]),))})}