Skip to content

Commit 982be73

Browse files
committed
Add regression test for pre-commit#339.
1 parent 9411499 commit 982be73

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/commands/run_test.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,3 +596,26 @@ def test_unstaged_message_suppressed(
596596
args = _get_opts(**opts)
597597
ret, printed = _do_run(modified_config_repo, args)
598598
assert b'Your .pre-commit-config.yaml is unstaged.' not in printed
599+
600+
601+
def test_files_running_subdir(
602+
repo_with_passing_hook, mock_out_store_directory, tempdir_factory,
603+
):
604+
with cwd(repo_with_passing_hook):
605+
install(Runner(repo_with_passing_hook))
606+
607+
os.mkdir('subdir')
608+
open('subdir/foo.py', 'w').close()
609+
cmd_output('git', 'add', 'subdir/foo.py')
610+
611+
with cwd('subdir'):
612+
# Don't want to write to home directory
613+
env = dict(os.environ, PRE_COMMIT_HOME=tempdir_factory.get())
614+
# Use subprocess to demonstrate behaviour in main
615+
_, stdout, _ = cmd_output(
616+
sys.executable, '-m', 'pre_commit.main', 'run', '-v',
617+
# Files relative to where we are (#339)
618+
'--files', 'foo.py',
619+
env=env,
620+
)
621+
assert 'subdir/foo.py' in stdout

0 commit comments

Comments
 (0)