diff options
| author | Junio C Hamano <gitster@pobox.com> | 2019-12-05 12:52:47 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2019-12-05 12:52:47 -0800 |
| commit | 8feb47e8824e16c0913028a59cfaa6d76fc9f209 (patch) | |
| tree | 8112afad8f7b5ec6a0255c264ce3cde9d24100ac /t/test-lib-functions.sh | |
| parent | 6b3cb32f4353266ce02100b49ad5bff3701aa0e8 (diff) | |
| parent | 2a02262078e63dd2b90b2ab40ff024eccb444a48 (diff) | |
| download | git-8feb47e8824e16c0913028a59cfaa6d76fc9f209.tar.gz | |
Merge branch 'dl/t5520-cleanup'
Test cleanup.
* dl/t5520-cleanup:
t5520: replace `! git` with `test_must_fail git`
t5520: remove redundant lines in test cases
t5520: replace $(cat ...) comparison with test_cmp
t5520: don't put git in upstream of pipe
t5520: test single-line files by git with test_cmp
t5520: use test_cmp_rev where possible
t5520: replace test -{n,z} with test-lib functions
t5520: use test_line_count where possible
t5520: remove spaces after redirect operator
t5520: replace test -f with test-lib functions
t5520: let sed open its own input
t5520: use sq for test case names
t5520: improve test style
t: teach test_cmp_rev to accept ! for not-equals
t0000: test multiple local assignment
Diffstat (limited to 't/test-lib-functions.sh')
| -rw-r--r-- | t/test-lib-functions.sh | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index b299ecc326..efcd96fc9e 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1012,19 +1012,30 @@ test_must_be_empty () { fi } -# Tests that its two parameters refer to the same revision +# Tests that its two parameters refer to the same revision, or if '!' is +# provided first, that its other two parameters refer to different +# revisions. test_cmp_rev () { + local op='=' wrong_result=different + + if test $# -ge 1 && test "x$1" = 'x!' + then + op='!=' + wrong_result='the same' + shift + fi if test $# != 2 then error "bug in the test script: test_cmp_rev requires two revisions, but got $#" else local r1 r2 r1=$(git rev-parse --verify "$1") && - r2=$(git rev-parse --verify "$2") && - if test "$r1" != "$r2" + r2=$(git rev-parse --verify "$2") || return 1 + + if ! test "$r1" "$op" "$r2" then cat >&4 <<-EOF - error: two revisions point to different objects: + error: two revisions point to $wrong_result objects: '$1': $r1 '$2': $r2 EOF |
