Files
codex/scripts/codex_package/test_layout.py
2026-07-09 23:57:01 +00:00

78 lines
2.8 KiB
Python

#!/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_app_server_package_places_code_mode_host_in_resources(self) -> None:
with tempfile.TemporaryDirectory() as temp_dir:
for target, spec in TARGET_SPECS.items():
with self.subTest(target=target):
root = Path(temp_dir) / target
root.mkdir()
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") if spec.is_linux else None
),
codex_command_runner_bin=(
touch_executable(root / "codex-command-runner.exe")
if spec.is_windows
else None
),
codex_windows_sandbox_setup_bin=(
touch_executable(root / "codex-windows-sandbox-setup.exe")
if spec.is_windows
else None
),
)
build_package_dir(
package_dir,
"1.2.3",
PACKAGE_VARIANTS["codex-app-server"],
spec,
inputs,
)
validate_package_dir(
package_dir,
PACKAGE_VARIANTS["codex-app-server"],
spec,
include_zsh=False,
)
self.assertTrue(
(
package_dir
/ "codex-resources"
/ f"codex-code-mode-host{spec.exe_suffix}"
).is_file()
)
def touch_executable(path: Path) -> Path:
path.touch(mode=0o755)
return path
if __name__ == "__main__":
unittest.main()