mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 06:18:07 +03:00
integration: enable unlink tests
Summary: On macOS/NFS, for whatever reason, calling "unlink" on a directory will always give a EPERM error. EdenFS is not involved in the error returned. Reviewed By: fanzeyi Differential Revision: D43962767 fbshipit-source-id: d0834b472be29657c1e37062a955337091a58be4
This commit is contained in:
parent
053dbd428d
commit
a629980e28
@ -268,12 +268,6 @@ elif sys.platform.startswith("darwin"):
|
||||
# OSError: AF_UNIX path too long
|
||||
TEST_DISABLED["unixsocket_test.UnixSocketTest"] = True
|
||||
|
||||
# Output doesn't match expected result
|
||||
TEST_DISABLED["unlink_test.UnlinkTest"] = [
|
||||
"test_unlink_dir",
|
||||
"test_unlink_empty_dir",
|
||||
]
|
||||
|
||||
# EdenFS on macOS uses NFSv3, which doesn't support extended attributes.
|
||||
TEST_DISABLED["xattr_test.XattrTest"] = True
|
||||
|
||||
|
@ -8,6 +8,7 @@ import errno
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
from typing import Tuple
|
||||
|
||||
from .lib import testcase
|
||||
|
||||
@ -47,41 +48,38 @@ class UnlinkTest(testcase.EdenRepoTest):
|
||||
msg="unlink raises ENOENT for nonexistent file",
|
||||
)
|
||||
|
||||
def get_expected_errno(self) -> Tuple[int, str]:
|
||||
if sys.platform == "linux":
|
||||
return errno.EISDIR, "EISDIR"
|
||||
elif sys.platform == "win32":
|
||||
return errno.EACCES, "EACCES"
|
||||
else:
|
||||
return errno.EPERM, "EPERM"
|
||||
|
||||
def test_unlink_dir(self) -> None:
|
||||
adir = os.path.join(self.mount, "adir")
|
||||
with self.assertRaises(OSError) as context:
|
||||
os.unlink(adir)
|
||||
|
||||
if sys.platform != "win32":
|
||||
self.assertEqual(
|
||||
context.exception.errno,
|
||||
errno.EISDIR,
|
||||
msg="unlink on a dir raises EISDIR",
|
||||
)
|
||||
else:
|
||||
self.assertEqual(
|
||||
context.exception.errno,
|
||||
errno.EACCES,
|
||||
msg="unlink on a dir raises EACCES",
|
||||
)
|
||||
err, errstr = self.get_expected_errno()
|
||||
self.assertEqual(
|
||||
context.exception.errno,
|
||||
err,
|
||||
msg=f"unlink on a dir raises {errstr}",
|
||||
)
|
||||
|
||||
def test_unlink_empty_dir(self) -> None:
|
||||
adir = os.path.join(self.mount, "an-empty-dir")
|
||||
os.mkdir(adir)
|
||||
with self.assertRaises(OSError) as context:
|
||||
os.unlink(adir)
|
||||
if sys.platform != "win32":
|
||||
self.assertEqual(
|
||||
context.exception.errno,
|
||||
errno.EISDIR,
|
||||
msg="unlink on an empty dir raises EISDIR",
|
||||
)
|
||||
else:
|
||||
self.assertEqual(
|
||||
context.exception.errno,
|
||||
errno.EACCES,
|
||||
msg="unlink on an empty dir raises EACCES",
|
||||
)
|
||||
|
||||
err, errstr = self.get_expected_errno()
|
||||
self.assertEqual(
|
||||
context.exception.errno,
|
||||
err,
|
||||
msg=f"unlink on an empty dir raises {errstr}",
|
||||
)
|
||||
|
||||
def test_rmdir_file(self) -> None:
|
||||
filename = os.path.join(self.mount, "hello")
|
||||
|
Loading…
Reference in New Issue
Block a user