Skip to content

Commit f522682

Browse files
committed
test that pixi build is a teenager
1 parent b9568bc commit f522682

File tree

1 file changed

+86
-1
lines changed

1 file changed

+86
-1
lines changed

tests/integration_python/test_build.py

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
22
import shutil
3-
from typing import Any
3+
from typing import Any, Iterator
44
from pathlib import Path
55

66
import pytest
@@ -740,6 +740,91 @@ def test_git_path_lock_branch_records_branch_metadata(
740740
)
741741

742742

743+
@pytest.mark.slow
744+
def test_git_path_build_have_absolutely_no_respect_to_lock_file(
745+
pixi: Path,
746+
build_data: Path,
747+
tmp_pixi_workspace: Path,
748+
local_cpp_git_repo: LocalGitRepo,
749+
) -> None:
750+
prepare_cpp_git_workspace(
751+
tmp_pixi_workspace, build_data, local_cpp_git_repo, branch="other-feature"
752+
)
753+
754+
lock_path = tmp_pixi_workspace / "pixi.lock"
755+
verify_cli_command(
756+
[pixi, "lock", "-v", "--manifest-path", tmp_pixi_workspace],
757+
)
758+
759+
initial_sources = extract_git_sources(lock_path)
760+
assert any(local_cpp_git_repo.other_feature_rev in entry for entry in initial_sources)
761+
762+
repo_path = local_cpp_git_repo.path
763+
main_path = repo_path.joinpath("project", "src", "main.cc")
764+
verify_cli_command([pixi, "run", "git", "checkout", "other-feature"], cwd=repo_path)
765+
main_path.write_text(
766+
main_path.read_text(encoding="utf-8").replace(
767+
"Usage: sdl-example [options]", "Usage: sdl-example v2 [options]"
768+
),
769+
encoding="utf-8",
770+
)
771+
verify_cli_command(
772+
[pixi, "run", "git", "add", main_path.relative_to(repo_path).as_posix()],
773+
cwd=repo_path,
774+
)
775+
verify_cli_command(
776+
[pixi, "run", "git", "commit", "-m", "Update branch for pixi build test"],
777+
cwd=repo_path,
778+
)
779+
new_branch_rev = verify_cli_command(
780+
[pixi, "run", "git", "rev-parse", "HEAD"], cwd=repo_path
781+
).stdout.strip()
782+
assert new_branch_rev != local_cpp_git_repo.other_feature_rev
783+
784+
verify_cli_command(
785+
[
786+
pixi,
787+
"build",
788+
"-v",
789+
"--manifest-path",
790+
tmp_pixi_workspace,
791+
"--output-dir",
792+
tmp_pixi_workspace,
793+
],
794+
)
795+
796+
built_packages = list(tmp_pixi_workspace.glob("*.conda"))
797+
assert built_packages
798+
799+
# lock file should remain untouched when running `pixi build`
800+
assert extract_git_sources(lock_path) == initial_sources
801+
802+
work_dir = tmp_pixi_workspace / ".pixi" / "build" / "work"
803+
assert work_dir.exists()
804+
805+
target_phrase = b"Usage: sdl-example v2 [options]"
806+
legacy_phrase = b"Usage: sdl-example [options]"
807+
808+
def iter_candidate_files() -> Iterator[Path]:
809+
for path in work_dir.rglob("*"):
810+
if not path.is_file():
811+
continue
812+
if path.suffix in {".o", ".bin", ".txt", ".json"} or "sdl_example" in path.name:
813+
yield path
814+
815+
found = []
816+
for candidate in iter_candidate_files():
817+
try:
818+
data = candidate.read_bytes()
819+
except OSError:
820+
continue
821+
if target_phrase in data:
822+
found.append(candidate)
823+
assert legacy_phrase not in data, f"found legacy string in {candidate}"
824+
825+
assert found, "expected build artifacts to include updated branch contents"
826+
827+
743828
@pytest.mark.slow
744829
def test_git_path_lock_tag_records_tag_metadata(
745830
pixi: Path,

0 commit comments

Comments
 (0)