Skip to content

Commit 079b087

Browse files
sunshinecogitster
authored andcommitted
t6046/t9833: fix use of "VAR=VAL cmd" with a shell function
Unlike "FOO=bar cmd" one-shot environment variable assignments which exist only for the invocation of 'cmd', those assigned by "FOO=bar shell_func" exist within the running shell and continue to do so until the process exits (or are explicitly unset). It is unlikely that this behavior was intended by the test author. In these particular tests, the "FOO=bar shell_func" invocations are already in subshells, so the assignments don't last too long, don't appear to harm subsequent commands in the same subshells, and don't affect other tests in the same scripts, however, the usage is nevertheless misleading and poor practice, so fix the tests to assign and export the environment variables in the usual fashion. Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f44a744 commit 079b087

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

t/t6046-merge-skip-unneeded-updates.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,9 @@ test_expect_success '2c-check: Modify b & add c VS rename b->c' '
366366
367367
git checkout A^0 &&
368368
369-
GIT_MERGE_VERBOSITY=3 test_must_fail git merge -s recursive B^0 >out 2>err &&
369+
GIT_MERGE_VERBOSITY=3 &&
370+
export GIT_MERGE_VERBOSITY &&
371+
test_must_fail git merge -s recursive B^0 >out 2>err &&
370372
371373
test_i18ngrep "CONFLICT (rename/add): Rename b->c" out &&
372374
test_i18ngrep ! "Skipped c" out &&

t/t9833-errors.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ test_expect_success 'error handling' '
2626
) &&
2727
p4 passwd -P newpassword &&
2828
(
29-
P4PASSWD=badpassword test_must_fail git p4 clone //depot/foo 2>errmsg &&
29+
P4PASSWD=badpassword &&
30+
export P4PASSWD &&
31+
test_must_fail git p4 clone //depot/foo 2>errmsg &&
3032
grep -q "failure accessing depot.*P4PASSWD" errmsg
3133
)
3234
'

0 commit comments

Comments
 (0)