{"thread":{"id":"41305","subject":"[PATCH] test-lib: limit the output of the yes utility","startedAt":"2016-02-02T07:28:21Z","lastAt":"2016-02-03T12:11:57Z","messageCount":4,"participants":["Johannes Sixt","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"277211","messageId":"56B05A95.3000808@kdbg.org","threadId":"41305","inReplyTo":null,"subject":"[PATCH] test-lib: limit the output of the yes utility","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2016-02-02T07:28:21Z","receivedAt":"2016-02-02T07:28:21Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Windows, there is no SIGPIPE. A consequence of this is that the\nupstream process of a pipe does not notice the death of the downstream\nprocess until the pipe buffer is full and writing more data returns an\nerror. This behavior is the reason for an annoying delay during the\nexecution of t7610-mergetool.sh: There are a number of test cases where\n'yes' is invoked upstream. Since the utility is basically an endless\nloop it runs, on Windows, until the pipe buffer is full. This does take\na few seconds.\n\nThe test suite has its own implementation of 'yes'. Modify it to produce\nonly a limited amount of output that is sufficient for the test suite.\nThe amount chosen should be sufficiently high for any test case, assuming\nthat future test cases will not exaggerate their demands of input from\nan upstream 'yes' invocation.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n This does not fix an error, but only an unnecessary sink of CPU cycles\n and wasted wall clock time.\n\n t/test-lib.sh | 14 +++++++-------\n 1 file changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex bd4b02e..97e6491 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -902,15 +902,15 @@ fi\n yes () {\n \tif test $# = 0\n \tthen\n-\t\ty=y\n+\t\tset -- y\n \telse\n-\t\ty=\"$*\"\n+\t\tset -- \"$*\"\n \tfi\n-\n-\twhile echo \"$y\"\n-\tdo\n-\t\t:\n-\tdone\n+\t# we do not need an infinite supply of output for tests\n+\tset -- \"$@\" \"$@\" \"$@\" \"$@\"\t# 4\n+\tset -- \"$@\" \"$@\" \"$@\" \"$@\"\t# 16\n+\tset -- \"$@\" \"$@\" \"$@\" \"$@\"\t# 64\n+\tprintf \"%s\\n\" \"$@\"\n }\n \n # Fix some commands on Windows\n-- \n2.7.0.118.g90056ae\n"},{"id":"277213","messageId":"alpine.DEB.2.20.1602020907290.2964@virtualbox","threadId":"41305","inReplyTo":"56B05A95.3000808@kdbg.org","subject":"Re: [PATCH] test-lib: limit the output of the yes utility","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-02-02T08:21:10Z","receivedAt":"2016-02-02T08:21:10Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Hannes,\n\nOn Tue, 2 Feb 2016, Johannes Sixt wrote:\n\n> On Windows, there is no SIGPIPE.\n\nTrue. But we do get some sort of write failure, no? Otherwise\nhttps://github.com/git/git/commit/2b86292ed would not work...\n\n> diff --git a/t/test-lib.sh b/t/test-lib.sh\n> index bd4b02e..97e6491 100644\n> --- a/t/test-lib.sh\n> +++ b/t/test-lib.sh\n> @@ -902,15 +902,15 @@ fi\n>  yes () {\n>  \tif test $# = 0\n>  \tthen\n> -\t\ty=y\n> +\t\tset -- y\n>  \telse\n> -\t\ty=\"$*\"\n> +\t\tset -- \"$*\"\n>  \tfi\n> -\n> -\twhile echo \"$y\"\n> -\tdo\n> -\t\t:\n> -\tdone\n> +\t# we do not need an infinite supply of output for tests\n> +\tset -- \"$@\" \"$@\" \"$@\" \"$@\"\t# 4\n> +\tset -- \"$@\" \"$@\" \"$@\" \"$@\"\t# 16\n> +\tset -- \"$@\" \"$@\" \"$@\" \"$@\"\t# 64\n> +\tprintf \"%s\\n\" \"$@\"\n>  }\n\nI agree with the idea, but I would like to have a less intrusive patch.\nSomething like this should do the job as well, and is a little easier on\nthe eyes IMHO:\n\n-- snipsnap --\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 32ac1a6..ae381b9 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -907,9 +907,11 @@ yes () {\n \t\ty=\"$*\"\n \tfi\n \n-\twhile echo \"$y\"\n+\ti=0\n+\twhile test $i -lt 99\n \tdo\n-\t\t:\n+\t\techo \"$y\"\n+\t\ti=$(($i+1))\n \tdone\n }\n \n"},{"id":"277263","messageId":"56B0F259.1060100@kdbg.org","threadId":"41305","inReplyTo":"alpine.DEB.2.20.1602020907290.2964@virtualbox","subject":"[PATCH v2] test-lib: limit the output of the yes utility","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2016-02-02T18:15:53Z","receivedAt":"2016-02-02T18:15:53Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nOn Windows, there is no SIGPIPE. A consequence of this is that the\nupstream process of a pipe does not notice the death of the downstream\nprocess until the pipe buffer is full and writing more data returns an\nerror. This behavior is the reason for an annoying delay during the\nexecution of t7610-mergetool.sh: There are a number of test cases where\n'yes' is invoked upstream. Since the utility is basically an endless\nloop it runs, on Windows, until the pipe buffer is full. This does take\na few seconds.\n\nThe test suite has its own implementation of 'yes'. Modify it to produce\nonly a limited amount of output that is sufficient for the test suite.\nThe amount chosen should be sufficiently high for any test case, assuming\nthat future test cases will not exaggerate their demands of input from\nan upstream 'yes' invocation.\n\n[j6t: commit message]\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\nAm 02.02.2016 um 09:21 schrieb Johannes Schindelin:\n> On Tue, 2 Feb 2016, Johannes Sixt wrote:\n>> On Windows, there is no SIGPIPE.\n> \n> True. But we do get some sort of write failure, no? Otherwise\n> https://github.com/git/git/commit/2b86292ed would not work...\n\nOf course. See the second sentence of the commit message.\n\n> I agree with the idea, but I would like to have a less intrusive patch.\n> Something like this should do the job as well, and is a little easier on\n> the eyes IMHO:\n\nI'm not 100% satisfied with your version because it stomps on\nshort-and-sweet shell variables $i and $y. But then the utility\nonly occurs upstream of a pipeline in a separate process, so that\ndoes not matter.\n\nPlease allow me to pass authorship to you, since the patch text is\nnow all yours, and to forge your sign-off.\n\n-- Hannes\n\n t/test-lib.sh | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex bd4b02e..51e4a88 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -907,9 +907,11 @@ yes () {\n \t\ty=\"$*\"\n \tfi\n \n-\twhile echo \"$y\"\n+\ti=0\n+\twhile test $i -lt 99\n \tdo\n-\t\t:\n+\t\techo \"$y\"\n+\t\ti=$(($i+1))\n \tdone\n }\n \n-- \n2.7.0.118.g90056ae\n"},{"id":"277334","messageId":"alpine.DEB.2.20.1602031309550.2964@virtualbox","threadId":"41305","inReplyTo":"56B0F259.1060100@kdbg.org","subject":"Re: [PATCH v2] test-lib: limit the output of the yes utility","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-02-03T12:11:57Z","receivedAt":"2016-02-03T12:11:57Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Hannes,\n\nOn Tue, 2 Feb 2016, Johannes Sixt wrote:\n\n> I'm not 100% satisfied with your version because it stomps on\n> short-and-sweet shell variables $i and $y.\n\nPlease note that $y was already stomped on before my patch.\n\n> But then the utility only occurs upstream of a pipeline in a separate\n> process, so that does not matter.\n\nThat was my thinking, too.\n\n> Please allow me to pass authorship to you, since the patch text is\n> now all yours, and to forge your sign-off.\n\nFair enough,\nDscho\n"}]}