diff mbox series

[v3,6/7] t3701-add-interactive: test add_i_show_help()

Message ID aede733318bb6fccc1c3d16adf442135d3cb0692.1548062019.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series Turn git add-i into built-in | expand

Commit Message

Bruce Perry via GitGitGadget Jan. 21, 2019, 9:13 a.m. UTC
From: Slavica Djukic <slawica92@hotmail.com>

Add test to t3701-add-interactive to verify that add_i_show_help()
outputs expected content.
Also, add it before changing git-add--interactive.perl's help_cmd
to demonstrate that there are no changes introduced by the
conversion to C.
Prefix git add -i call with GIT_PAGER_IN_USE=true TERM=vt100
to force colored output on Windows.

Signed-off-by: Slavica Djukic <slawica92@hotmail.com>
---
 t/t3701-add-interactive.sh | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Comments

Phillip Wood Jan. 25, 2019, 11:01 a.m. UTC | #1
Hi Slavica

Having suggested that you move this patch up the series, I thought I
should check that it does actually pass before the rewrite.
Unfortunately when I run it it fails, but it is due to a missing
trailing space in the expected file. I get

--- expect	2019-01-25 10:42:06.794251740 +0000
+++ actual	2019-01-25 10:42:07.044127788 +0000
@@ -11,5 +11,5 @@
 <BOLD>*** Commands ***<RESET>
   1: <BOLD;BLUE>s<RESET>tatus	  2: <BOLD;BLUE>u<RESET>pdate	  3:
<BOLD;BLUE>r<RESET>evert	  4: <BOLD;BLUE>a<RESET>dd untracked
   5: <BOLD;BLUE>p<RESET>atch	  6: <BOLD;BLUE>d<RESET>iff	  7:
<BOLD;BLUE>q<RESET>uit	  8: <BOLD;BLUE>h<RESET>elp
-<BOLD;BLUE>What now<RESET>>
+<BOLD;BLUE>What now<RESET>>
 Bye.

There should be a space after '<BOLD;BLUE>What now<RESET>>' as the
prompt has a space after it. The space is actually in the patch but it
got eaten by 'git am' (I have core.whitespace set but I think cleaning
up trailing whitespace is on by default anyway). I think the best way to
make this patch easier to apply would be to use '$SP' which is already
set up in earlier tests to avoid trailing whitespace in here documents.
You'll need to change
cat >expect <<-\EOF
to
cat >expect <<-EOF
to enable variable interpolation in the here document as well.

Best Wishes

Phillip


On 21/01/2019 09:13, Slavica Djukic via GitGitGadget wrote:
> From: Slavica Djukic <slawica92@hotmail.com>
> 
> Add test to t3701-add-interactive to verify that add_i_show_help()
> outputs expected content.
> Also, add it before changing git-add--interactive.perl's help_cmd
> to demonstrate that there are no changes introduced by the
> conversion to C.
> Prefix git add -i call with GIT_PAGER_IN_USE=true TERM=vt100
> to force colored output on Windows.
> 
> Signed-off-by: Slavica Djukic <slawica92@hotmail.com>
> ---
>  t/t3701-add-interactive.sh | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
> index 65dfbc033a..14e3286995 100755
> --- a/t/t3701-add-interactive.sh
> +++ b/t/t3701-add-interactive.sh
> @@ -639,4 +639,28 @@ test_expect_success 'add -p patch editing works with pathological context lines'
>  	test_cmp expected-2 actual
>  '
>  
> +test_expect_success 'show help from add--helper' '
> +	git reset --hard &&
> +	cat >expect <<-\EOF &&
> +
> +	<BOLD>*** Commands ***<RESET>
> +	  1: <BOLD;BLUE>s<RESET>tatus	  2: <BOLD;BLUE>u<RESET>pdate	  3: <BOLD;BLUE>r<RESET>evert	  4: <BOLD;BLUE>a<RESET>dd untracked
> +	  5: <BOLD;BLUE>p<RESET>atch	  6: <BOLD;BLUE>d<RESET>iff	  7: <BOLD;BLUE>q<RESET>uit	  8: <BOLD;BLUE>h<RESET>elp
> +	<BOLD;BLUE>What now<RESET>> <BOLD;RED>status        - show paths with changes<RESET>
> +	<BOLD;RED>update        - add working tree state to the staged set of changes<RESET>
> +	<BOLD;RED>revert        - revert staged set of changes back to the HEAD version<RESET>
> +	<BOLD;RED>patch         - pick hunks and update selectively<RESET>
> +	<BOLD;RED>diff          - view diff between HEAD and index<RESET>
> +	<BOLD;RED>add untracked - add contents of untracked files to the staged set of changes<RESET>
> +	<BOLD>*** Commands ***<RESET>
> +	  1: <BOLD;BLUE>s<RESET>tatus	  2: <BOLD;BLUE>u<RESET>pdate	  3: <BOLD;BLUE>r<RESET>evert	  4: <BOLD;BLUE>a<RESET>dd untracked
> +	  5: <BOLD;BLUE>p<RESET>atch	  6: <BOLD;BLUE>d<RESET>iff	  7: <BOLD;BLUE>q<RESET>uit	  8: <BOLD;BLUE>h<RESET>elp
> +	<BOLD;BLUE>What now<RESET>> 
> +	Bye.
> +	EOF
> +	test_write_lines h | GIT_PAGER_IN_USE=true TERM=vt100 git add -i >actual.colored &&
> +	test_decode_color <actual.colored >actual &&
> +	test_i18ncmp expect actual
> +'
> +
>  test_done
>
Slavica Djukic Jan. 25, 2019, 11:36 a.m. UTC | #2
Hi Phillip,

On 25-Jan-19 12:01 PM, Phillip Wood wrote:
> Hi Slavica
>
> Having suggested that you move this patch up the series, I thought I
> should check that it does actually pass before the rewrite.
> Unfortunately when I run it it fails, but it is due to a missing
> trailing space in the expected file. I get
>
> --- expect	2019-01-25 10:42:06.794251740 +0000
> +++ actual	2019-01-25 10:42:07.044127788 +0000
> @@ -11,5 +11,5 @@
>   <BOLD>*** Commands ***<RESET>
>     1: <BOLD;BLUE>s<RESET>tatus	  2: <BOLD;BLUE>u<RESET>pdate	  3:
> <BOLD;BLUE>r<RESET>evert	  4: <BOLD;BLUE>a<RESET>dd untracked
>     5: <BOLD;BLUE>p<RESET>atch	  6: <BOLD;BLUE>d<RESET>iff	  7:
> <BOLD;BLUE>q<RESET>uit	  8: <BOLD;BLUE>h<RESET>elp
> -<BOLD;BLUE>What now<RESET>>
> +<BOLD;BLUE>What now<RESET>>
>   Bye.
>
> There should be a space after '<BOLD;BLUE>What now<RESET>>' as the
> prompt has a space after it. The space is actually in the patch but it
> got eaten by 'git am' (I have core.whitespace set but I think cleaning
> up trailing whitespace is on by default anyway). I think the best way to
> make this patch easier to apply would be to use '$SP' which is already
> set up in earlier tests to avoid trailing whitespace in here documents.
> You'll need to change
> cat >expect <<-\EOF
> to
> cat >expect <<-EOF
> to enable variable interpolation in the here document as well.


Thanks for checking the test. I had no idea that this might happen.

I'll send new iteration soon, along with this changes.


-Slavica


>
> Best Wishes
>
> Phillip
>
>
> On 21/01/2019 09:13, Slavica Djukic via GitGitGadget wrote:
>> From: Slavica Djukic <slawica92@hotmail.com>
>>
>> Add test to t3701-add-interactive to verify that add_i_show_help()
>> outputs expected content.
>> Also, add it before changing git-add--interactive.perl's help_cmd
>> to demonstrate that there are no changes introduced by the
>> conversion to C.
>> Prefix git add -i call with GIT_PAGER_IN_USE=true TERM=vt100
>> to force colored output on Windows.
>>
>> Signed-off-by: Slavica Djukic <slawica92@hotmail.com>
>> ---
>>   t/t3701-add-interactive.sh | 24 ++++++++++++++++++++++++
>>   1 file changed, 24 insertions(+)
>>
>> diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
>> index 65dfbc033a..14e3286995 100755
>> --- a/t/t3701-add-interactive.sh
>> +++ b/t/t3701-add-interactive.sh
>> @@ -639,4 +639,28 @@ test_expect_success 'add -p patch editing works with pathological context lines'
>>   	test_cmp expected-2 actual
>>   '
>>   
>> +test_expect_success 'show help from add--helper' '
>> +	git reset --hard &&
>> +	cat >expect <<-\EOF &&
>> +
>> +	<BOLD>*** Commands ***<RESET>
>> +	  1: <BOLD;BLUE>s<RESET>tatus	  2: <BOLD;BLUE>u<RESET>pdate	  3: <BOLD;BLUE>r<RESET>evert	  4: <BOLD;BLUE>a<RESET>dd untracked
>> +	  5: <BOLD;BLUE>p<RESET>atch	  6: <BOLD;BLUE>d<RESET>iff	  7: <BOLD;BLUE>q<RESET>uit	  8: <BOLD;BLUE>h<RESET>elp
>> +	<BOLD;BLUE>What now<RESET>> <BOLD;RED>status        - show paths with changes<RESET>
>> +	<BOLD;RED>update        - add working tree state to the staged set of changes<RESET>
>> +	<BOLD;RED>revert        - revert staged set of changes back to the HEAD version<RESET>
>> +	<BOLD;RED>patch         - pick hunks and update selectively<RESET>
>> +	<BOLD;RED>diff          - view diff between HEAD and index<RESET>
>> +	<BOLD;RED>add untracked - add contents of untracked files to the staged set of changes<RESET>
>> +	<BOLD>*** Commands ***<RESET>
>> +	  1: <BOLD;BLUE>s<RESET>tatus	  2: <BOLD;BLUE>u<RESET>pdate	  3: <BOLD;BLUE>r<RESET>evert	  4: <BOLD;BLUE>a<RESET>dd untracked
>> +	  5: <BOLD;BLUE>p<RESET>atch	  6: <BOLD;BLUE>d<RESET>iff	  7: <BOLD;BLUE>q<RESET>uit	  8: <BOLD;BLUE>h<RESET>elp
>> +	<BOLD;BLUE>What now<RESET>>
>> +	Bye.
>> +	EOF
>> +	test_write_lines h | GIT_PAGER_IN_USE=true TERM=vt100 git add -i >actual.colored &&
>> +	test_decode_color <actual.colored >actual &&
>> +	test_i18ncmp expect actual
>> +'
>> +
>>   test_done
>>
diff mbox series

Patch

diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 65dfbc033a..14e3286995 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -639,4 +639,28 @@  test_expect_success 'add -p patch editing works with pathological context lines'
 	test_cmp expected-2 actual
 '
 
+test_expect_success 'show help from add--helper' '
+	git reset --hard &&
+	cat >expect <<-\EOF &&
+
+	<BOLD>*** Commands ***<RESET>
+	  1: <BOLD;BLUE>s<RESET>tatus	  2: <BOLD;BLUE>u<RESET>pdate	  3: <BOLD;BLUE>r<RESET>evert	  4: <BOLD;BLUE>a<RESET>dd untracked
+	  5: <BOLD;BLUE>p<RESET>atch	  6: <BOLD;BLUE>d<RESET>iff	  7: <BOLD;BLUE>q<RESET>uit	  8: <BOLD;BLUE>h<RESET>elp
+	<BOLD;BLUE>What now<RESET>> <BOLD;RED>status        - show paths with changes<RESET>
+	<BOLD;RED>update        - add working tree state to the staged set of changes<RESET>
+	<BOLD;RED>revert        - revert staged set of changes back to the HEAD version<RESET>
+	<BOLD;RED>patch         - pick hunks and update selectively<RESET>
+	<BOLD;RED>diff          - view diff between HEAD and index<RESET>
+	<BOLD;RED>add untracked - add contents of untracked files to the staged set of changes<RESET>
+	<BOLD>*** Commands ***<RESET>
+	  1: <BOLD;BLUE>s<RESET>tatus	  2: <BOLD;BLUE>u<RESET>pdate	  3: <BOLD;BLUE>r<RESET>evert	  4: <BOLD;BLUE>a<RESET>dd untracked
+	  5: <BOLD;BLUE>p<RESET>atch	  6: <BOLD;BLUE>d<RESET>iff	  7: <BOLD;BLUE>q<RESET>uit	  8: <BOLD;BLUE>h<RESET>elp
+	<BOLD;BLUE>What now<RESET>> 
+	Bye.
+	EOF
+	test_write_lines h | GIT_PAGER_IN_USE=true TERM=vt100 git add -i >actual.colored &&
+	test_decode_color <actual.colored >actual &&
+	test_i18ncmp expect actual
+'
+
 test_done