t7502: perform commits using alternate editor in a subshell
These tests call test_set_editor to set an alternate editor script, but they appear to presume that the assignment is of a temporary nature and will not have any effect outside of each individual test. That is not the case. All of the test functions within a test script share a single environment, so any variables modified in one, are visible in the ones that follow. So, let's protect the test functions that follow these, which set an alternate editor, by performing the test_set_editor and 'git commit' in a subshell. Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Casey committed
Feb 22, 2013 at 15:13 UTC
24e099f475692059dc2cb0c1c0d1a74a3fde8ac6
1 file changed
+16
-8
t/t7502-commit.sh
+16
-8
@@ -255,32 +255,40 @@ test_expect_success 'cleanup commit message (fail on invalid cleanup mode config
255
test_expect_success 'cleanup commit message (no config and no option uses default)' '
256
echo content >>file &&
257
git add file &&
258
- test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
259
- git commit --no-status &&
258
+ (
259
+ test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
260
+ git commit --no-status
261
+ ) &&
262
commit_msg_is "commit message"
263
'
264
265
test_expect_success 'cleanup commit message (option overrides default)' '
266
echo content >>file &&
267
git add file &&
266
- test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
267
- git commit --cleanup=whitespace --no-status &&
268
+ (
269
+ test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
270
+ git commit --cleanup=whitespace --no-status
271
+ ) &&
272
commit_msg_is "commit message # comment"
273
'
274
275
test_expect_success 'cleanup commit message (config overrides default)' '
276
echo content >>file &&
277
git add file &&
274
- test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
275
- git -c commit.cleanup=whitespace commit --no-status &&
278
+ (
279
+ test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
280
+ git -c commit.cleanup=whitespace commit --no-status
281
+ ) &&
282
commit_msg_is "commit message # comment"
283
'
284
285
test_expect_success 'cleanup commit message (option overrides config)' '
286
echo content >>file &&
287
git add file &&
282
- test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
283
- git -c commit.cleanup=whitespace commit --cleanup=default &&
288
+ (
289
+ test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
290
+ git -c commit.cleanup=whitespace commit --cleanup=default
291
+ ) &&
292
commit_msg_is "commit message"
293
'
294