diff --git a/tests/conftest.py b/tests/conftest.py index a47b030..958a4c6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,8 +2,6 @@ import json import logging -import os -import stat import subprocess import sys import time @@ -25,8 +23,6 @@ for _mod in ( if _mod not in sys.modules: sys.modules[_mod] = unittest.mock.MagicMock() -import pytest - logger = logging.getLogger(__name__) COORDINATOR_URL = "http://localhost:8210" @@ -159,70 +155,3 @@ def gpu_settings(): ) -def _git(args: list[str], cwd: Path) -> None: - subprocess.run(["git"] + args, cwd=cwd, check=True, capture_output=True) - - -@pytest.fixture -def divergent_repo(tmp_path: Path) -> Path: - """Repo whose local branch and origin/main have diverged on bun.lock. - - Layout after setup: - local main — initial commit + local-only commit (edits bun.lock) - origin/main — initial commit + remote-only commit (edits bun.lock differently) - Fetching makes local 1 ahead, 1 behind with a guaranteed bun.lock conflict on rebase. - """ - bare = tmp_path / "remote.git" - local = tmp_path / "local" - - subprocess.run(["git", "init", "--bare", str(bare)], check=True, capture_output=True) - - local.mkdir() - _git(["init"], local) - _git(["config", "user.email", "test@test.com"], local) - _git(["config", "user.name", "Test User"], local) - _git(["remote", "add", "origin", str(bare)], local) - - # Shared base commit - (local / "bun.lock").write_text("# lockfile v0\n[[packages]]\n") - (local / "package.json").write_text('{"name":"test","version":"1.0.0"}\n') - _git(["add", "."], local) - _git(["commit", "-m", "Initial commit"], local) - _git(["push", "-u", "origin", "master"], local) - - # Remote diverges: adds a dep - other = tmp_path / "other" - subprocess.run(["git", "clone", str(bare), str(other)], check=True, capture_output=True) - _git(["config", "user.email", "test@test.com"], other) - _git(["config", "user.name", "Test User"], other) - (other / "bun.lock").write_text("# lockfile v0\n[[packages]]\nremote-dep = '1.0.0'\n") - _git(["add", "bun.lock"], other) - _git(["commit", "-m", "remote: add remote-dep"], other) - _git(["push", "origin", "master"], other) - - # Local diverges: adds a different dep - (local / "bun.lock").write_text("# lockfile v0\n[[packages]]\nlocal-dep = '2.0.0'\n") - _git(["add", "bun.lock"], local) - _git(["commit", "-m", "local: add local-dep"], local) - - # Fetch so origin/master is known locally (but do NOT pull — we want divergence) - _git(["fetch", "origin"], local) - - return local - - -@pytest.fixture -def fake_bun_binary(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path: - """Install a stub `bun` script on PATH that exits 0 and writes a clean lockfile.""" - bin_dir = tmp_path / "stub-bin" - bin_dir.mkdir() - bun = bin_dir / "bun" - bun.write_text( - "#!/bin/sh\n" - # Write a clean lockfile to the cwd so git add succeeds - "printf '# lockfile v0\\n[[packages]]\\n' > bun.lock\n" - "exit 0\n" - ) - bun.chmod(bun.stat().st_mode | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH) - monkeypatch.setenv("PATH", f"{bin_dir}:{os.environ['PATH']}") - return bun