Skip to content
Merged
Changes from 4 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
24 changes: 17 additions & 7 deletions src/odin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,11 @@ impl zed::Extension for OdinExtension {
resolved_label: String,
debug_adapter_name: String,
) -> Option<DebugScenario> {
// Only handle Odin run tasks
if build_task.command != "odin" || build_task.args.is_empty() || build_task.args[0] != "run"
{
let is_run = build_task.command == "odin" && build_task.args.first() == Some(&"run".into());
let is_test =
build_task.command == "odin" && build_task.args.first() == Some(&"test".into());

if !is_run && !is_test {
return None;
}

Expand All @@ -449,9 +451,17 @@ impl zed::Extension for OdinExtension {
build_args.push("-debug".into());
}

if is_test {
build_args.push("-build-mode:test".into())
}

// Create the build task template
let build_template = BuildTaskTemplate {
label: "odin debug build".into(),
label: if is_test {
"odin debug test".into()
} else {
"odin debug build".into()
},
command: build_task.command.clone(),
args: build_args,
env: build_task.env.clone(),
Expand Down Expand Up @@ -487,12 +497,12 @@ impl zed::Extension for OdinExtension {
_locator_name: String,
build_task: TaskTemplate,
) -> Result<DebugRequest, String> {
// Only handle Odin build tasks
// Only handle Odin build and test tasks
if build_task.command != "odin"
|| build_task.args.is_empty()
|| build_task.args[0] != "build"
|| !(build_task.args[0] == "build" || build_task.args[0] == "test")
{
return Err("Not an Odin build task".to_string());
return Err("Not an Odin build or test task".to_string());
}

// Extract the binary name from the -out: flag
Expand Down