debugger: Add locator for Python tasks (#31533)

Closes #ISSUE

Release Notes:

- debugger: Python tests/main functions can now we debugged from the
gutter.

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
This commit is contained in:
Piotr Osiewicz 2025-05-28 12:27:12 +02:00 committed by GitHub
parent 15d59fcda9
commit c0a5ace8b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 118 additions and 3 deletions

View file

@ -413,6 +413,7 @@ impl ContextProvider for PythonContextProvider {
"-c".to_owned(),
VariableName::SelectedText.template_value_with_whitespace(),
],
cwd: Some("$ZED_WORKTREE_ROOT".into()),
..TaskTemplate::default()
},
// Execute an entire file
@ -420,6 +421,7 @@ impl ContextProvider for PythonContextProvider {
label: format!("run '{}'", VariableName::File.template_value()),
command: PYTHON_ACTIVE_TOOLCHAIN_PATH.template_value(),
args: vec![VariableName::File.template_value_with_whitespace()],
cwd: Some("$ZED_WORKTREE_ROOT".into()),
..TaskTemplate::default()
},
// Execute a file as module
@ -430,6 +432,7 @@ impl ContextProvider for PythonContextProvider {
"-m".to_owned(),
PYTHON_MODULE_NAME_TASK_VARIABLE.template_value(),
],
cwd: Some("$ZED_WORKTREE_ROOT".into()),
tags: vec!["python-module-main-method".to_owned()],
..TaskTemplate::default()
},
@ -447,6 +450,7 @@ impl ContextProvider for PythonContextProvider {
"unittest".to_owned(),
VariableName::File.template_value_with_whitespace(),
],
cwd: Some("$ZED_WORKTREE_ROOT".into()),
..TaskTemplate::default()
},
// Run test(s) for a specific target within a file
@ -462,6 +466,7 @@ impl ContextProvider for PythonContextProvider {
"python-unittest-class".to_owned(),
"python-unittest-method".to_owned(),
],
cwd: Some("$ZED_WORKTREE_ROOT".into()),
..TaskTemplate::default()
},
]
@ -477,6 +482,7 @@ impl ContextProvider for PythonContextProvider {
"pytest".to_owned(),
VariableName::File.template_value_with_whitespace(),
],
cwd: Some("$ZED_WORKTREE_ROOT".into()),
..TaskTemplate::default()
},
// Run test(s) for a specific target within a file
@ -488,6 +494,7 @@ impl ContextProvider for PythonContextProvider {
"pytest".to_owned(),
PYTHON_TEST_TARGET_TASK_VARIABLE.template_value_with_whitespace(),
],
cwd: Some("$ZED_WORKTREE_ROOT".into()),
tags: vec![
"python-pytest-class".to_owned(),
"python-pytest-method".to_owned(),