comparison tests/test-extension.t @ 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 96bfd2875213
children 38dc3f28f478
comparison
equal deleted inserted replaced
28611:6aa17f86d9f0 28612:6fb1d3c936d2
5 > from mercurial import cmdutil, commands 5 > from mercurial import cmdutil, commands
6 > cmdtable = {} 6 > cmdtable = {}
7 > command = cmdutil.command(cmdtable) 7 > command = cmdutil.command(cmdtable)
8 > def uisetup(ui): 8 > def uisetup(ui):
9 > ui.write("uisetup called\\n") 9 > ui.write("uisetup called\\n")
10 > ui.flush()
10 > def reposetup(ui, repo): 11 > def reposetup(ui, repo):
11 > ui.write("reposetup called for %s\\n" % os.path.basename(repo.root)) 12 > ui.write("reposetup called for %s\\n" % os.path.basename(repo.root))
12 > ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!")) 13 > ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!"))
14 > ui.flush()
13 > @command('foo', [], 'hg foo') 15 > @command('foo', [], 'hg foo')
14 > def foo(ui, *args, **kwargs): 16 > def foo(ui, *args, **kwargs):
15 > ui.write("Foo\\n") 17 > ui.write("Foo\\n")
16 > @command('bar', [], 'hg bar', norepo=True) 18 > @command('bar', [], 'hg bar', norepo=True)
17 > def bar(ui, *args, **kwargs): 19 > def bar(ui, *args, **kwargs):
181 $ cat > $TESTTMP/extroot/__init__.py <<EOF 183 $ cat > $TESTTMP/extroot/__init__.py <<EOF
182 > s = 'this is extroot.__init__' 184 > s = 'this is extroot.__init__'
183 > import foo 185 > import foo
184 > def extsetup(ui): 186 > def extsetup(ui):
185 > ui.write('(extroot) ', foo.func(), '\n') 187 > ui.write('(extroot) ', foo.func(), '\n')
188 > ui.flush()
186 > EOF 189 > EOF
187 190
188 $ cat > $TESTTMP/extroot/foo.py <<EOF 191 $ cat > $TESTTMP/extroot/foo.py <<EOF
189 > # test absolute import 192 > # test absolute import
190 > buf = [] 193 > buf = []
1075 1078
1076 $ cat > $TESTTMP/reposetuptest.py <<EOF 1079 $ cat > $TESTTMP/reposetuptest.py <<EOF
1077 > from mercurial import extensions 1080 > from mercurial import extensions
1078 > def reposetup(ui, repo): 1081 > def reposetup(ui, repo):
1079 > ui.write('reposetup() for %s\n' % (repo.root)) 1082 > ui.write('reposetup() for %s\n' % (repo.root))
1083 > ui.flush()
1080 > EOF 1084 > EOF
1081 $ hg init src 1085 $ hg init src
1082 $ echo a > src/a 1086 $ echo a > src/a
1083 $ hg -R src commit -Am '#0 at src/a' 1087 $ hg -R src commit -Am '#0 at src/a'
1084 adding a 1088 adding a