Repository navigation
Expand file tree
/
Copy pathtest_layout.py
More file actions
106 lines (92 loc) · 4.24 KB
/
Copy pathtest_layout.py
File metadata and controls
106 lines (92 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env python3
from pathlib import Path
import sys
import tempfile
import unittest
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from codex_package.layout import build_package_dir
from codex_package.layout import validate_package_dir
from codex_package.targets import PACKAGE_VARIANTS
from codex_package.targets import PackageInputs
from codex_package.targets import TARGET_SPECS
class PackageLayoutTest(unittest.TestCase):
def test_macos_package_preserves_prebuilt_resource_binaries(self) -> None:
for variant_name in ("codex", "codex-app-server"):
for target in ("aarch64-apple-darwin", "x86_64-apple-darwin"):
with self.subTest(variant=variant_name, target=target):
with tempfile.TemporaryDirectory() as temp_dir:
root = Path(temp_dir)
package_dir = root / "package"
package_dir.mkdir()
rg_bin = touch_executable(root / "signed-rg")
zsh_bin = touch_executable(root / "signed-zsh")
rg_bin.write_bytes(b"signed ripgrep binary")
zsh_bin.write_bytes(b"signed zsh binary")
variant = PACKAGE_VARIANTS[variant_name]
spec = TARGET_SPECS[target]
inputs = PackageInputs(
entrypoint_bin=touch_executable(
root / variant.executable_stem
),
code_mode_host_bin=touch_executable(
root / "codex-code-mode-host"
),
rg_bin=rg_bin,
zsh_bin=zsh_bin,
bwrap_bin=None,
codex_command_runner_bin=None,
codex_windows_sandbox_setup_bin=None,
)
build_package_dir(package_dir, "1.2.3", variant, spec, inputs)
validate_package_dir(
package_dir, variant, spec, include_zsh=True
)
self.assertEqual(
{
"rg": (package_dir / "codex-path" / "rg").read_bytes(),
"zsh": (
package_dir
/ "codex-resources"
/ "zsh"
/ "bin"
/ "zsh"
).read_bytes(),
},
{
"rg": b"signed ripgrep binary",
"zsh": b"signed zsh binary",
},
)
def test_app_server_package_places_code_mode_host_beside_entrypoint(self) -> None:
with tempfile.TemporaryDirectory() as temp_dir:
root = Path(temp_dir)
package_dir = root / "package"
package_dir.mkdir()
inputs = PackageInputs(
entrypoint_bin=touch_executable(root / "codex-app-server"),
code_mode_host_bin=touch_executable(root / "codex-code-mode-host"),
rg_bin=touch_executable(root / "rg"),
zsh_bin=None,
bwrap_bin=touch_executable(root / "bwrap"),
codex_command_runner_bin=None,
codex_windows_sandbox_setup_bin=None,
)
build_package_dir(
package_dir,
"1.2.3",
PACKAGE_VARIANTS["codex-app-server"],
TARGET_SPECS["x86_64-unknown-linux-musl"],
inputs,
)
validate_package_dir(
package_dir,
PACKAGE_VARIANTS["codex-app-server"],
TARGET_SPECS["x86_64-unknown-linux-musl"],
include_zsh=False,
)
self.assertTrue((package_dir / "bin" / "codex-code-mode-host").is_file())
def touch_executable(path: Path) -> Path:
path.touch(mode=0o755)
return path
if __name__ == "__main__":
unittest.main()