Felipe Contreras felipe.contre...@gmail.com writes:
After every test the environment should be as close as to how it was
before as possible.
Alternatively, each individual tests in a sequence of tests can
choose to set the test environment to its preferred state before
proceeding.
Starting from a pristine state (i.e. the goal the above aspires to
reach) is probably more desirable, but in practice we could go
either way. In any case we should consistently stick to one inside
a single test.
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
t/t3200-branch.sh | 71
+++
1 file changed, 35 insertions(+), 36 deletions(-)
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 0fe7647..33673e0 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -329,7 +329,7 @@ test_expect_success 'tracking setup fails on non-matching
refspec' '
'
test_expect_success 'test tracking setup via config' '
- git config branch.autosetupmerge true
+ test_config branch.autosetupmerge true
git config remote.local.url .
git config remote.local.fetch refs/heads/*:refs/remotes/local/*
And remote.local.* setting does not follow that pristine
principle, making the result of applying this patch inconsistent.
Is that desirable?
(git show-ref -q refs/remotes/local/master || git fetch local)
@@ -339,20 +339,18 @@ test_expect_success 'test tracking setup via config' '
'
test_expect_success 'test overriding tracking setup via --no-track' '
- git config branch.autosetupmerge true
+ test_config branch.autosetupmerge true
git config remote.local.url .
git config remote.local.fetch refs/heads/*:refs/remotes/local/*
(git show-ref -q refs/remotes/local/master || git fetch local)
git branch --no-track my2 local/master
- git config branch.autosetupmerge false
! test $(git config branch.my2.remote) = local
! test $(git config branch.my2.merge) = refs/heads/master
'
test_expect_success 'no tracking without .fetch entries' '
- git config branch.autosetupmerge true
+ test_config branch.autosetupmerge true
git branch my6 s
- git config branch.autosetupmerge false
test -z $(git config branch.my6.remote)
test -z $(git config branch.my6.merge)
'
@@ -387,9 +385,8 @@ test_expect_success 'test --track without .fetch entries'
'
'
test_expect_success 'branch from non-branch HEAD w/autosetupmerge=always' '
- git config branch.autosetupmerge always
- git branch my9 HEAD^
- git config branch.autosetupmerge false
+ test_config branch.autosetupmerge always
+ git branch my9 HEAD^
'
test_expect_success 'branch from non-branch HEAD w/--track causes failure' '
@@ -406,9 +403,9 @@ test_expect_success '--set-upstream-to fails on multiple
branches' '
'
test_expect_success '--set-upstream-to fails on detached HEAD' '
+ test_when_finished git checkout -
git checkout HEAD^{}
- test_must_fail git branch --set-upstream-to master
- git checkout -
+ test_must_fail git branch --set-upstream-to master
'
test_expect_success '--set-upstream-to fails on a missing dst branch' '
@@ -460,9 +457,9 @@ test_expect_success '--unset-upstream should fail on
multiple branches' '
'
test_expect_success '--unset-upstream should fail on detached HEAD' '
+ test_when_finished git checkout -
git checkout HEAD^{}
- test_must_fail git branch --unset-upstream
- git checkout -
+ test_must_fail git branch --unset-upstream
'
test_expect_success 'test --unset-upstream on a particular branch' '
@@ -541,7 +538,8 @@ test_expect_success 'checkout -b with -l makes reflog
when core.logAllRefUpdates
'
test_expect_success 'avoid ambiguous track' '
- git config branch.autosetupmerge true
+ test_when_finished git remote rm ambi1 git remote rm ambi2
+ test_config branch.autosetupmerge true
git config remote.ambi1.url lalala
git config remote.ambi1.fetch refs/heads/lalala:refs/heads/master
git config remote.ambi2.url lilili
@@ -553,7 +551,7 @@ test_expect_success 'avoid ambiguous track' '
test_expect_success 'autosetuprebase local on a tracked local branch' '
git config remote.local.url .
git config remote.local.fetch refs/heads/*:refs/remotes/local/*
- git config branch.autosetuprebase local
+ test_config branch.autosetuprebase local
(git show-ref -q refs/remotes/local/o || git fetch local)
git branch mybase
git branch --track myr1 mybase
@@ -565,7 +563,7 @@ test_expect_success 'autosetuprebase local on a tracked
local branch' '
test_expect_success 'autosetuprebase always on a tracked local branch' '
git config remote.local.url .
git config remote.local.fetch refs/heads/*:refs/remotes/local/*
- git