Rev 4832: (doxxx) Make bzr serve --quiet really quiet in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Nov 27 11:27:14 GMT 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4832 [merge]
revision-id: pqm at pqm.ubuntu.com-20091127112712-52xu8dywjwc1utjs
parent: pqm at pqm.ubuntu.com-20091126181911-j0gaqxdj5dc9ozih
parent: v.ladeuil+lp at free.fr-20091127104347-s0z0ma2f7mbpd660
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2009-11-27 11:27:12 +0000
message:
(doxxx) Make bzr serve --quiet really quiet
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/blackbox/test_serve.py test_serve.py-20060913064329-8t2pvmsikl4s3xhl-1
=== modified file 'NEWS'
--- a/NEWS 2009-11-26 17:23:54 +0000
+++ b/NEWS 2009-11-27 10:43:47 +0000
@@ -40,6 +40,8 @@
* ``bzr serve`` is more clear about the risk of supplying --allow-writes.
(Robert Collins, #84659)
+* ``bzr serve --quiet`` really is quiet now. (Gordon Tyler, #252834)
+
* Lots of bugfixes for the test suite on Windows. We should once again
have a test suite with no failures on Windows. (John Arbash Meinel)
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2009-11-24 08:28:41 +0000
+++ b/bzrlib/tests/__init__.py 2009-11-27 10:43:47 +0000
@@ -1836,10 +1836,22 @@
os.chdir(working_dir)
try:
- result = self.apply_redirected(ui.ui_factory.stdin,
- stdout, stderr,
- bzrlib.commands.run_bzr_catch_user_errors,
- args)
+ try:
+ result = self.apply_redirected(ui.ui_factory.stdin,
+ stdout, stderr,
+ bzrlib.commands.run_bzr_catch_user_errors,
+ args)
+ except KeyboardInterrupt:
+ # Reraise KeyboardInterrupt with contents of redirected stdout
+ # and stderr as arguments, for tests which are interested in
+ # stdout and stderr and are expecting the exception.
+ out = stdout.getvalue()
+ err = stderr.getvalue()
+ if out:
+ self.log('output:\n%r', out)
+ if err:
+ self.log('errors:\n%r', err)
+ raise KeyboardInterrupt(out, err)
finally:
logger.removeHandler(handler)
ui.ui_factory = old_ui_factory
=== modified file 'bzrlib/tests/blackbox/test_serve.py'
--- a/bzrlib/tests/blackbox/test_serve.py 2009-11-16 21:36:52 +0000
+++ b/bzrlib/tests/blackbox/test_serve.py 2009-11-25 13:21:52 +0000
@@ -45,8 +45,49 @@
from bzrlib.trace import mutter
from bzrlib.transport import get_transport, remote
-
-class TestBzrServe(TestCaseWithTransport):
+class TestBzrServeBase(TestCaseWithTransport):
+
+ def run_bzr_serve_then_func(self, serve_args, retcode=0, func=None,
+ *func_args, **func_kwargs):
+ """Run 'bzr serve', and run the given func in a thread once the server
+ has started.
+
+ When 'func' terminates, the server will be terminated too.
+
+ Returns stdout and stderr.
+ """
+ # install hook
+ def on_server_start(backing_urls, tcp_server):
+ t = threading.Thread(
+ target=on_server_start_thread, args=(tcp_server,))
+ t.start()
+ def on_server_start_thread(tcp_server):
+ try:
+ # Run func if set
+ self.tcp_server = tcp_server
+ if not func is None:
+ try:
+ func(*func_args, **func_kwargs)
+ except Exception, e:
+ # Log errors to make some test failures a little less
+ # mysterious.
+ mutter('func broke: %r', e)
+ finally:
+ # Then stop the server
+ mutter('interrupting...')
+ thread.interrupt_main()
+ SmartTCPServer.hooks.install_named_hook(
+ 'server_started_ex', on_server_start,
+ 'run_bzr_serve_then_func hook')
+ # start a TCP server
+ try:
+ out, err = self.run_bzr(['serve'] + list(serve_args))
+ except KeyboardInterrupt, e:
+ out, err = e.args
+ return out, err
+
+
+class TestBzrServe(TestBzrServeBase):
def setUp(self):
super(TestBzrServe, self).setUp()
@@ -119,6 +160,13 @@
url = 'bzr://localhost:%d/' % port
self.permit_url(url)
return process, url
+
+ def test_bzr_serve_quiet(self):
+ self.make_branch('.')
+ args = ['--port', 'localhost:0', '--quiet']
+ out, err = self.run_bzr_serve_then_func(args, retcode=3)
+ self.assertEqual('', out)
+ self.assertEqual('', err)
def test_bzr_serve_inet_readonly(self):
"""bzr server should provide a read only filesystem by default."""
@@ -168,7 +216,7 @@
self.assertServerFinishesCleanly(process)
-class TestCmdServeChrooting(TestCaseWithTransport):
+class TestCmdServeChrooting(TestBzrServeBase):
def test_serve_tcp(self):
"""'bzr serve' wraps the given --directory in a ChrootServer.
@@ -183,47 +231,12 @@
['--port', '127.0.0.1:0',
'--directory', t.local_abspath('server-root'),
'--allow-writes'],
- self.when_server_started)
+ func=self.when_server_started)
# The when_server_started method issued a find_repositoryV3 that should
# fail with 'norepository' because there are no repositories inside the
# --directory.
self.assertEqual(('norepository',), self.client_resp)
- def run_bzr_serve_then_func(self, serve_args, func, *func_args,
- **func_kwargs):
- """Run 'bzr serve', and run the given func in a thread once the server
- has started.
-
- When 'func' terminates, the server will be terminated too.
- """
- # install hook
- def on_server_start(backing_urls, tcp_server):
- t = threading.Thread(
- target=on_server_start_thread, args=(tcp_server,))
- t.start()
- def on_server_start_thread(tcp_server):
- try:
- # Run func
- self.tcp_server = tcp_server
- try:
- func(*func_args, **func_kwargs)
- except Exception, e:
- # Log errors to make some test failures a little less
- # mysterious.
- mutter('func broke: %r', e)
- finally:
- # Then stop the server
- mutter('interrupting...')
- thread.interrupt_main()
- SmartTCPServer.hooks.install_named_hook(
- 'server_started_ex', on_server_start,
- 'run_bzr_serve_then_func hook')
- # start a TCP server
- try:
- self.run_bzr(['serve'] + list(serve_args))
- except KeyboardInterrupt:
- pass
-
def when_server_started(self):
# Connect to the TCP server and issue some requests and see what comes
# back.
More information about the bazaar-commits
mailing list