Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Dec 1, 2024
1 parent 874cc86 commit 8a27f5f
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion py-rattler-build/README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Python bindings to rattler-build
# Python bindings to rattler-build
3 changes: 2 additions & 1 deletion py-rattler-build/rattler_build/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .rattler_build import get_rattler_build_version_py as _get_rattler_build_version_py
from .rattler_build import \
get_rattler_build_version_py as _get_rattler_build_version_py


def rattler_build_version() -> str:
Expand Down
3 changes: 2 additions & 1 deletion py-rattler-build/tests/unit/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import rattler_build
from pathlib import Path

import rattler_build


def test_basic() -> None:
parent_cargo_toml = Path(__file__).parent.parent.parent.parent / "Cargo.toml"
Expand Down
1 change: 1 addition & 0 deletions test-data/recipes/cache/recipe-symlinks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ cache:
ln -s $PREFIX/foo.txt $PREFIX/absolute-symlink.txt
ln -s $PREFIX/non-existent-file $PREFIX/broken-symlink.txt
ln -s ./foo.txt $PREFIX/relative-symlink.txt
echo ${{ PREFIX }} > $PREFIX/prefix.txt
outputs:
- package:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"size_in_bytes": 0
},
{
"_path": "prefix.txt",
"file_mode": "text",
"path_type": "hardlink",
"sha256": "1f7c780c5a35eeab2ffd8a7d38f9db34974e84ca569db0ff99af21159b5d02d6",
"size_in_bytes": 256
},
{
"_path": "relative-symlink.txt",
"path_type": "softlink",
Expand Down
16 changes: 14 additions & 2 deletions test/end-to-end/test_symlinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import pytest
from helpers import RattlerBuild, get_extracted_package
from syrupy.filters import paths as filter_paths


@pytest.mark.skipif(
Expand Down Expand Up @@ -34,10 +35,11 @@ def test_symlink_cache(

paths_json = pkg / "info/paths.json"
j = json.loads(paths_json.read_text())
assert snapshot_json == j
# prefix placeholder always changes, and we test it later
assert snapshot_json(exclude=filter_paths("paths.4.prefix_placeholder")) == j

paths = j["paths"]
assert len(paths) == 5
assert len(paths) == 6
for p in paths:
if "symlink" in p["_path"]:
assert p["path_type"] == "softlink"
Expand All @@ -61,3 +63,13 @@ def test_symlink_cache(
relative_symlink = pkg / "bin/exe-symlink"
assert relative_symlink.is_symlink()
assert relative_symlink.readlink() == Path("exe")

prefix_txt = pkg / "prefix.txt"
assert prefix_txt.exists()
contents = prefix_txt.read_text()
assert contents.len() > 0
# find the path in paths.json for the prefix.txt
for p in paths:
if p["_path"] == "prefix.txt":
assert p["path_type"] == "hardlink"
assert p["prefix_placeholder"] == contents.strip()

0 comments on commit 8a27f5f

Please sign in to comment.