fix(build): stage platform-specific PTY artifacts
This commit is contained in:
@@ -17,14 +17,10 @@ build_python_release = SimpleNamespace(**runpy.run_path(str(SCRIPT)))
|
||||
|
||||
|
||||
def helper_header(target: str) -> bytes:
|
||||
header = bytearray(20)
|
||||
if target.startswith("linux-"):
|
||||
header[:6] = b"\x7fELF\x02\x01"
|
||||
machine = 62 if target == "linux-x64" else 183
|
||||
header[18:20] = machine.to_bytes(2, "little")
|
||||
else:
|
||||
header[:4] = b"\xcf\xfa\xed\xfe"
|
||||
header[4:8] = (0x0100000C).to_bytes(4, "little")
|
||||
header = bytearray(8)
|
||||
header[:4] = b"\xcf\xfa\xed\xfe"
|
||||
cpu_type = 0x01000007 if target == "macos-x64" else 0x0100000C
|
||||
header[4:8] = cpu_type.to_bytes(4, "little")
|
||||
return bytes(header)
|
||||
|
||||
|
||||
@@ -76,7 +72,7 @@ def test_stage_runtime_copies_executable_and_spawn_helper(tmp_path: Path) -> Non
|
||||
|
||||
|
||||
def test_stage_runtime_rejects_missing_spawn_helper(tmp_path: Path) -> None:
|
||||
executable = tmp_path / "dsh-jsonrpc-agent-pkg-linux-x64"
|
||||
executable = tmp_path / "dsh-jsonrpc-agent-pkg-macos-arm64"
|
||||
executable.write_bytes(b"runtime")
|
||||
executable.chmod(0o755)
|
||||
|
||||
@@ -89,20 +85,36 @@ def test_stage_runtime_rejects_missing_spawn_helper(tmp_path: Path) -> None:
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("target", ["linux-x64", "linux-arm64", "macos-arm64"])
|
||||
@pytest.mark.parametrize("target", ["linux-x64", "linux-arm64"])
|
||||
def test_stage_runtime_copies_linux_executable_without_spawn_helper(
|
||||
tmp_path: Path, target: str
|
||||
) -> None:
|
||||
executable = tmp_path / f"dsh-jsonrpc-agent-pkg-{target}"
|
||||
executable.write_bytes(b"runtime")
|
||||
executable.chmod(0o755)
|
||||
destination = tmp_path / "staging"
|
||||
|
||||
build_python_release.stage_runtime(destination, "1.2.3", executable, executable.name)
|
||||
|
||||
runtime_dir = destination / "src" / "deepseek_harness_runtime" / "runtime"
|
||||
runtime_files = [path.name for path in runtime_dir.glob("dsh-jsonrpc-agent-pkg-*")]
|
||||
assert runtime_files == [executable.name]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("target", ["macos-x64", "macos-arm64"])
|
||||
def test_spawn_helper_binary_target(target: str) -> None:
|
||||
assert build_python_release.spawn_helper_binary_target(helper_header(target)) == target
|
||||
|
||||
|
||||
def test_stage_runtime_rejects_mismatched_spawn_helper(tmp_path: Path) -> None:
|
||||
executable = tmp_path / "dsh-jsonrpc-agent-pkg-linux-x64"
|
||||
executable = tmp_path / "dsh-jsonrpc-agent-pkg-macos-arm64"
|
||||
executable.write_bytes(b"runtime")
|
||||
executable.chmod(0o755)
|
||||
spawn_helper = Path(f"{executable}-spawn-helper")
|
||||
spawn_helper.write_bytes(helper_header("linux-arm64"))
|
||||
spawn_helper.write_bytes(helper_header("macos-x64"))
|
||||
spawn_helper.chmod(0o755)
|
||||
|
||||
with pytest.raises(ValueError, match="expected linux-x64, found linux-arm64"):
|
||||
with pytest.raises(ValueError, match="expected macos-arm64, found macos-x64"):
|
||||
build_python_release.stage_runtime(
|
||||
tmp_path / "staging",
|
||||
"1.2.3",
|
||||
|
||||
Reference in New Issue
Block a user