Increase robustness of tests involving git

1. Disable automatic `git commit` GPG-signing, since that requires interaction.
   This issue was encountered in practice by me, causing spurious test failures
2. In case path operands could turn out to start with dashes, escape the
   operand list with '--'.
This commit is contained in:
Sander Maijers 2016-06-12 18:49:44 +02:00
parent 6b1aa19425
commit 9e89b7616a
No known key found for this signature in database
GPG key ID: 2E974A73F1B0F2F7
4 changed files with 23 additions and 16 deletions

View file

@ -80,11 +80,18 @@ xfailif_no_gitlfs = pytest.mark.xfail(
def test_allows_gitlfs(temp_git_dir): # pragma: no cover
with temp_git_dir.as_cwd():
# Work around https://github.com/github/git-lfs/issues/913
cmd_output('git', 'commit', '--allow-empty', '-m', 'foo')
cmd_output(
'git',
'commit',
'--no-gpg-sign',
'--allow-empty',
'-m',
'foo',
)
cmd_output('git', 'lfs', 'install')
temp_git_dir.join('f.py').write('a' * 10000)
cmd_output('git', 'lfs', 'track', 'f.py')
cmd_output('git', 'add', '.')
cmd_output('git', 'add', '--', '.')
# Should succeed
assert main(('--maxkb', '9', 'f.py')) == 0
@ -96,8 +103,8 @@ def test_moves_with_gitlfs(temp_git_dir): # pragma: no cover
cmd_output('git', 'lfs', 'track', 'a.bin', 'b.bin')
# First add the file we're going to move
temp_git_dir.join('a.bin').write('a' * 10000)
cmd_output('git', 'add', '.')
cmd_output('git', 'commit', '-am', 'foo')
cmd_output('git', 'add', '--', '.')
cmd_output('git', 'commit', '--no-gpg-sign', '-am', 'foo')
# Now move it and make sure the hook still succeeds
cmd_output('git', 'mv', 'a.bin', 'b.bin')
assert main(('--maxkb', '9', 'b.bin')) == 0