- Guard setup with test_expect_success - Single-quoted, tab prefaced test blocks of < 80 cols - Redirect unwanted output Signed-off-by: Tom Grennan <tmgrennan@xxxxxxxxx> --- t/t5512-ls-remote.sh | 29 ++++++++++++++++++++--------- 1 files changed, 20 insertions(+), 9 deletions(-) diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh index 5c546c9..bbe650f 100755 --- a/t/t5512-ls-remote.sh +++ b/t/t5512-ls-remote.sh @@ -2,14 +2,22 @@ test_description='git ls-remote' +if ! test -r test-lib.sh ; then + (cd ${0%/*} && ./${0##*/} $@) + exit $? +fi + . ./test-lib.sh +quiet () { "$@" >/dev/null; } +silent () { "$@" >/dev/null 2>&1; } + test_expect_success setup ' >file && git add file && test_tick && - git commit -m initial && + git commit -q -m initial && git tag mark && git show-ref --tags -d | sed -e "s/ / /" >expected.tag && ( @@ -51,7 +59,7 @@ test_expect_success 'ls-remote self' ' test_expect_success 'dies when no remote specified and no default remotes found' ' - test_must_fail git ls-remote + silent test_must_fail git ls-remote ' @@ -70,8 +78,8 @@ test_expect_success 'use "origin" when no remote specified' ' test_expect_success 'suppress "From <url>" with -q' ' - git ls-remote -q 2>actual_err && - test_must_fail test_cmp exp_err actual_err + quiet git ls-remote -q 2>actual_err && + test_must_fail cmp -s exp_err actual_err ' @@ -83,7 +91,7 @@ test_expect_success 'use branch.<name>.remote if possible' ' # # setup a new remote to differentiate from "origin" - git clone . other.git && + git clone -q . other.git && ( cd other.git && echo "$(git rev-parse HEAD) HEAD" @@ -102,11 +110,13 @@ test_expect_success 'use branch.<name>.remote if possible' ' ' -cat >exp <<EOF +test_expect_success 'confuses pattern as remote when no remote specified' ' + '" + cat >exp <<-EOF fatal: 'refs*master' does not appear to be a git repository fatal: The remote end hung up unexpectedly EOF -test_expect_success 'confuses pattern as remote when no remote specified' ' + "' # # Do not expect "git ls-remote <pattern>" to work; ls-remote, correctly, # confuses <pattern> for <remote>. Although ugly, this behaviour is akin @@ -124,7 +134,7 @@ test_expect_success 'confuses pattern as remote when no remote specified' ' ' test_expect_success 'die with non-2 for wrong repository even with --exit-code' ' - git ls-remote --exit-code ./no-such-repository ;# not && + silent git ls-remote --exit-code ./no-such-repository ;# not && status=$? && test $status != 2 && test $status != 0 ' @@ -136,7 +146,8 @@ test_expect_success 'Report success even when nothing matches' ' ' test_expect_success 'Report no-match with --exit-code' ' - test_expect_code 2 git ls-remote --exit-code other.git "refs/nsn/*" >actual && + test_expect_code 2 git ls-remote --exit-code other.git "refs/nsn/*" \ + >actual && >expect && test_cmp expect actual ' -- 1.7.8 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html