Patchwork test-extension: flush diagnostic message to stabilize chg output

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 7, 2020, 11:56 a.m.
Message ID <e19bab808d0b34911211.1607342172@lemosa>
Download mbox | patch
Permalink /patch/47817/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 7, 2020, 11:56 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1607339556 -32400
#      Mon Dec 07 20:12:36 2020 +0900
# Node ID e19bab808d0b3491121113509601f990fe5988f1
# Parent  1bf2b44c40078c4e17479a1625c57370dc7750ec
test-extension: flush diagnostic message to stabilize chg output

Since chg server may create new file object for the attached stdout,
procutil.stdout is not ui.fout and the buffered procutil.stdout data wouldn't
be flushed at all. That's why test-extension.t passes without modification
on Python 2.
Pulkit Goyal - Dec. 8, 2020, 7:16 a.m.
On Mon, Dec 7, 2020 at 5:26 PM Yuya Nishihara <yuya@tcha.org> wrote:
>
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1607339556 -32400
> #      Mon Dec 07 20:12:36 2020 +0900
> # Node ID e19bab808d0b3491121113509601f990fe5988f1
> # Parent  1bf2b44c40078c4e17479a1625c57370dc7750ec
> test-extension: flush diagnostic message to stabilize chg output
>
> Since chg server may create new file object for the attached stdout,
> procutil.stdout is not ui.fout and the buffered procutil.stdout data wouldn't
> be flushed at all. That's why test-extension.t passes without modification
> on Python 2.

Queued this, many thanks Yuya!

Patch

diff --git a/tests/test-extension.t b/tests/test-extension.t
--- a/tests/test-extension.t
+++ b/tests/test-extension.t
@@ -154,7 +154,10 @@  Check that extensions are loaded in phas
   > from mercurial import exthelper
   > from mercurial.utils import procutil
   > 
-  > write = procutil.stdout.write
+  > def write(msg):
+  >     procutil.stdout.write(msg)
+  >     procutil.stdout.flush()
+  > 
   > name = os.path.basename(__file__).rsplit('.', 1)[0]
   > bytesname = name.encode('utf-8')
   > write(b"1) %s imported\n" % bytesname)
@@ -194,6 +197,9 @@  Check that extensions are loaded in phas
 
 Check normal command's load order of extensions and registration of functions
 
+ On chg server, extension should be first set up by the server. Then
+ object-level setup should follow in the worker process.
+
   $ hg log -r "foo() and bar()" -q
   1) foo imported
   1) bar imported
@@ -209,6 +215,18 @@  Check normal command's load order of ext
   4) bar uipopulate
   5) foo reposetup
   5) bar reposetup
+  4) foo uipopulate (chg !)
+  4) bar uipopulate (chg !)
+  4) foo uipopulate (chg !)
+  4) bar uipopulate (chg !)
+  4) foo uipopulate (chg !)
+  4) bar uipopulate (chg !)
+  4) foo uipopulate (chg !)
+  4) bar uipopulate (chg !)
+  4) foo uipopulate (chg !)
+  4) bar uipopulate (chg !)
+  5) foo reposetup (chg !)
+  5) bar reposetup (chg !)
   0:c24b9ac61126
 
 Check hgweb's load order of extensions and registration of functions