From: Eric Sunshine <sunshine@sunshineco.com>
To: David Tran <unsignedzero@gmail.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH v2] tests: set temp variables using 'env' in test function instead of subshell
Date: Tue, 18 Mar 2014 16:52:46 -0400 [thread overview]
Message-ID: <CAPig+cS5UDxvCGRm4d840tOfG6pwjHbARuyAWOR+D_Aht79Gzw@mail.gmail.com> (raw)
In-Reply-To: <1395144518-2489-1-git-send-email-unsignedzero@gmail.com>
On Tue, Mar 18, 2014 at 8:08 AM, David Tran <unsignedzero@gmail.com> wrote:
> Originally, the code used subshells instead of FOO=BAR command because
> the variable would otherwise leak into the surrounding context of the POSIX
> shell when 'command' is a shell function. The subshell was used to hold the
> context for the test. Using 'env' in the test function sets the temp variables
> without leaking, removing the need of a subshell.
>
> Signed-off-by: David Tran <unsignedzero@gmail.com>
> ---
>> Oh, really ;-)?
> Missed that.
>
>> Thanks. Getting closer, I think.
> Slowly but surely.
Getting better. See below.
> Signed-off-by: David Tran <unsignedzero@gmail.com>
> ---
> diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
> index 50e22b1..4c7364a 100755
> --- a/t/t3404-rebase-interactive.sh
> +++ b/t/t3404-rebase-interactive.sh
> @@ -104,9 +104,7 @@ test_expect_success 'rebase -i with the exec command checks tree cleanness' '
> git checkout master &&
> (
> set_fake_editor &&
> - FAKE_LINES="exec_echo_foo_>file1 1" &&
> - export FAKE_LINES &&
> - test_must_fail git rebase -i HEAD^
> + test_must_fail env FAKE_LINES="exec_echo_foo_>file1 1" git rebase -i HEAD^
> ) &&
In a previous review, I asked if this subshell could be dropped or if
it was required for set_fake_editor. I didn't quite understand your
response, so I tested it myself, and found that the subshell can be
eliminated safely without breaking this or later tests.
> test_cmp_rev master^ HEAD &&
> git reset --hard &&
> @@ -118,9 +116,8 @@ test_expect_success 'rebase -i with exec of inexistent command' '
> test_when_finished "git rebase --abort" &&
> (
> set_fake_editor &&
> - FAKE_LINES="exec_this-command-does-not-exist 1" &&
> - export FAKE_LINES &&
> - test_must_fail git rebase -i HEAD^ >actual 2>&1
> + test_must_fail env FAKE_LINES="exec_this-command-does-not-exist 1" \
> + git rebase -i HEAD^ >actual 2>&1
> ) &&
Ditto for this subshell.
> ! grep "Maybe git-rebase is broken" actual
> '
> @@ -528,11 +509,7 @@ test_expect_success 'aborted --continue does not squash commits after "edit"' '
> FAKE_LINES="edit 1" git rebase -i HEAD^ &&
> echo "edited again" > file7 &&
> git add file7 &&
> - (
> - FAKE_COMMIT_MESSAGE=" " &&
> - export FAKE_COMMIT_MESSAGE &&
> - test_must_fail git rebase --continue
> - ) &&
> + test_must_fail env FAKE_COMMIT_MESSAGE=" " git rebase --continue
Broken &&-chain.
> test $old = $(git rev-parse HEAD) &&
> git rebase --abort
> '
prev parent reply other threads:[~2014-03-18 20:52 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <244284@gmane.comp.version-control.git>
2014-03-18 12:08 ` [PATCH v2] tests: set temp variables using 'env' in test function instead of subshell David Tran
2014-03-18 20:37 ` Junio C Hamano
2014-03-18 21:45 ` Jeff King
2014-03-18 22:16 ` Junio C Hamano
2014-03-18 23:06 ` Jeff King
2014-03-19 17:28 ` Junio C Hamano
2014-03-20 23:11 ` [PATCH 0/12] GIT_CONFIG in the test suite Jeff King
2014-03-20 23:13 ` [PATCH 01/12] t/Makefile: stop setting GIT_CONFIG Jeff King
2014-03-20 23:13 ` [PATCH 02/12] t/test-lib: drop redundant unset of GIT_CONFIG Jeff King
2014-03-20 23:14 ` [PATCH 03/12] t: drop useless sane_unset GIT_* calls Jeff King
2014-03-21 21:24 ` Junio C Hamano
2014-03-24 21:56 ` Jeff King
2014-03-24 22:06 ` Junio C Hamano
2014-03-25 4:56 ` Junio C Hamano
2014-03-20 23:15 ` [PATCH 04/12] t: stop using GIT_CONFIG to cross repo boundaries Jeff King
2014-03-21 21:26 ` Junio C Hamano
2014-03-24 22:00 ` Jeff King
2014-03-20 23:15 ` [PATCH 05/12] t: prefer "git config --file" to GIT_CONFIG with test_must_fail Jeff King
2014-03-20 23:17 ` [PATCH 06/12] t: prefer "git config --file" to GIT_CONFIG Jeff King
2014-03-20 23:17 ` [PATCH 07/12] t0001: make symlink reinit test more careful Jeff King
2014-03-20 23:17 ` [PATCH 08/12] t0001: use test_path_is_* Jeff King
2014-03-20 23:18 ` [PATCH 09/12] t0001: use test_config_global Jeff King
2014-03-20 23:19 ` [PATCH 10/12] t0001: use test_must_fail Jeff King
2014-03-20 23:21 ` [PATCH 11/12] t0001: drop useless subshells Jeff King
2014-03-21 20:27 ` Eric Sunshine
2014-03-20 23:23 ` [PATCH 12/12] t0001: drop subshells just for "cd" Jeff King
2014-03-18 22:36 ` [PATCH v2] tests: set temp variables using 'env' in test function instead of subshell Eric Sunshine
2014-03-18 20:52 ` Eric Sunshine [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPig+cS5UDxvCGRm4d840tOfG6pwjHbARuyAWOR+D_Aht79Gzw@mail.gmail.com \
--to=sunshine@sunshineco.com \
--cc=git@vger.kernel.org \
--cc=unsignedzero@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).