mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-05-05 23:09:15 -05:00
Force serial hook runs during tests
This commit is contained in:
@@ -50,7 +50,7 @@ def no_install(prefix, version, additional_dependencies):
|
||||
|
||||
|
||||
def target_concurrency(hook):
|
||||
if hook['require_serial']:
|
||||
if hook['require_serial'] or 'PRE_COMMIT_NO_CONCURRENCY' in os.environ:
|
||||
return 1
|
||||
else:
|
||||
# Travis appears to have a bunch of CPUs, but we can't use them all.
|
||||
|
||||
@@ -40,7 +40,15 @@ def test_target_concurrency_normal():
|
||||
|
||||
|
||||
def test_target_concurrency_cpu_count_require_serial_true():
|
||||
assert helpers.target_concurrency({'require_serial': True}) == 1
|
||||
with mock.patch.dict(os.environ, {}, clear=True):
|
||||
assert helpers.target_concurrency({'require_serial': True}) == 1
|
||||
|
||||
|
||||
def test_target_concurrency_testing_env_var():
|
||||
with mock.patch.dict(
|
||||
os.environ, {'PRE_COMMIT_NO_CONCURRENCY': '1'}, clear=True,
|
||||
):
|
||||
assert helpers.target_concurrency({'require_serial': False}) == 1
|
||||
|
||||
|
||||
def test_target_concurrency_on_travis():
|
||||
@@ -52,4 +60,5 @@ def test_target_concurrency_cpu_count_not_implemented():
|
||||
with mock.patch.object(
|
||||
multiprocessing, 'cpu_count', side_effect=NotImplementedError,
|
||||
):
|
||||
assert helpers.target_concurrency({'require_serial': False}) == 1
|
||||
with mock.patch.dict(os.environ, {}, clear=True):
|
||||
assert helpers.target_concurrency({'require_serial': False}) == 1
|
||||
|
||||
Reference in New Issue
Block a user