forked from prefix-dev/pixi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: select correct run environment (prefix-dev#2301)
- Loading branch information
1 parent
2894275
commit 4b9bbd7
Showing
3 changed files
with
64 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from pathlib import Path | ||
from .common import verify_cli_command, ExitCode | ||
|
||
ALL_PLATFORMS = '["linux-64", "osx-64", "win-64", "linux-ppc64le", "linux-aarch64"]' | ||
|
||
EMPTY_BOILERPLATE_PROJECT = f""" | ||
[project] | ||
name = "test" | ||
channels = [] | ||
platforms = {ALL_PLATFORMS} | ||
""" | ||
|
||
|
||
def test_run_in_shell(pixi: Path, tmp_path: Path) -> None: | ||
manifest = tmp_path.joinpath("pixi.toml") | ||
toml = f""" | ||
{EMPTY_BOILERPLATE_PROJECT} | ||
[tasks] | ||
task = "echo default" | ||
task1 = "echo default1" | ||
[feature.a.tasks] | ||
task = {{ cmd = "echo a", depends-on = "task1" }} | ||
task1 = "echo a1" | ||
[environments] | ||
a = ["a"] | ||
""" | ||
manifest.write_text(toml) | ||
|
||
# Run the default task | ||
verify_cli_command( | ||
[pixi, "run", "--manifest-path", manifest, "--environment", "default", "task"], | ||
ExitCode.SUCCESS, | ||
stdout_contains="default", | ||
stderr_excludes="default1", | ||
) | ||
|
||
# Run the a task | ||
verify_cli_command( | ||
[pixi, "run", "--manifest-path", manifest, "--environment", "a", "task"], | ||
ExitCode.SUCCESS, | ||
stdout_contains=["a", "a1"], | ||
) | ||
|
||
# Error on non-specified environment as ambiguous | ||
verify_cli_command( | ||
[pixi, "run", "--manifest-path", manifest, "task"], | ||
ExitCode.FAILURE, | ||
stderr_contains=["ambiguous", "default", "a"], | ||
) | ||
|
||
# Simulate activated shell in environment 'a' | ||
env = {"PIXI_IN_SHELL": "true", "PIXI_ENVIRONMENT_NAME": "a"} | ||
verify_cli_command( | ||
[pixi, "run", "--manifest-path", manifest, "task"], | ||
ExitCode.SUCCESS, | ||
stdout_contains=["a", "a1"], | ||
env=env, | ||
) |