From 22fde4aa45a0a0f1b3834d3ea12919861dea0b96 Mon Sep 17 00:00:00 2001 From: gaoguobin <31329849+gaoguobin@users.noreply.github.com> Date: Wed, 20 May 2026 14:55:39 +0800 Subject: [PATCH 1/2] test: make unix socket backup test path-length resilient --- tests/test_core.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/tests/test_core.py b/tests/test_core.py index bc28281..792ba51 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -288,24 +288,27 @@ def test_backup_skips_venv_symlinks_and_unix_sockets(self) -> None: socket_path = home / "app-server-control" / "app-server-control.sock" socket_created = False if hasattr(socket, "AF_UNIX"): - socket_path.parent.mkdir(parents=True) - server = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - try: + socket_path.parent.mkdir(parents=True, exist_ok=True) + with tempfile.TemporaryDirectory(prefix="ceb-sock-", dir=temp_parent) as socket_dir: + short_link = Path(socket_dir) / "app-server-control" try: - server.bind(str(socket_path)) - socket_created = True + short_link.symlink_to(socket_path.parent, target_is_directory=True) + bind_path = short_link / socket_path.name except OSError: - if os.name != "nt": - raise - socket_created = False - result = create_backup( - home, - backup_root=root / "backups", - timestamp="codex-backup-special-files", - run_doctor_commands=False, - ) - finally: - server.close() + bind_path = socket_path + if len(str(bind_path)) < 100: + server = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + try: + server.bind(str(bind_path)) + socket_created = True + finally: + server.close() + result = create_backup( + home, + backup_root=root / "backups", + timestamp="codex-backup-special-files", + run_doctor_commands=False, + ) else: result = create_backup( home, From 5f3deef68faa9f9f5f6e1a6f94a38b25c7c7fc44 Mon Sep 17 00:00:00 2001 From: gaoguobin <31329849+gaoguobin@users.noreply.github.com> Date: Wed, 20 May 2026 15:05:56 +0800 Subject: [PATCH 2/2] tests: handle AF_UNIX bind failures on Windows --- tests/test_core.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/test_core.py b/tests/test_core.py index 792ba51..9fa455e 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -299,8 +299,13 @@ def test_backup_skips_venv_symlinks_and_unix_sockets(self) -> None: if len(str(bind_path)) < 100: server = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) try: - server.bind(str(bind_path)) - socket_created = True + try: + server.bind(str(bind_path)) + except OSError: + if os.name != "nt": + raise + else: + socket_created = True finally: server.close() result = create_backup(