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 '--'.
diff --git a/tests/check_added_large_files_test.py b/tests/check_added_large_files_test.py
index 99c60cb..ce15f5c 100644
--- a/tests/check_added_large_files_test.py
+++ b/tests/check_added_large_files_test.py
@@ -80,11 +80,18 @@
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 @@
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