[PATCH STABLE] dispatch: adjust ui.flush() timing to stabilize test-blackbox.t

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH STABLE] dispatch: adjust ui.flush() timing to stabilize test-blackbox.t

Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara <[hidden email]>
# Date 1595685086 -32400
#      Sat Jul 25 22:51:26 2020 +0900
# Branch stable
# Node ID cd333962901c4142d6b29deae1851bca6c51f587
# Parent  41021660baa1bdb3fb089d6ddb6b6658c9e540b1
dispatch: adjust ui.flush() timing to stabilize test-blackbox.t

Without this change, dispatch.dispatch() could return before flushing all
stdio data. This means chg stdio would print data after receiving the result
code.

--- tests/test-blackbox.t
+++ tests/test-blackbox.t.err
@@ -354,13 +354,13 @@
   > EOF
   $ hg log --debug
   removing $TESTTMP/gone/.hg
-  warning: cannot write to blackbox.log: $ENOENT$ (no-windows !)
   warning: cannot write to blackbox.log: $TESTTMP/gone/.hg/blackbox.log: $ENOTDIR$ (windows !)
   $ cd ..

 blackbox should disable itself if track is empty

   $ hg --config blackbox.track= init nothing_tracked
+  warning: cannot write to blackbox.log: $ENOENT$
   $ cd nothing_tracked
   $ cat >> .hg/hgrc << EOF
   > [blackbox]

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -323,7 +323,7 @@ def dispatch(req):
             ret = -1
         finally:
             duration = util.timer() - starttime
-            req.ui.flush()
+            req.ui.flush()  # record blocked times
             if req.ui.logblockedtimes:
                 req.ui._blockedtimes[b'command_duration'] = duration * 1000
                 req.ui.log(
@@ -346,6 +346,8 @@ def dispatch(req):
                 req._runexithandlers()
             except:  # exiting, so no re-raises
                 ret = ret or -1
+            # do flush again since ui.log() and exit handlers may write to ui
+            req.ui.flush()
         return ret
 
 
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH STABLE] dispatch: adjust ui.flush() timing to stabilize test-blackbox.t

Pulkit Goyal
On Sat, Jul 25, 2020 at 7:59 PM Yuya Nishihara <[hidden email]> wrote:

>
> # HG changeset patch
> # User Yuya Nishihara <[hidden email]>
> # Date 1595685086 -32400
> #      Sat Jul 25 22:51:26 2020 +0900
> # Branch stable
> # Node ID cd333962901c4142d6b29deae1851bca6c51f587
> # Parent  41021660baa1bdb3fb089d6ddb6b6658c9e540b1
> dispatch: adjust ui.flush() timing to stabilize test-blackbox.t
>
> Without this change, dispatch.dispatch() could return before flushing all
> stdio data. This means chg stdio would print data after receiving the result
> code.

Thanks a lot for looking into this. Queued for stable, many thanks!
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel