diff --git a/pre_commit/languages/helpers.py b/pre_commit/languages/helpers.py index ba83ec74..f0a01658 100644 --- a/pre_commit/languages/helpers.py +++ b/pre_commit/languages/helpers.py @@ -1,16 +1,11 @@ -from plumbum import local +import subprocess def run_hook(env, hook, file_args): return env.run( - ' '.join([hook['entry']] + hook.get('args', []) + list(file_args)), - retcode=None, - ) - return env.run( - ' '.join(['xargs |', hook['entry']] + hook.get('args', [])), - retcode=None, - stdin='\n'.join(file_args) + '\n', + ' '.join(['xargs', hook['entry']] + hook.get('args', [])), + stdin='\n'.join(list(file_args) + ['']), ) @@ -29,9 +24,14 @@ class Environment(object): """ raise NotImplementedError - def run(self, cmd, **kwargs): + def run(self, cmd, stdin=None, **kwargs): """Returns (returncode, stdout, stderr).""" - return local['bash'][ - '-c', - ' '.join([self.env_prefix, cmd]) - ].run(**kwargs) + proc = subprocess.Popen( + ['bash', '-c', ' '.join([self.env_prefix, cmd])], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + stdout, stderr = proc.communicate(stdin) + + return proc.returncode, stdout, stderr diff --git a/tests/repository_test.py b/tests/repository_test.py index 0d15ea72..8ba7f799 100644 --- a/tests/repository_test.py +++ b/tests/repository_test.py @@ -52,7 +52,6 @@ def test_run_a_python_hook(config_for_python_pre_commit_git_repo): assert ret[1] == "['/dev/null']\nHello World\n" -@pytest.mark.xfail @pytest.mark.integration def test_run_a_hook_lots_of_files(config_for_python_pre_commit_git_repo): repo = Repository(config_for_python_pre_commit_git_repo) @@ -60,7 +59,6 @@ def test_run_a_hook_lots_of_files(config_for_python_pre_commit_git_repo): ret = repo.run_hook('foo', ['/dev/null'] * 15000) assert ret[0] == 0 - assert ret[1] == 'Hello World\n' @pytest.mark.skipif(