Skip to content

Commit

Permalink
Extend tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Hofer-Julian committed Oct 21, 2024
1 parent d11587a commit 7664271
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/cli/global/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ async fn setup_environment(
}

// Add the dependencies to the environment
for spec in specs {
for spec in specs.iter().chain(&args.with) {
project.manifest.add_dependency(
env_name,
spec,
Expand Down
6 changes: 3 additions & 3 deletions src/global/project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,14 +701,14 @@ impl Project {
}
}
ExposedType::Filter(filter) => {
// Add new binaries that are not yet exposed and that come from one of the packages we filter on
// Add new binaries that are not yet exposed and that don't come from one of the packages we filter on
let executable_names = env_executables
.into_iter()
.filter_map(|(package_name, executable)| {
if filter.contains(&package_name) {
Some(executable)
} else {
None
} else {
Some(executable)
}
})
.flatten()
Expand Down
136 changes: 136 additions & 0 deletions tests/integration/test_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,142 @@ def test_existing_manifest_gets_version(pixi: Path, tmp_path: Path, dummy_channe
assert actual_manifest == expected_manifest


def test_install_with_basic(pixi: Path, tmp_path: Path, dummy_channel_1: str) -> None:
env = {"PIXI_HOME": str(tmp_path)}
manifests = tmp_path.joinpath("manifests")
manifest = manifests.joinpath("pixi-global.toml")

dummy_a = tmp_path / "bin" / exec_extension("dummy-a")
dummy_aa = tmp_path / "bin" / exec_extension("dummy-aa")
dummy_b = tmp_path / "bin" / exec_extension("dummy-b")
dummy_c = tmp_path / "bin" / exec_extension("dummy-c")

verify_cli_command(
[
pixi,
"global",
"install",
"--channel",
dummy_channel_1,
"dummy-a",
"--with",
"dummy-b",
"--with",
"dummy-c",
],
env=env,
)

expected_manifest = f"""\
version = {MANIFEST_VERSION}
[envs.dummy-a]
channels = ["{dummy_channel_1}"]
dependencies = {{ dummy-a = "*", dummy-b = "*", dummy-c = "*" }}
exposed = {{ dummy-a = "dummy-a", dummy-aa = "dummy-aa" }}
"""
actual_manifest = manifest.read_text()

# Ensure that the manifest is correctly adapted
assert actual_manifest == expected_manifest

assert dummy_a.is_file()
assert dummy_aa.is_file()
assert not dummy_b.is_file()
assert not dummy_c.is_file()


def test_install_with_environment_no_expose(
pixi: Path, tmp_path: Path, dummy_channel_1: str
) -> None:
env = {"PIXI_HOME": str(tmp_path)}
manifests = tmp_path.joinpath("manifests")
manifest = manifests.joinpath("pixi-global.toml")

dummy_a = tmp_path / "bin" / exec_extension("dummy-a")
dummy_aa = tmp_path / "bin" / exec_extension("dummy-aa")
dummy_b = tmp_path / "bin" / exec_extension("dummy-b")

verify_cli_command(
[
pixi,
"global",
"install",
"--channel",
dummy_channel_1,
"--environment",
"dummy",
"dummy-a",
"--with",
"dummy-b",
],
env=env,
)

expected_manifest = f"""\
version = {MANIFEST_VERSION}
[envs.dummy]
channels = ["{dummy_channel_1}"]
dependencies = {{ dummy-a = "*", dummy-b = "*" }}
exposed = {{ dummy-a = "dummy-a", dummy-aa = "dummy-aa" }}
"""
actual_manifest = manifest.read_text()

# Ensure that the manifest is correctly adapted
assert actual_manifest == expected_manifest

assert dummy_a.is_file()
assert dummy_aa.is_file()
assert not dummy_b.is_file()


def test_install_with_environment_and_expose(
pixi: Path, tmp_path: Path, dummy_channel_1: str
) -> None:
env = {"PIXI_HOME": str(tmp_path)}
manifests = tmp_path.joinpath("manifests")
manifest = manifests.joinpath("pixi-global.toml")

dummy_a = tmp_path / "bin" / exec_extension("dummy-a")
dummy_aa = tmp_path / "bin" / exec_extension("dummy-aa")
dummy_b = tmp_path / "bin" / exec_extension("dummy-b")

verify_cli_command(
[
pixi,
"global",
"install",
"--channel",
dummy_channel_1,
"--environment",
"dummy",
"--expose=dummy-b",
"dummy-a",
"--with",
"dummy-b",
],
env=env,
)

expected_manifest = f"""\
version = {MANIFEST_VERSION}
[envs.dummy]
channels = ["{dummy_channel_1}"]
dependencies = {{ dummy-a = "*", dummy-b = "*" }}
exposed = {{ dummy-b = "dummy-b" }}
"""
actual_manifest = manifest.read_text()

# Ensure that the manifest is correctly adapted
assert actual_manifest == expected_manifest

assert not dummy_a.is_file()
assert not dummy_aa.is_file()
assert dummy_b.is_file()


def test_install_twice(pixi: Path, tmp_path: Path, dummy_channel_1: str) -> None:
env = {"PIXI_HOME": str(tmp_path)}

Expand Down

0 comments on commit 7664271

Please sign in to comment.