From 4461fe23590f6ed04e011e8cd5ce94cc1f4936dc Mon Sep 17 00:00:00 2001 From: Maksim Shulga Date: Tue, 4 Aug 2026 22:52:42 +0000 Subject: [PATCH] Fix Unix-socket test failing on macOS due to AF_UNIX path length (#14) tmp_path nests too deeply for AF_UNIX socket paths (~104-108 byte limit on macOS). Use a flat tempfile.TemporaryDirectory(), matching the pattern already used by TestEntryKind::test_socket. Co-authored-by: Maxim Shulga Co-authored-by: Claude Sonnet 5 --- IMPROVEMENTS.md | 2 +- tests/test_rsync.py | 27 +++++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/IMPROVEMENTS.md b/IMPROVEMENTS.md index 2d79225..d3d844b 100644 --- a/IMPROVEMENTS.md +++ b/IMPROVEMENTS.md @@ -157,7 +157,7 @@ Acceptance criteria: - [ ] Run CI on pull requests as well as pushes. - [ ] Add macOS CI because macOS is an advertised platform. -- [ ] Fix the Unix-socket path test that currently fails on a local macOS run. +- [x] Fix the Unix-socket path test that currently fails on a local macOS run. - [ ] Replace nonexistent issue references in `xfail` markers with real tracked work, then remove the markers as fixes land. - [ ] Add subprocess-based concurrency, signal, interruption, and fault tests. diff --git a/tests/test_rsync.py b/tests/test_rsync.py index b092c6a..fdc0829 100644 --- a/tests/test_rsync.py +++ b/tests/test_rsync.py @@ -136,17 +136,24 @@ class TestRsync: assert os.path.lexists(dst_path) assert os.path.isdir(dst_path) - def test_src_is_socket(self, common_fs_dirs): - src_dir, dst_dir = common_fs_dirs - src_spath = create_file(str(src_dir)) - dst_spath = os.path.join(str(dst_dir), - relpath(src_spath, str(src_dir), str(dst_dir))) - os.unlink(src_spath) - sock = socket.socket(socket.AF_UNIX) - sock.bind(src_spath) + @pytest.mark.skipif(not hasattr(socket, "AF_UNIX"), + reason="AF_UNIX not available on this platform") + def test_src_is_socket(self): + import tempfile + # AF_UNIX paths are capped at ~104-108 bytes; pytest's tmp_path + # nests too deep on macOS, so use a short-path tempdir directly. + with tempfile.TemporaryDirectory() as d: + src_dir = os.path.join(d, "src") + dst_dir = os.path.join(d, "dst") + os.mkdir(src_dir) + os.mkdir(dst_dir) + src_spath = os.path.join(src_dir, "a_socket") + dst_spath = os.path.join(dst_dir, "a_socket") + with socket.socket(socket.AF_UNIX) as sock: + sock.bind(src_spath) + all(fs.rsync(src_dir, dst_dir)) - all(fs.rsync(str(src_dir), str(dst_dir))) - assert not os.path.lexists(dst_spath) + assert not os.path.lexists(dst_spath) def test_src_dst_same_inode(self, common_fs_dirs): src_dir, dst_dir = common_fs_dirs