Mercurial > hg-stable
changeset 28612:6fb1d3c936d2
tests: explicitly flush output streams
Some tests fail while running with chg because they do not flush their output
streams. chgserver will make sure ui.flush is called after dispatch, but not
after {ui,repo}setup. For other non-ui streams, it should be explicitly
flushed since the request handler will use os._exit.
This patch adds explicit flushes in test-bundle2-format.t, test-extension.t
and test-obsolete.t. It will fix most test cases of them when running with chg.
author | Jun Wu <quark@fb.com> |
---|---|
date | Tue, 15 Mar 2016 09:51:42 +0000 |
parents | 6aa17f86d9f0 |
children | 6433da9c96a9 |
files | tests/test-bundle2-format.t tests/test-extension.t tests/test-obsolete.t |
diffstat | 3 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test-bundle2-format.t Sun Mar 20 15:09:29 2016 -0700 +++ b/tests/test-bundle2-format.t Tue Mar 15 09:51:42 2016 +0000 @@ -166,6 +166,8 @@ > file.write(chunk) > except RuntimeError, exc: > raise error.Abort(exc) + > finally: + > file.flush() > > @command('unbundle2', [], '') > def cmdunbundle2(ui, repo, replypath=None): @@ -194,9 +196,9 @@ > for rec in op.records['changegroup']: > ui.write('addchangegroup return: %i\n' % rec['return']) > if op.reply is not None and replypath is not None: - > file = open(replypath, 'wb') - > for chunk in op.reply.getchunks(): - > file.write(chunk) + > with open(replypath, 'wb') as file: + > for chunk in op.reply.getchunks(): + > file.write(chunk) > > @command('statbundle2', [], '') > def cmdstatbundle2(ui, repo):
--- a/tests/test-extension.t Sun Mar 20 15:09:29 2016 -0700 +++ b/tests/test-extension.t Tue Mar 15 09:51:42 2016 +0000 @@ -7,9 +7,11 @@ > command = cmdutil.command(cmdtable) > def uisetup(ui): > ui.write("uisetup called\\n") + > ui.flush() > def reposetup(ui, repo): > ui.write("reposetup called for %s\\n" % os.path.basename(repo.root)) > ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!")) + > ui.flush() > @command('foo', [], 'hg foo') > def foo(ui, *args, **kwargs): > ui.write("Foo\\n") @@ -183,6 +185,7 @@ > import foo > def extsetup(ui): > ui.write('(extroot) ', foo.func(), '\n') + > ui.flush() > EOF $ cat > $TESTTMP/extroot/foo.py <<EOF @@ -1077,6 +1080,7 @@ > from mercurial import extensions > def reposetup(ui, repo): > ui.write('reposetup() for %s\n' % (repo.root)) + > ui.flush() > EOF $ hg init src $ echo a > src/a
--- a/tests/test-obsolete.t Sun Mar 20 15:09:29 2016 -0700 +++ b/tests/test-obsolete.t Tue Mar 15 09:51:42 2016 +0000 @@ -935,7 +935,7 @@ > opts['message'] = 'Test' > opts['logfile'] = None > cmdutil.amend(ui, repo, commitfunc, repo['.'], {}, pats, opts) - > print repo.changelog.headrevs() + > ui.write('%s\n' % repo.changelog.headrevs()) > EOF $ cat >> $HGRCPATH << EOF > [extensions]