git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Phillip Wood <phillip.wood@talktalk.net>
To: Junio C Hamano <gitster@pobox.com>,
	Eric Sunshine <sunshine@sunshineco.com>
Cc: Phillip Wood <phillip.wood@dunelm.org.uk>,
	Git Mailing List <git@vger.kernel.org>,
	"Brian M. Carlson" <sandals@crustytoothpaste.net>
Subject: Re: [PATCH v2 3/9] t3701: use test_write_lines and write_script
Date: Wed, 21 Feb 2018 11:26:30 +0000	[thread overview]
Message-ID: <372bd26b-4e95-3f82-a1b1-dd0191568503@talktalk.net> (raw)
In-Reply-To: <xmqqr2pf4m0l.fsf@gitster-ct.c.googlers.com>

On 20/02/18 17:19, Junio C Hamano wrote:
> Eric Sunshine <sunshine@sunshineco.com> writes:
> 
>>>   test_expect_success 'setup fake editor' '
>>> -       echo "#!$SHELL_PATH" >fake_editor.sh &&
>>> -       cat >>fake_editor.sh <<-\EOF &&
>>> +       FAKE_EDITOR="$(pwd)/fake-editor.sh" &&
>>> +       write_script "$FAKE_EDITOR" <<-\EOF &&
>>>          mv -f "$1" oldpatch &&
>>>          mv -f patch "$1"
>>>          EOF
>>> -       chmod a+x fake_editor.sh &&
>>> -       test_set_editor "$(pwd)/fake_editor.sh"
>>> +       test_set_editor "$FAKE_EDITOR"
>>>   '
>>
>> The very first thing that test_set_editor() does is set FAKE_EDITOR to
>> the value of $1, so it is confusing to see it getting setting it here
>> first; the reader has to spend extra brain cycles wondering if
>> something non-obvious is going on that requires this manual
>> assignment. Perhaps drop the assignment altogether and just write
>> literal "fake_editor.sh" in the couple places it's needed (as was done
>> in the original code)?
> 
> Yeah, I think $(pwd)/ prefix is needed at the final step (i.e. as
> the first argument to test_set_editor) for this to be a faithful
> rewrite but it is distracting having to write it anywhere else.
> 
> Other than that, this looks like a quite straight-forward cleanup.
> 
> Thanks, both.  Here is what I'd be queuing tentatively.

That looks good, thanks for fixing it up

Phillip
> 
>   t/t3701-add-interactive.sh | 33 +++++----------------------------
>   1 file changed, 5 insertions(+), 28 deletions(-)
> 
> diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
> index 39c7423069..4a369fcb51 100755
> --- a/t/t3701-add-interactive.sh
> +++ b/t/t3701-add-interactive.sh
> @@ -87,13 +87,8 @@ test_expect_success 'setup expected' '
>   	EOF
>   '
>   
> -test_expect_success 'setup fake editor' '
> -	>fake_editor.sh &&
> -	chmod a+x fake_editor.sh &&
> -	test_set_editor "$(pwd)/fake_editor.sh"
> -'
> -
>   test_expect_success 'dummy edit works' '
> +	test_set_editor : &&
>   	(echo e; echo a) | git add -p &&
>   	git diff > diff &&
>   	test_cmp expected diff
> @@ -110,12 +105,10 @@ test_expect_success 'setup patch' '
>   '
>   
>   test_expect_success 'setup fake editor' '
> -	echo "#!$SHELL_PATH" >fake_editor.sh &&
> -	cat >>fake_editor.sh <<-\EOF &&
> +	write_script "fake_editor.sh" <<-\EOF &&
>   	mv -f "$1" oldpatch &&
>   	mv -f patch "$1"
>   	EOF
> -	chmod a+x fake_editor.sh &&
>   	test_set_editor "$(pwd)/fake_editor.sh"
>   '
>   
> @@ -302,18 +295,12 @@ test_expect_success 'deleting an empty file' '
>   
>   test_expect_success 'split hunk setup' '
>   	git reset --hard &&
> -	for i in 10 20 30 40 50 60
> -	do
> -		echo $i
> -	done >test &&
> +	test_write_lines 10 20 30 40 50 60 >test &&
>   	git add test &&
>   	test_tick &&
>   	git commit -m test &&
>   
> -	for i in 10 15 20 21 22 23 24 30 40 50 60
> -	do
> -		echo $i
> -	done >test
> +	test_write_lines 10 15 20 21 22 23 24 30 40 50 60 >test
>   '
>   
>   test_expect_success 'split hunk "add -p (edit)"' '
> @@ -334,17 +321,7 @@ test_expect_success 'split hunk "add -p (edit)"' '
>   '
>   
>   test_expect_failure 'split hunk "add -p (no, yes, edit)"' '
> -	cat >test <<-\EOF &&
> -	5
> -	10
> -	20
> -	21
> -	30
> -	31
> -	40
> -	50
> -	60
> -	EOF
> +	test_write_lines 5 10 20 21 30 31 40 50 60 >test &&
>   	git reset &&
>   	# test sequence is s(plit), n(o), y(es), e(dit)
>   	# q n q q is there to make sure we exit at the end.
> 


  reply	other threads:[~2018-02-21 11:26 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-13 10:44 [PATCH 0/4] Correct offsets of hunks when one is skipped Phillip Wood
2018-02-13 10:44 ` [PATCH 1/4] add -i: add function to format hunk header Phillip Wood
2018-02-13 10:44 ` [PATCH 2/4] t3701: add failing test for pathological context lines Phillip Wood
2018-02-13 20:35   ` Junio C Hamano
2018-02-13 10:44 ` [PATCH 3/4] add -p: Adjust offsets of subsequent hunks when one is skipped Phillip Wood
2018-02-13 10:44 ` [PATCH 4/4] add -p: calculate offset delta for edited patches Phillip Wood
2018-02-13 23:56 ` [PATCH 0/4] Correct offsets of hunks when one is skipped brian m. carlson
2018-02-19 13:01   ` Phillip Wood
2018-02-19 11:29 ` [PATCH v2 0/9] " Phillip Wood
2018-02-19 11:29   ` [PATCH v2 1/9] add -i: add function to format hunk header Phillip Wood
2018-02-20 18:21     ` Junio C Hamano
2018-02-19 11:29   ` [PATCH v2 2/9] t3701: indent here documents Phillip Wood
2018-02-19 18:36     ` Eric Sunshine
2018-02-19 11:29   ` [PATCH v2 3/9] t3701: use test_write_lines and write_script Phillip Wood
2018-02-19 18:47     ` Eric Sunshine
2018-02-20 17:19       ` Junio C Hamano
2018-02-21 11:26         ` Phillip Wood [this message]
2018-02-19 11:29   ` [PATCH v2 4/9] t3701: don't hard code sha1 hash values Phillip Wood
2018-02-19 18:52     ` Eric Sunshine
2018-02-20 17:39     ` Junio C Hamano
2018-02-21 11:42       ` Phillip Wood
2018-02-21 16:58         ` Junio C Hamano
2018-02-19 11:29   ` [PATCH v2 5/9] t3701: add failing test for pathological context lines Phillip Wood
2018-02-21 11:28     ` Phillip Wood
2018-02-19 11:29   ` [PATCH v2 6/9] add -p: Adjust offsets of subsequent hunks when one is skipped Phillip Wood
2018-02-19 11:29   ` [PATCH v2 7/9] add -p: calculate offset delta for edited patches Phillip Wood
2018-02-19 11:29   ` [PATCH v2 8/9] add -p: fix counting when splitting and coalescing Phillip Wood
2018-02-19 11:29   ` [PATCH v2 9/9] add -p: don't rely on apply's '--recount' option Phillip Wood
2018-02-20 18:50     ` Junio C Hamano
2018-02-27 11:03 ` [PATCH v3 0/9] Correct offsets of hunks when one is skipped Phillip Wood
2018-02-27 11:03   ` [PATCH v3 1/9] add -i: add function to format hunk header Phillip Wood
2018-02-27 11:03   ` [PATCH v3 2/9] t3701: indent here documents Phillip Wood
2018-02-27 22:35     ` Junio C Hamano
2018-02-28 11:00       ` Phillip Wood
2018-02-28 15:37         ` Junio C Hamano
2018-03-01 10:57           ` Phillip Wood
2018-03-01 15:58             ` Junio C Hamano
2018-02-27 11:03   ` [PATCH v3 3/9] t3701: use test_write_lines and write_script Phillip Wood
2018-02-27 11:03   ` [PATCH v3 4/9] t3701: don't hard code sha1 hash values Phillip Wood
2018-02-27 22:42     ` Junio C Hamano
2018-02-28 11:03       ` Phillip Wood
2018-02-28 11:10         ` Phillip Wood
2018-02-27 11:04   ` [PATCH v3 5/9] t3701: add failing test for pathological context lines Phillip Wood
2018-02-27 11:04   ` [PATCH v3 6/9] add -p: Adjust offsets of subsequent hunks when one is skipped Phillip Wood
2018-02-27 11:04   ` [PATCH v3 7/9] add -p: calculate offset delta for edited patches Phillip Wood
2018-02-27 11:04   ` [PATCH v3 8/9] add -p: fix counting when splitting and coalescing Phillip Wood
2018-02-27 11:04   ` [PATCH v3 9/9] add -p: don't rely on apply's '--recount' option Phillip Wood
2018-03-01 10:50 ` [PATCH v4 0/9] Correct offsets of hunks when one is skipped Phillip Wood
2018-03-01 10:50   ` [PATCH v4 1/9] add -i: add function to format hunk header Phillip Wood
2018-03-01 10:50   ` [PATCH v4 2/9] t3701: indent here documents Phillip Wood
2018-03-01 10:50   ` [PATCH v4 3/9] t3701: use test_write_lines and write_script Phillip Wood
2018-03-01 10:50   ` [PATCH v4 4/9] t3701: don't hard code sha1 hash values Phillip Wood
2018-03-02 15:55     ` SZEDER Gábor
2018-03-02 16:09       ` Junio C Hamano
2018-03-05 10:59         ` Phillip Wood
2018-03-05 12:32           ` SZEDER Gábor
2018-03-01 10:50   ` [PATCH v4 5/9] t3701: add failing test for pathological context lines Phillip Wood
2018-03-01 10:51   ` [PATCH v4 6/9] add -p: adjust offsets of subsequent hunks when one is skipped Phillip Wood
2018-03-01 10:51   ` [PATCH v4 7/9] add -p: calculate offset delta for edited patches Phillip Wood
2018-03-01 20:14     ` Junio C Hamano
2018-03-02 10:36       ` Phillip Wood
2018-03-01 10:51   ` [PATCH v4 8/9] add -p: fix counting when splitting and coalescing Phillip Wood
2018-03-01 20:29     ` Junio C Hamano
2018-03-02 10:48       ` Phillip Wood
2018-03-01 10:51   ` [PATCH v4 9/9] add -p: don't rely on apply's '--recount' option Phillip Wood
2018-03-01 20:30     ` Junio C Hamano
2018-03-02 10:49       ` Phillip Wood
2018-03-05 10:56 ` [PATCH v5 0/9] Correct offsets of hunks when one is skipped Phillip Wood
2018-03-05 10:56   ` [PATCH v5 1/9] add -i: add function to format hunk header Phillip Wood
2018-03-05 10:56   ` [PATCH v5 2/9] t3701: indent here documents Phillip Wood
2018-03-05 10:56   ` [PATCH v5 3/9] t3701: use test_write_lines and write_script Phillip Wood
2018-03-05 10:56   ` [PATCH v5 4/9] t3701: don't hard code sha1 hash values Phillip Wood
2018-03-05 10:56   ` [PATCH v5 5/9] t3701: add failing test for pathological context lines Phillip Wood
2018-03-05 10:56   ` [PATCH v5 6/9] add -p: adjust offsets of subsequent hunks when one is skipped Phillip Wood
2018-03-05 10:56   ` [PATCH v5 7/9] add -p: calculate offset delta for edited patches Phillip Wood
2018-03-05 10:56   ` [PATCH v5 8/9] add -p: fix counting when splitting and coalescing Phillip Wood
2018-03-05 10:56   ` [PATCH v5 9/9] add -p: don't rely on apply's '--recount' option Phillip Wood
2018-03-05 18:50   ` [PATCH v5 0/9] Correct offsets of hunks when one is skipped Junio C Hamano
2018-03-06 10:25     ` Phillip Wood

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=372bd26b-4e95-3f82-a1b1-dd0191568503@talktalk.net \
    --to=phillip.wood@talktalk.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=phillip.wood@dunelm.org.uk \
    --cc=sandals@crustytoothpaste.net \
    --cc=sunshine@sunshineco.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).