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 <maxim.shulga@alludo.com> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2 files changed
+18
-11
No files matched your search
+1
-1
@@ -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.
|
||||
|
||||
+17
-10
@@ -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
|
||||
|
||||
Reference in new issue
Block a user