t1300-repo-config: make it resilient to being run via 'sh -x'

One way to diagnose broken regression tests is to run the test
script using 'sh -x t... -i -v' to find out which call actually
demonstrates the symptom.

Hence it is pretty counterproductive if the test script behaves
differently when being run via 'sh -x', in particular when using
test_cmp or test_i18ncmp on redirected stderr.  A more recent way
"sh tXXXX -i -v -x" has the same issue.

So let's use test_i18ngrep (as suggested by Jonathan Nieder) instead of
test_cmp/test_i18ncmp to verify that stderr looks as expected.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Johannes Schindelin 2016-03-23 11:55:07 +01:00 committed by Junio C Hamano
parent 5ca6b7bb47
commit 2ec20212c5

View File

@ -699,17 +699,13 @@ test_expect_success 'invalid unit' '
echo 1auto >expect && echo 1auto >expect &&
git config aninvalid.unit >actual && git config aninvalid.unit >actual &&
test_cmp expect actual && test_cmp expect actual &&
cat >expect <<-\EOF &&
fatal: bad numeric config value '\''1auto'\'' for '\''aninvalid.unit'\'' in file .git/config: invalid unit
EOF
test_must_fail git config --int --get aninvalid.unit 2>actual && test_must_fail git config --int --get aninvalid.unit 2>actual &&
test_i18ncmp expect actual test_i18ngrep "bad numeric config value .1auto. for .aninvalid.unit. in file .git/config: invalid unit" actual
' '
test_expect_success 'invalid stdin config' ' test_expect_success 'invalid stdin config' '
echo "fatal: bad config line 1 in standard input " >expect &&
echo "[broken" | test_must_fail git config --list --file - >output 2>&1 && echo "[broken" | test_must_fail git config --list --file - >output 2>&1 &&
test_cmp expect output test_i18ngrep "bad config line 1 in standard input" output
' '
cat > expect << EOF cat > expect << EOF