All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] test-lib: limit the output of the yes utility
@ 2016-02-02  7:28 Johannes Sixt
  2016-02-02  8:21 ` Johannes Schindelin
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Sixt @ 2016-02-02  7:28 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Johannes Schindelin

On Windows, there is no SIGPIPE. A consequence of this is that the
upstream process of a pipe does not notice the death of the downstream
process until the pipe buffer is full and writing more data returns an
error. This behavior is the reason for an annoying delay during the
execution of t7610-mergetool.sh: There are a number of test cases where
'yes' is invoked upstream. Since the utility is basically an endless
loop it runs, on Windows, until the pipe buffer is full. This does take
a few seconds.

The test suite has its own implementation of 'yes'. Modify it to produce
only a limited amount of output that is sufficient for the test suite.
The amount chosen should be sufficiently high for any test case, assuming
that future test cases will not exaggerate their demands of input from
an upstream 'yes' invocation.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 This does not fix an error, but only an unnecessary sink of CPU cycles
 and wasted wall clock time.

 t/test-lib.sh | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index bd4b02e..97e6491 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -902,15 +902,15 @@ fi
 yes () {
 	if test $# = 0
 	then
-		y=y
+		set -- y
 	else
-		y="$*"
+		set -- "$*"
 	fi
-
-	while echo "$y"
-	do
-		:
-	done
+	# we do not need an infinite supply of output for tests
+	set -- "$@" "$@" "$@" "$@"	# 4
+	set -- "$@" "$@" "$@" "$@"	# 16
+	set -- "$@" "$@" "$@" "$@"	# 64
+	printf "%s\n" "$@"
 }
 
 # Fix some commands on Windows
-- 
2.7.0.118.g90056ae

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

* Re: [PATCH] test-lib: limit the output of the yes utility
  2016-02-02  7:28 [PATCH] test-lib: limit the output of the yes utility Johannes Sixt
@ 2016-02-02  8:21 ` Johannes Schindelin
  2016-02-02 18:15   ` [PATCH v2] " Johannes Sixt
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Schindelin @ 2016-02-02  8:21 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Git Mailing List

Hi Hannes,

On Tue, 2 Feb 2016, Johannes Sixt wrote:

> On Windows, there is no SIGPIPE.

True. But we do get some sort of write failure, no? Otherwise
https://github.com/git/git/commit/2b86292ed would not work...

> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index bd4b02e..97e6491 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -902,15 +902,15 @@ fi
>  yes () {
>  	if test $# = 0
>  	then
> -		y=y
> +		set -- y
>  	else
> -		y="$*"
> +		set -- "$*"
>  	fi
> -
> -	while echo "$y"
> -	do
> -		:
> -	done
> +	# we do not need an infinite supply of output for tests
> +	set -- "$@" "$@" "$@" "$@"	# 4
> +	set -- "$@" "$@" "$@" "$@"	# 16
> +	set -- "$@" "$@" "$@" "$@"	# 64
> +	printf "%s\n" "$@"
>  }

I agree with the idea, but I would like to have a less intrusive patch.
Something like this should do the job as well, and is a little easier on
the eyes IMHO:

-- snipsnap --
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 32ac1a6..ae381b9 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -907,9 +907,11 @@ yes () {
 		y="$*"
 	fi
 
-	while echo "$y"
+	i=0
+	while test $i -lt 99
 	do
-		:
+		echo "$y"
+		i=$(($i+1))
 	done
 }
 

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

* [PATCH v2] test-lib: limit the output of the yes utility
  2016-02-02  8:21 ` Johannes Schindelin
@ 2016-02-02 18:15   ` Johannes Sixt
  2016-02-03 12:11     ` Johannes Schindelin
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Sixt @ 2016-02-02 18:15 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Git Mailing List

From: Johannes Schindelin <johannes.schindelin@gmx.de>

On Windows, there is no SIGPIPE. A consequence of this is that the
upstream process of a pipe does not notice the death of the downstream
process until the pipe buffer is full and writing more data returns an
error. This behavior is the reason for an annoying delay during the
execution of t7610-mergetool.sh: There are a number of test cases where
'yes' is invoked upstream. Since the utility is basically an endless
loop it runs, on Windows, until the pipe buffer is full. This does take
a few seconds.

The test suite has its own implementation of 'yes'. Modify it to produce
only a limited amount of output that is sufficient for the test suite.
The amount chosen should be sufficiently high for any test case, assuming
that future test cases will not exaggerate their demands of input from
an upstream 'yes' invocation.

[j6t: commit message]

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
Am 02.02.2016 um 09:21 schrieb Johannes Schindelin:
> On Tue, 2 Feb 2016, Johannes Sixt wrote:
>> On Windows, there is no SIGPIPE.
> 
> True. But we do get some sort of write failure, no? Otherwise
> https://github.com/git/git/commit/2b86292ed would not work...

Of course. See the second sentence of the commit message.

> I agree with the idea, but I would like to have a less intrusive patch.
> Something like this should do the job as well, and is a little easier on
> the eyes IMHO:

I'm not 100% satisfied with your version because it stomps on
short-and-sweet shell variables $i and $y. But then the utility
only occurs upstream of a pipeline in a separate process, so that
does not matter.

Please allow me to pass authorship to you, since the patch text is
now all yours, and to forge your sign-off.

-- Hannes

 t/test-lib.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index bd4b02e..51e4a88 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -907,9 +907,11 @@ yes () {
 		y="$*"
 	fi
 
-	while echo "$y"
+	i=0
+	while test $i -lt 99
 	do
-		:
+		echo "$y"
+		i=$(($i+1))
 	done
 }
 
-- 
2.7.0.118.g90056ae

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

* Re: [PATCH v2] test-lib: limit the output of the yes utility
  2016-02-02 18:15   ` [PATCH v2] " Johannes Sixt
@ 2016-02-03 12:11     ` Johannes Schindelin
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Schindelin @ 2016-02-03 12:11 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Git Mailing List

Hi Hannes,

On Tue, 2 Feb 2016, Johannes Sixt wrote:

> I'm not 100% satisfied with your version because it stomps on
> short-and-sweet shell variables $i and $y.

Please note that $y was already stomped on before my patch.

> But then the utility only occurs upstream of a pipeline in a separate
> process, so that does not matter.

That was my thinking, too.

> Please allow me to pass authorship to you, since the patch text is
> now all yours, and to forge your sign-off.

Fair enough,
Dscho

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

end of thread, other threads:[~2016-02-03 12:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-02  7:28 [PATCH] test-lib: limit the output of the yes utility Johannes Sixt
2016-02-02  8:21 ` Johannes Schindelin
2016-02-02 18:15   ` [PATCH v2] " Johannes Sixt
2016-02-03 12:11     ` Johannes Schindelin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.