fix: relocate long-path runtime console launchers
Assistant: codex Assistant-Model: gpt-6-astra Assistant-Session: 01a0e387-534d-70e3-ad53-4ea05676db8c
This commit is contained in:
parent
505e82db74
commit
81b5fcff8e
3 changed files with 113 additions and 10 deletions
|
|
@ -96,3 +96,44 @@ def test_installed_package_contents_must_match_committed_source(tmp_path, change
|
|||
else:
|
||||
result = builder.verify_source_files(site, [(source, "fixture", "fixture")])
|
||||
assert result["files_verified"] == 1
|
||||
|
||||
|
||||
@pytest.mark.parametrize("launcher", ["direct", "long-path", "spaces"])
|
||||
def test_console_entrypoint_runs_after_build_directory_disappears(tmp_path, monkeypatch, launcher):
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
name = {"long-path": "long-" + "x" * 150, "spaces": "build with spaces"}.get(
|
||||
launcher, "build"
|
||||
)
|
||||
output = tmp_path / name
|
||||
(output / "bin").mkdir(parents=True)
|
||||
shutil.copy2(sys.executable, output / "bin/python3")
|
||||
interpreter = str(output / "bin/python3")
|
||||
body = "print('entrypoint-ok')\n"
|
||||
if launcher == "direct":
|
||||
header = f"#!{interpreter}\n"
|
||||
else:
|
||||
header = "#!/bin/sh\n'''exec' '" + interpreter + "' \"$0\" \"$@\"\n' '''\n"
|
||||
command = output / "bin/rein-aharness"
|
||||
command.write_text(header + body)
|
||||
command.chmod(0o755)
|
||||
binary = output / "bin/native"
|
||||
binary.write_bytes(b"\x7fELF\x00leave unchanged")
|
||||
mount = tmp_path / "mounted"
|
||||
monkeypatch.setattr(builder, "RUNTIME_MOUNT", str(mount))
|
||||
assert builder.relocate_entrypoints(output) == ["rein-aharness"]
|
||||
shutil.move(output, mount)
|
||||
assert not output.exists()
|
||||
result = subprocess.run([str(mount / "bin/rein-aharness")], capture_output=True, text=True)
|
||||
assert result.returncode == 0, result.stderr
|
||||
assert result.stdout.strip() == "entrypoint-ok"
|
||||
assert (mount / "bin/native").read_bytes() == b"\x7fELF\x00leave unchanged"
|
||||
|
||||
|
||||
def test_unknown_governed_launcher_fails_closed(tmp_path):
|
||||
(tmp_path / "bin").mkdir()
|
||||
(tmp_path / "bin/rein-aharness").write_text("#!/bin/sh\nexec /unreviewed/python3\n")
|
||||
with pytest.raises(ValueError, match="unrelocated governed entrypoint"):
|
||||
builder.relocate_entrypoints(tmp_path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue