Quantcast

[PATCH] test-logtoprocess: use cat to wait for outputs

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH] test-logtoprocess: use cat to wait for outputs

Jun Wu
# HG changeset patch
# User Jun Wu <[hidden email]>
# Date 1487270039 28800
#      Thu Feb 16 10:33:59 2017 -0800
# Node ID 9088dc2948690d0668fbaa7bb1f2fe137c40ee5d
# Parent  6e6a461b5b60dc48a9e49cab2f3994b1345531fc
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 9088dc294869
test-logtoprocess: use cat to wait for outputs

Commands started by logtoprocess are running asynchronously. To be able to
test the output, we need to block and wait for the output.

The patch uses "| cat" to wait for such "asynchronous" outputs, to make the
test more reliable. I have also written a short notice at the top, hopefully
people would be aware of the pitfall when changing the test.

diff --git a/tests/test-logtoprocess.t b/tests/test-logtoprocess.t
--- a/tests/test-logtoprocess.t
+++ b/tests/test-logtoprocess.t
@@ -1,2 +1,6 @@
+ATTENTION: logtoprocess runs commands asynchronously. Be sure to append "| cat"
+to hg commands, to wait for the output, if you want to test its output.
+Otherwise the test will be flaky.
+
 Test if logtoprocess correctly captures command-related log calls.
 
@@ -35,7 +39,6 @@ Running a command triggers both a ui.log
 ui.log('commandfinish') call. The foo command also uses ui.log.
 
-Use head to ensure we wait for all lines to be produced, and sort to avoid
-ordering issues between the various processes we spawn:
-  $ hg foo | head -n 17 | sort
+Use sort to avoid ordering issues between the various processes we spawn:
+  $ hg foo | cat | sort
   
   
@@ -67,4 +70,4 @@ Confirm that logging blocked time catche
   > EOF
 
-  $ hg log
+  $ hg log | cat
   uiblocked stdio [0-9]+.[0-9]* ms command [0-9]+.[0-9]* ms (re)
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH] test-logtoprocess: use cat to wait for outputs

Martin von Zweigbergk via Mercurial-devel
On Thu, Feb 16, 2017 at 11:00 AM, Jun Wu <[hidden email]> wrote:
> # HG changeset patch
> # User Jun Wu <[hidden email]>
> # Date 1487270039 28800
> #      Thu Feb 16 10:33:59 2017 -0800
> # Node ID 9088dc2948690d0668fbaa7bb1f2fe137c40ee5d
> # Parent  6e6a461b5b60dc48a9e49cab2f3994b1345531fc
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 9088dc294869
> test-logtoprocess: use cat to wait for outputs

Queued, thanks.
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Loading...