fsck: add stress tests for fsck.skipList

Stress test the parsing logic shared by fsck.skipList and {fetch,receive}.fsck.skipList added in cd94c6f91e ("fsck: git receive-pack: support excluding objects from fsck'ing", 2015-06-22). There were no tests for the work done by the init_skiplist() routine, e.g. how it dies on invalid input. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Jul 27, 2018 at 14:37 UTC 65a836fa6bf9e9cf604e22855e744af61e708664
1 file changed +28
t/t5504-fetch-receive-strict.sh
+28
@@ -133,6 +133,14 @@ committer Bugs Bunny <bugs@bun.ni> 1234567890 +0000
133 This commit object intentionally broken
134 EOF
135
136 +test_expect_success 'fsck with invalid or bogus skipList input' '
137 + git -c fsck.skipList=/dev/null -c fsck.missingEmail=ignore fsck &&
138 + test_must_fail git -c fsck.skipList=does-not-exist -c fsck.missingEmail=ignore fsck 2>err &&
139 + test_i18ngrep "Could not open skip list: does-not-exist" err &&
140 + test_must_fail git -c fsck.skipList=.git/config -c fsck.missingEmail=ignore fsck 2>err &&
141 + test_i18ngrep "Invalid SHA-1: \[core\]" err
142 +'
143 +
144 test_expect_success 'push with receive.fsck.skipList' '
145 commit="$(git hash-object -t commit -w --stdin <bogus-commit)" &&
146 git push . $commit:refs/heads/bogus &&
@@ -146,6 +154,16 @@ test_expect_success 'push with receive.fsck.skipList' '
154 git --git-dir=dst/.git config fsck.skipList SKIP &&
155 test_must_fail git push --porcelain dst bogus &&
156
157 + # Invalid and/or bogus skipList input
158 + git --git-dir=dst/.git config receive.fsck.skipList /dev/null &&
159 + test_must_fail git push --porcelain dst bogus &&
160 + git --git-dir=dst/.git config receive.fsck.skipList does-not-exist &&
161 + test_must_fail git push --porcelain dst bogus 2>err &&
162 + test_i18ngrep "Could not open skip list: does-not-exist" err &&
163 + git --git-dir=dst/.git config receive.fsck.skipList config &&
164 + test_must_fail git push --porcelain dst bogus 2>err &&
165 + test_i18ngrep "Invalid SHA-1: \[core\]" err &&
166 +
167 git --git-dir=dst/.git config receive.fsck.skipList SKIP &&
168 git push --porcelain dst bogus
169 '
@@ -166,6 +184,16 @@ test_expect_success 'fetch with fetch.fsck.skipList' '
184 git --git-dir=dst/.git config fsck.skipList dst/.git/SKIP &&
185 test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec &&
186
187 + # Invalid and/or bogus skipList input
188 + git --git-dir=dst/.git config fetch.fsck.skipList /dev/null &&
189 + test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec &&
190 + git --git-dir=dst/.git config fetch.fsck.skipList does-not-exist &&
191 + test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec 2>err &&
192 + test_i18ngrep "Could not open skip list: does-not-exist" err &&
193 + git --git-dir=dst/.git config fetch.fsck.skipList dst/.git/config &&
194 + test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec 2>err &&
195 + test_i18ngrep "Invalid SHA-1: \[core\]" err &&
196 +
197 git --git-dir=dst/.git config fetch.fsck.skipList dst/.git/SKIP &&
198 git --git-dir=dst/.git fetch "file://$(pwd)" $refspec
199 '