mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-16 02:21:46 +04:00
Add osx specific limit for command-line length
Limit on OSX is 262144
This commit is contained in:
parent
6bc7b91dd1
commit
7f9b29dfd4
2 changed files with 16 additions and 0 deletions
|
|
@ -15,6 +15,8 @@ from pre_commit.util import cmd_output
|
|||
|
||||
# TODO: properly compute max_length value
|
||||
def _get_platform_max_length():
|
||||
if sys.platform == "darwin":
|
||||
return 262144
|
||||
# posix minimum
|
||||
return 4 * 1024
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,13 @@ def linux_mock():
|
|||
yield
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def osx_mock():
|
||||
with mock.patch.object(sys, 'getfilesystemencoding', return_value='utf-8'):
|
||||
with mock.patch.object(sys, 'platform', 'darwin'):
|
||||
yield
|
||||
|
||||
|
||||
def test_partition_trivial():
|
||||
assert xargs.partition(('cmd',), (), 1) == (('cmd',),)
|
||||
|
||||
|
|
@ -88,6 +95,13 @@ def test_partition_limit_linux(linux_mock):
|
|||
assert ret == (cmd + varargs,)
|
||||
|
||||
|
||||
def test_partition_limit_osx(osx_mock):
|
||||
cmd = ('ninechars',)
|
||||
varargs = (('x' * 9,) * 26214)
|
||||
ret = xargs.partition(cmd, varargs, 1)
|
||||
assert ret == (cmd + varargs[0:26213], (cmd + varargs[26213:]))
|
||||
|
||||
|
||||
def test_argument_too_long_with_large_unicode(linux_mock):
|
||||
cmd = ('ninechars',)
|
||||
varargs = ('😑' * 10,) # 4 bytes * 10
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue