Skip to content

Commit

Permalink
t4202: use test_config/test_unconfig to set/unset git config variables
Browse files Browse the repository at this point in the history
Instead of using construct such as:
    test_when_finished "git config --unset <key>"
    git config <key> <value>
uses
    test_config <key> <value>
The latter takes care of removing <key> at the end of the test.

Additionally, instead of
     git config <key> ""
or
     git config --unset <key>
uses
     test_unconfig <key>
The latter doesn't failed if <key> is not defined.

Tests are modified to assume correct (default) configuration at entry,
and to reset the modified configuration variables at the end.

Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Yann Droneaud authored and Junio C Hamano committed Mar 25, 2013
1 parent ff73aa4 commit 90e76b7
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions t/t4202-log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,6 @@ test_expect_success 'log --graph with merge' '
'

test_expect_success 'log.decorate configuration' '
test_might_fail git config --unset-all log.decorate &&
git log --oneline >expect.none &&
git log --oneline --decorate >expect.short &&
git log --oneline --decorate=full >expect.full &&
Expand All @@ -429,61 +427,55 @@ test_expect_success 'log.decorate configuration' '
git log --oneline >actual &&
test_cmp expect.short actual &&
git config --unset-all log.decorate &&
git config log.decorate true &&
test_config log.decorate true &&
git log --oneline >actual &&
test_cmp expect.short actual &&
git log --oneline --decorate=full >actual &&
test_cmp expect.full actual &&
git log --oneline --decorate=no >actual &&
test_cmp expect.none actual &&
git config --unset-all log.decorate &&
git config log.decorate no &&
test_config log.decorate no &&
git log --oneline >actual &&
test_cmp expect.none actual &&
git log --oneline --decorate >actual &&
test_cmp expect.short actual &&
git log --oneline --decorate=full >actual &&
test_cmp expect.full actual &&
git config --unset-all log.decorate &&
git config log.decorate 1 &&
test_config log.decorate 1 &&
git log --oneline >actual &&
test_cmp expect.short actual &&
git log --oneline --decorate=full >actual &&
test_cmp expect.full actual &&
git log --oneline --decorate=no >actual &&
test_cmp expect.none actual &&
git config --unset-all log.decorate &&
git config log.decorate short &&
test_config log.decorate short &&
git log --oneline >actual &&
test_cmp expect.short actual &&
git log --oneline --no-decorate >actual &&
test_cmp expect.none actual &&
git log --oneline --decorate=full >actual &&
test_cmp expect.full actual &&
git config --unset-all log.decorate &&
git config log.decorate full &&
test_config log.decorate full &&
git log --oneline >actual &&
test_cmp expect.full actual &&
git log --oneline --no-decorate >actual &&
test_cmp expect.none actual &&
git log --oneline --decorate >actual &&
test_cmp expect.short actual
git config --unset-all log.decorate &&
test_unconfig log.decorate &&
git log --pretty=raw >expect.raw &&
git config log.decorate full &&
test_config log.decorate full &&
git log --pretty=raw >actual &&
test_cmp expect.raw actual
'

test_expect_success 'reflog is expected format' '
test_might_fail git config --remove-section log &&
git log -g --abbrev-commit --pretty=oneline >expect &&
git reflog >actual &&
test_cmp expect actual
Expand All @@ -496,10 +488,6 @@ test_expect_success 'whatchanged is expected format' '
'

test_expect_success 'log.abbrevCommit configuration' '
test_when_finished "git config --unset log.abbrevCommit" &&
test_might_fail git config --unset log.abbrevCommit &&
git log --abbrev-commit >expect.log.abbrev &&
git log --no-abbrev-commit >expect.log.full &&
git log --pretty=raw >expect.log.raw &&
Expand All @@ -508,7 +496,7 @@ test_expect_success 'log.abbrevCommit configuration' '
git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
git config log.abbrevCommit true &&
test_config log.abbrevCommit true &&
git log >actual &&
test_cmp expect.log.abbrev actual &&
Expand Down

0 comments on commit 90e76b7

Please sign in to comment.