[PATCH V3] tests: use proctutil.stdout.write() instead of print() in test-extension.t
Pulkit Goyal
7895pulkit at gmail.com
Thu Jun 18 16:45:51 UTC 2020
# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1592483079 -19800
# Thu Jun 18 17:54:39 2020 +0530
# Node ID a892eba498bf291d5474cc43d530842619c27979
# Parent 9bc86abdc75bd009d908cd6f5b6fc7fcff82a60c
# EXP-Topic chg-test
tests: use proctutil.stdout.write() instead of print() in test-extension.t
I was debugging this test failure on python3 + chg. I get the following hunk as
test failure:
```
@@ -206,6 +206,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
```
After hours of debugging and head scracthing, I figured out that something is
wrong with output flushing. I initially switched the print() statements to
ui.warn() but thanks to Yuya who suggested using procutil.stdout.write()
instead.
diff --git a/tests/test-extension.t b/tests/test-extension.t
--- a/tests/test-extension.t
+++ b/tests/test-extension.t
@@ -152,21 +152,25 @@ Check that extensions are loaded in phas
> from __future__ import print_function
> import os
> from mercurial import exthelper
+ > from mercurial.utils import procutil
+ >
+ > write = procutil.stdout.write
> name = os.path.basename(__file__).rsplit('.', 1)[0]
- > print("1) %s imported" % name, flush=True)
+ > bytesname = name.encode('utf-8')
+ > write(b"1) %s imported\n" % bytesname)
> eh = exthelper.exthelper()
> @eh.uisetup
> def _uisetup(ui):
- > print("2) %s uisetup" % name, flush=True)
+ > write(b"2) %s uisetup\n" % bytesname)
> @eh.extsetup
> def _extsetup(ui):
- > print("3) %s extsetup" % name, flush=True)
+ > write(b"3) %s extsetup\n" % bytesname)
> @eh.uipopulate
> def _uipopulate(ui):
- > print("4) %s uipopulate" % name, flush=True)
+ > write(b"4) %s uipopulate\n" % bytesname)
> @eh.reposetup
> def _reposetup(ui, repo):
- > print("5) %s reposetup" % name, flush=True)
+ > write(b"5) %s reposetup\n" % bytesname)
>
> extsetup = eh.finalextsetup
> reposetup = eh.finalreposetup
@@ -174,7 +178,6 @@ Check that extensions are loaded in phas
> uisetup = eh.finaluisetup
> revsetpredicate = eh.revsetpredicate
>
- > bytesname = name.encode('utf-8')
> # custom predicate to check registration of functions at loading
> from mercurial import (
> smartset,
More information about the Mercurial-devel
mailing list