t3416: set $EDITOR in subshell

As $EDITOR is exported, setting it in one test affects all subsequent tests. Avoid this by always setting it in a subshell. Also remove a couple of unnecessary call to set_fake_editor where the editor does not change the todo list. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Phillip Wood committed Oct 17, 2022 at 13:17 UTC 05ec41855da2ba813e6cfb5fb1fb86aea623addc
1 file changed +21 -10
t/t3416-rebase-onto-threedots.sh
+21 -10
@@ -79,8 +79,10 @@ test_expect_success 'rebase -i --onto main...topic' '
79 git reset --hard &&
80 git checkout topic &&
81 git reset --hard G &&
82 - set_fake_editor &&
83 - EXPECT_COUNT=1 git rebase -i --onto main...topic F &&
82 + (
83 + set_fake_editor &&
84 + EXPECT_COUNT=1 git rebase -i --onto main...topic F
85 + ) &&
86 git rev-parse HEAD^1 >actual &&
87 git rev-parse C^0 >expect &&
88 test_cmp expect actual
@@ -90,8 +92,10 @@ test_expect_success 'rebase -i --onto main...' '
92 git reset --hard &&
93 git checkout topic &&
94 git reset --hard G &&
93 - set_fake_editor &&
94 - EXPECT_COUNT=1 git rebase -i --onto main... F &&
95 + (
96 + set_fake_editor &&
97 + EXPECT_COUNT=1 git rebase -i --onto main... F
98 + ) &&
99 git rev-parse HEAD^1 >actual &&
100 git rev-parse C^0 >expect &&
101 test_cmp expect actual
@@ -102,7 +106,6 @@ test_expect_success 'rebase --onto main...side requires a single merge-base' '
106 git checkout side &&
107 git reset --hard K &&
108
105 - set_fake_editor &&
109 test_must_fail git rebase -i --onto main...side J 2>err &&
110 grep "need exactly one merge base" err
111 '
@@ -157,8 +160,10 @@ test_expect_success 'rebase -i --keep-base main from topic' '
160 git checkout topic &&
161 git reset --hard G &&
162
160 - set_fake_editor &&
161 - EXPECT_COUNT=2 git rebase -i --keep-base main &&
163 + (
164 + set_fake_editor &&
165 + EXPECT_COUNT=2 git rebase -i --keep-base main
166 + ) &&
167 git rev-parse C >base.expect &&
168 git merge-base main HEAD >base.actual &&
169 test_cmp base.expect base.actual &&
@@ -172,8 +177,10 @@ test_expect_success 'rebase -i --keep-base main topic from main' '
177 git checkout main &&
178 git branch -f topic G &&
179
175 - set_fake_editor &&
176 - EXPECT_COUNT=2 git rebase -i --keep-base main topic &&
180 + (
181 + set_fake_editor &&
182 + EXPECT_COUNT=2 git rebase -i --keep-base main topic
183 + ) &&
184 git rev-parse C >base.expect &&
185 git merge-base main HEAD >base.actual &&
186 test_cmp base.expect base.actual &&
@@ -188,9 +195,13 @@ test_expect_success 'rebase --keep-base requires a single merge base' '
195 git checkout side &&
196 git reset --hard K &&
197
191 - set_fake_editor &&
198 test_must_fail git rebase -i --keep-base main 2>err &&
199 grep "need exactly one merge base with branch" err
200 '
201
202 +# This must be the last test in this file
203 +test_expect_success '$EDITOR and friends are unchanged' '
204 + test_editor_unchanged
205 +'
206 +
207 test_done