# HG changeset patch # User Jun Wu # Date 2017-02-16 18:33:59 # Node ID 3844b3299a53b3746e1a708c84bbd6b83adddb7d # Parent cb899ee133d8c05445e07526c35e9c038b6ad3d1 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,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 @@ Test if logtoprocess correctly captures 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 @@ Confirm that logging blocked time catche > logblockedtimes=True > EOF - $ hg log + $ hg log | cat uiblocked stdio [0-9]+.[0-9]* ms command [0-9]+.[0-9]* ms (re)