git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v2] t4253-am-keep-cr-dos: avoid using pipes
@ 2019-05-05  8:16 Boxuan Li
  2019-05-07  9:04 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Boxuan Li @ 2019-05-05  8:16 UTC (permalink / raw)
  To: git; +Cc: sunshine, Boxuan Li

The exit code of the upstream in a pipe is ignored thus we should avoid
using it. By writing out the output of the git command to a file, we can
test the exit codes of both the commands.

Signed-off-by: Boxuan Li <liboxuan@connect.hku.hk>
---
Thanks to Eric Sunshine's review, I've removed spaces after '>'
and changed 'actual' into 'output'.
---
 t/t4253-am-keep-cr-dos.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/t/t4253-am-keep-cr-dos.sh b/t/t4253-am-keep-cr-dos.sh
index 553fe3e88e..6e1b73ec3a 100755
--- a/t/t4253-am-keep-cr-dos.sh
+++ b/t/t4253-am-keep-cr-dos.sh
@@ -51,14 +51,16 @@ test_expect_success 'am with dos files without --keep-cr' '
 
 test_expect_success 'am with dos files with --keep-cr' '
 	git checkout -b dosfiles-keep-cr initial &&
-	git format-patch -k --stdout initial..master | git am --keep-cr -k -3 &&
+	git format-patch -k --stdout initial..master >output &&
+	git am --keep-cr -k -3 output &&
 	git diff --exit-code master
 '
 
 test_expect_success 'am with dos files config am.keepcr' '
 	git config am.keepcr 1 &&
 	git checkout -b dosfiles-conf-keepcr initial &&
-	git format-patch -k --stdout initial..master | git am -k -3 &&
+	git format-patch -k --stdout initial..master >output &&
+	git am -k -3 output &&
 	git diff --exit-code master
 '
 
-- 
2.21.0.777.g83232e3864


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] t4253-am-keep-cr-dos: avoid using pipes
  2019-05-05  8:16 [PATCH v2] t4253-am-keep-cr-dos: avoid using pipes Boxuan Li
@ 2019-05-07  9:04 ` Junio C Hamano
  2019-05-07 12:42   ` LI, BO XUAN
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2019-05-07  9:04 UTC (permalink / raw)
  To: Boxuan Li; +Cc: git, sunshine

Boxuan Li <liboxuan@connect.hku.hk> writes:

> The exit code of the upstream in a pipe is ignored thus we should avoid
> using it. By writing out the output of the git command to a file, we can
> test the exit codes of both the commands.

We are trying to catch breakages in "am" in these two tests (see the
title of the test file), and we rely on format-patch to correctly
produce its output---if we assume that the command being tested,
i.e. "am", could be fed garbage, the tests become pointless.

And once we decide to rely on the correctness of format-patch in
these two tests, there no longer is a reason to fear that
invocations of it upstream of a pipe would lose the exit status.

So while the patch is not wrong per-se, but these two changes are
borderline Meh.

> Signed-off-by: Boxuan Li <liboxuan@connect.hku.hk>
> ---
> Thanks to Eric Sunshine's review, I've removed spaces after '>'
> and changed 'actual' into 'output'.
> ---
>  t/t4253-am-keep-cr-dos.sh | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/t/t4253-am-keep-cr-dos.sh b/t/t4253-am-keep-cr-dos.sh
> index 553fe3e88e..6e1b73ec3a 100755
> --- a/t/t4253-am-keep-cr-dos.sh
> +++ b/t/t4253-am-keep-cr-dos.sh
> @@ -51,14 +51,16 @@ test_expect_success 'am with dos files without --keep-cr' '
>  
>  test_expect_success 'am with dos files with --keep-cr' '
>  	git checkout -b dosfiles-keep-cr initial &&
> -	git format-patch -k --stdout initial..master | git am --keep-cr -k -3 &&
> +	git format-patch -k --stdout initial..master >output &&
> +	git am --keep-cr -k -3 output &&
>  	git diff --exit-code master
>  '
>  
>  test_expect_success 'am with dos files config am.keepcr' '
>  	git config am.keepcr 1 &&
>  	git checkout -b dosfiles-conf-keepcr initial &&
> -	git format-patch -k --stdout initial..master | git am -k -3 &&
> +	git format-patch -k --stdout initial..master >output &&
> +	git am -k -3 output &&
>  	git diff --exit-code master
>  '

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] t4253-am-keep-cr-dos: avoid using pipes
  2019-05-07  9:04 ` Junio C Hamano
@ 2019-05-07 12:42   ` LI, BO XUAN
  2019-05-08  5:49     ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: LI, BO XUAN @ 2019-05-07 12:42 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, sunshine

Hi Junio,

Thanks for your review! I can understand your point, but I've got a
quick question:

What if format-patch really breaks and 'am' magically does not break?
Then the two tests might still pass. On the contrary, with this patch,
we can verify the correctness of format-patch and safely rely on it.

Best regards,
Boxuan Li

On Tue, May 7, 2019 at 5:04 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Boxuan Li <liboxuan@connect.hku.hk> writes:
>
> > The exit code of the upstream in a pipe is ignored thus we should avoid
> > using it. By writing out the output of the git command to a file, we can
> > test the exit codes of both the commands.
>
> We are trying to catch breakages in "am" in these two tests (see the
> title of the test file), and we rely on format-patch to correctly
> produce its output---if we assume that the command being tested,
> i.e. "am", could be fed garbage, the tests become pointless.
>
> And once we decide to rely on the correctness of format-patch in
> these two tests, there no longer is a reason to fear that
> invocations of it upstream of a pipe would lose the exit status.
>
> So while the patch is not wrong per-se, but these two changes are
> borderline Meh.
>
> > Signed-off-by: Boxuan Li <liboxuan@connect.hku.hk>
> > ---
> > Thanks to Eric Sunshine's review, I've removed spaces after '>'
> > and changed 'actual' into 'output'.
> > ---
> >  t/t4253-am-keep-cr-dos.sh | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/t/t4253-am-keep-cr-dos.sh b/t/t4253-am-keep-cr-dos.sh
> > index 553fe3e88e..6e1b73ec3a 100755
> > --- a/t/t4253-am-keep-cr-dos.sh
> > +++ b/t/t4253-am-keep-cr-dos.sh
> > @@ -51,14 +51,16 @@ test_expect_success 'am with dos files without --keep-cr' '
> >
> >  test_expect_success 'am with dos files with --keep-cr' '
> >       git checkout -b dosfiles-keep-cr initial &&
> > -     git format-patch -k --stdout initial..master | git am --keep-cr -k -3 &&
> > +     git format-patch -k --stdout initial..master >output &&
> > +     git am --keep-cr -k -3 output &&
> >       git diff --exit-code master
> >  '
> >
> >  test_expect_success 'am with dos files config am.keepcr' '
> >       git config am.keepcr 1 &&
> >       git checkout -b dosfiles-conf-keepcr initial &&
> > -     git format-patch -k --stdout initial..master | git am -k -3 &&
> > +     git format-patch -k --stdout initial..master >output &&
> > +     git am -k -3 output &&
> >       git diff --exit-code master
> >  '

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] t4253-am-keep-cr-dos: avoid using pipes
  2019-05-07 12:42   ` LI, BO XUAN
@ 2019-05-08  5:49     ` Junio C Hamano
  2019-05-08 16:49       ` LI, BO XUAN
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2019-05-08  5:49 UTC (permalink / raw)
  To: LI, BO XUAN; +Cc: git, sunshine

"LI, BO XUAN" <liboxuan@connect.hku.hk> writes:

> Thanks for your review! I can understand your point, but I've got a
> quick question:
>
> What if format-patch really breaks and 'am' magically does not break?

Doesn't that indicate that you are not testing the result of "am"
adequately?

I am not saying it is *wrong* to split the pipe into two.  I am
merely saying that it is borderline Meh, as the primary point of
these two tests are to see how the command downstream of the pipe
behaves and not the upstream one.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] t4253-am-keep-cr-dos: avoid using pipes
  2019-05-08  5:49     ` Junio C Hamano
@ 2019-05-08 16:49       ` LI, BO XUAN
  0 siblings, 0 replies; 5+ messages in thread
From: LI, BO XUAN @ 2019-05-08 16:49 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, sunshine

Hi Junio,

Understood. Thanks for the clarification.

Best regards,
Boxuan Li

On Wed, May 8, 2019 at 1:49 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> "LI, BO XUAN" <liboxuan@connect.hku.hk> writes:
>
> > Thanks for your review! I can understand your point, but I've got a
> > quick question:
> >
> > What if format-patch really breaks and 'am' magically does not break?
>
> Doesn't that indicate that you are not testing the result of "am"
> adequately?
>
> I am not saying it is *wrong* to split the pipe into two.  I am
> merely saying that it is borderline Meh, as the primary point of
> these two tests are to see how the command downstream of the pipe
> behaves and not the upstream one.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-05-08 16:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-05  8:16 [PATCH v2] t4253-am-keep-cr-dos: avoid using pipes Boxuan Li
2019-05-07  9:04 ` Junio C Hamano
2019-05-07 12:42   ` LI, BO XUAN
2019-05-08  5:49     ` Junio C Hamano
2019-05-08 16:49       ` LI, BO XUAN

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).