From f23b1659a33657b3c56b5661820239540d3a0354 Mon Sep 17 00:00:00 2001 From: "Joshua L. Adelman" Date: Fri, 4 Apr 2025 10:00:23 -0400 Subject: [PATCH 1/3] fix panic for platform specific tasks --- src/cli/task.rs | 2 +- tests/integration_python/test_main_cli.py | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/cli/task.rs b/src/cli/task.rs index 1c97bdb7c7..3a4fec8193 100644 --- a/src/cli/task.rs +++ b/src/cli/task.rs @@ -364,7 +364,7 @@ async fn list_tasks(workspace: Workspace, args: ListArgs) -> miette::Result<()> .into_iter() .map(|task_name| { let task = env - .task(&task_name, None) + .task(&task_name, Some(env.best_platform())) .expect("task should be available here"); (task_name, task) }) diff --git a/tests/integration_python/test_main_cli.py b/tests/integration_python/test_main_cli.py index 8c9b99a6be..48b9a3ad8c 100644 --- a/tests/integration_python/test_main_cli.py +++ b/tests/integration_python/test_main_cli.py @@ -1212,3 +1212,26 @@ def test_pixi_info_tasks(pixi: Path, tmp_pixi_workspace: Path) -> None: """ manifest.write_text(toml) verify_cli_command([pixi, "info", "--manifest-path", manifest], stdout_contains="foo, bar") + + +def test_pixi_task_list_platforms(pixi: Path, tmp_pixi_workspace: Path) -> None: + manifest = tmp_pixi_workspace.joinpath("pixi.toml") + toml = """ + [workspace] + name = "test" + channels = [] + platforms = ["linux-64", "win-64", "osx-64"] + + [tasks] + foo = "echo foo" + + [target.unix.tasks] + bar = "echo bar" + + [target.win.tasks] + bar = "echo bar" + """ + manifest.write_text(toml) + verify_cli_command( + [pixi, "task", "list", "--manifest-path", manifest], stderr_contains=["foo", "bar"] + ) From 771bd041fa79aa0acb6b0edc17604f038c3d41bb Mon Sep 17 00:00:00 2001 From: Hofer-Julian <30049909+Hofer-Julian@users.noreply.github.com> Date: Fri, 4 Apr 2025 16:05:50 +0200 Subject: [PATCH 2/3] Update tests/integration_python/test_main_cli.py --- tests/integration_python/test_main_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration_python/test_main_cli.py b/tests/integration_python/test_main_cli.py index 48b9a3ad8c..ff4464d2b5 100644 --- a/tests/integration_python/test_main_cli.py +++ b/tests/integration_python/test_main_cli.py @@ -1220,7 +1220,7 @@ def test_pixi_task_list_platforms(pixi: Path, tmp_pixi_workspace: Path) -> None: [workspace] name = "test" channels = [] - platforms = ["linux-64", "win-64", "osx-64"] + platforms = ["linux-64", "win-64", "osx-64", "osx-arm64"] [tasks] foo = "echo foo" From 8d218dd74d2f6c5d67de7550c86171bb5d7f0cf4 Mon Sep 17 00:00:00 2001 From: Julian Hofer Date: Tue, 8 Apr 2025 09:24:59 +0200 Subject: [PATCH 3/3] Don't panic if no task could be found --- src/cli/task.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/cli/task.rs b/src/cli/task.rs index 3a4fec8193..e7864e44a6 100644 --- a/src/cli/task.rs +++ b/src/cli/task.rs @@ -362,11 +362,10 @@ async fn list_tasks(workspace: Workspace, args: ListArgs) -> miette::Result<()> .map(|(env, task_names)| { let task_map = task_names .into_iter() - .map(|task_name| { - let task = env - .task(&task_name, Some(env.best_platform())) - .expect("task should be available here"); - (task_name, task) + .flat_map(|task_name| { + env.task(&task_name, Some(env.best_platform())) + .ok() + .map(|task| (task_name, task)) }) .collect(); (env, task_map)