Skip to content

Commit

Permalink
Test to make sure virtual packages aren't included in lockfiles
Browse files Browse the repository at this point in the history
Closes conda#559
  • Loading branch information
maresb committed Jan 18, 2024
1 parent 809875b commit 06aeb53
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions tests/test_conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,20 @@ def zlib_environment(tmp_path: Path):
return clone_test_dir("zlib", tmp_path).joinpath("environment.yml")


@pytest.fixture
def tzcode_environment(tmp_path: Path):
contents = """
channels:
- conda-forge
- nodefaults
dependencies:
- tzcode
"""
env = tmp_path / "environment.yml"
env.write_text(contents)
return env


@pytest.fixture
def input_hash_zlib_environment(tmp_path: Path):
return clone_test_dir("test-input-hash-zlib", tmp_path).joinpath("environment.yml")
Expand Down Expand Up @@ -1812,7 +1826,9 @@ def test_install(
kind: str,
tmp_path: Path,
conda_exe: str,
zlib_environment: Path,
# We choose tzcode since it depends on glibc on linux-64, and this induces a
# virtual package, and we test to make sure it's filtered out from the lockfile.
tzcode_environment: Path,
monkeypatch: "pytest.MonkeyPatch",
capsys: "pytest.CaptureFixture[str]",
):
Expand All @@ -1830,7 +1846,7 @@ def test_install(
generated_lockfile_path.mkdir(exist_ok=True)
monkeypatch.chdir(generated_lockfile_path)

package = "zlib"
package = "tzcode"
platform = "linux-64"

lock_filename_template = (
Expand All @@ -1852,7 +1868,7 @@ def test_install(
"-p",
platform,
"-f",
str(zlib_environment),
str(tzcode_environment),
"-k",
kind,
"--filename-template",
Expand All @@ -1866,6 +1882,14 @@ def test_install(
print(result.stderr, file=sys.stderr)
assert result.exit_code == 0

lockfile_content = Path(lock_filename).read_text()
might_contain_virtual_package = "__" in lockfile_content
assert not might_contain_virtual_package, (
f"Lockfile may contain a virtual package (e.g. __glibc). "
f"These should never appear in the lockfile. "
f"{lockfile_content}"
)

prefix = root_prefix / "test_env"

context: ContextManager
Expand Down

0 comments on commit 06aeb53

Please sign in to comment.