changeset 31011:3844b3299a53

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.
author Jun Wu <quark@fb.com>
date Thu, 16 Feb 2017 10:33:59 -0800
parents cb899ee133d8
children 61b4122019d3
files tests/test-logtoprocess.t
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-logtoprocess.t	Thu Feb 16 23:10:47 2017 -0800
+++ b/tests/test-logtoprocess.t	Thu Feb 16 10:33:59 2017 -0800
@@ -1,3 +1,7 @@
+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.
 
   $ hg init
@@ -34,9 +38,8 @@
 Running a command triggers both a ui.log('command') and a
 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
   
   
   
@@ -66,5 +69,5 @@
   > logblockedtimes=True
   > EOF
 
-  $ hg log
+  $ hg log | cat
   uiblocked stdio [0-9]+.[0-9]* ms command [0-9]+.[0-9]* ms (re)