Skip to content

Commit fea6593

Browse files
committed
test that pixi build is a teenager
1 parent 1bb0de4 commit fea6593

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
@@ -770,6 +770,91 @@ def test_git_path_lock_branch_records_branch_metadata(
770770
)
771771

772772

773+
@pytest.mark.slow
774+
def test_git_path_build_have_absolutely_no_respect_to_lock_file(
775+
pixi: Path,
776+
build_data: Path,
777+
tmp_pixi_workspace: Path,
778+
local_cpp_git_repo: LocalGitRepo,
779+
) -> None:
780+
prepare_cpp_git_workspace(
781+
tmp_pixi_workspace, build_data, local_cpp_git_repo, branch="other-feature"
782+
)
783+
784+
lock_path = tmp_pixi_workspace / "pixi.lock"
785+
verify_cli_command(
786+
[pixi, "lock", "-v", "--manifest-path", tmp_pixi_workspace],
787+
)
788+
789+
initial_sources = extract_git_sources(lock_path)
790+
assert any(local_cpp_git_repo.other_feature_rev in entry for entry in initial_sources)
791+
792+
repo_path = local_cpp_git_repo.path
793+
main_path = repo_path.joinpath("project", "src", "main.cc")
794+
verify_cli_command([pixi, "run", "git", "checkout", "other-feature"], cwd=repo_path)
795+
main_path.write_text(
796+
main_path.read_text(encoding="utf-8").replace(
797+
"Usage: sdl-example [options]", "Usage: sdl-example v2 [options]"
798+
),
799+
encoding="utf-8",
800+
)
801+
verify_cli_command(
802+
[pixi, "run", "git", "add", main_path.relative_to(repo_path).as_posix()],
803+
cwd=repo_path,
804+
)
805+
verify_cli_command(
806+
[pixi, "run", "git", "commit", "-m", "Update branch for pixi build test"],
807+
cwd=repo_path,
808+
)
809+
new_branch_rev = verify_cli_command(
810+
[pixi, "run", "git", "rev-parse", "HEAD"], cwd=repo_path
811+
).stdout.strip()
812+
assert new_branch_rev != local_cpp_git_repo.other_feature_rev
813+
814+
verify_cli_command(
815+
[
816+
pixi,
817+
"build",
818+
"-v",
819+
"--manifest-path",
820+
tmp_pixi_workspace,
821+
"--output-dir",
822+
tmp_pixi_workspace,
823+
],
824+
)
825+
826+
built_packages = list(tmp_pixi_workspace.glob("*.conda"))
827+
assert built_packages
828+
829+
# lock file should remain untouched when running `pixi build`
830+
assert extract_git_sources(lock_path) == initial_sources
831+
832+
work_dir = tmp_pixi_workspace / ".pixi" / "build" / "work"
833+
assert work_dir.exists()
834+
835+
target_phrase = b"Usage: sdl-example v2 [options]"
836+
legacy_phrase = b"Usage: sdl-example [options]"
837+
838+
def iter_candidate_files() -> Iterator[Path]:
839+
for path in work_dir.rglob("*"):
840+
if not path.is_file():
841+
continue
842+
if path.suffix in {".o", ".bin", ".txt", ".json"} or "sdl_example" in path.name:
843+
yield path
844+
845+
found = []
846+
for candidate in iter_candidate_files():
847+
try:
848+
data = candidate.read_bytes()
849+
except OSError:
850+
continue
851+
if target_phrase in data:
852+
found.append(candidate)
853+
assert legacy_phrase not in data, f"found legacy string in {candidate}"
854+
855+
assert found, "expected build artifacts to include updated branch contents"
856+
857+
773858
@pytest.mark.slow
774859
def test_git_path_lock_tag_records_tag_metadata(
775860
pixi: Path,

0 commit comments

Comments
 (0)