@matheusbsbs / matheus-bagliano / commits / 979f8891cc
Fork 0

t5520: replace test -{n,z} with test-lib functions

When wrapping a git command in a command substitution within another command, we throw away the git command's exit code. In case the git command fails, we would like to know about it rather than the failure being silent. Extract git commands so that their exit codes are not lost. Instead of using `test -n` or `test -z`, replace them respectively with invocations of test_file_not_empty() and test_must_be_empty() so that we get better debugging information in the case of a failure. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Denton Liu committed Nov 12, 2019 at 15:08 UTC 979f8891cca562f0af7044ff9ade9f3e5caa3be5
1 file changed +8 -4
t/t5520-pull.sh
+8 -4
@@ -206,15 +206,18 @@ test_expect_success 'fail if the index has unresolved entries' '
206 test_when_finished "git checkout -f copy && git branch -D third" &&
207 test "$(cat file)" = file &&
208 test_commit modified2 file &&
209 - test -z "$(git ls-files -u)" &&
209 + git ls-files -u >unmerged &&
210 + test_must_be_empty unmerged &&
211 test_must_fail git pull . second &&
211 - test -n "$(git ls-files -u)" &&
212 + git ls-files -u >unmerged &&
213 + test_file_not_empty unmerged &&
214 cp file expected &&
215 test_must_fail git pull . second 2>err &&
216 test_i18ngrep "Pulling is not possible because you have unmerged files." err &&
217 test_cmp expected file &&
218 git add file &&
217 - test -z "$(git ls-files -u)" &&
219 + git ls-files -u >unmerged &&
220 + test_must_be_empty unmerged &&
221 test_must_fail git pull . second 2>err &&
222 test_i18ngrep "You have not concluded your merge" err &&
223 test_cmp expected file
@@ -667,7 +670,8 @@ test_expect_success 'git pull --rebase detects upstreamed changes' '
670 (
671 cd dst &&
672 git pull --rebase &&
670 - test -z "$(git ls-files -u)"
673 + git ls-files -u >untracked &&
674 + test_must_be_empty untracked
675 )
676 '
677