Rev 6320: (mbp) bzr selftest tests fail after a configurable timeout (Martin Pool) in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Nov 29 01:29:56 UTC 2011
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6320 [merge]
revision-id: pqm at pqm.ubuntu.com-20111129012956-uclbanos2gylcgnw
parent: pqm at pqm.ubuntu.com-20111128194749-ngknllszanig1epd
parent: mbp at canonical.com-20111129005916-x3lk8n68jisjclo2
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2011-11-29 01:29:56 +0000
message:
(mbp) bzr selftest tests fail after a configurable timeout (Martin Pool)
modified:
Makefile Makefile-20050805140406-d96e3498bb61c5bb
bzrlib/config.py config.py-20051011043216-070c74f4e9e338e8
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/fixtures.py fixtures.py-20100514150609-1kpa1jqaciel01wn-1
doc/en/release-notes/bzr-2.5.txt bzr2.5.txt-20110708125756-587p0hpw7oke4h05-1
=== modified file 'Makefile'
--- a/Makefile 2011-09-06 11:01:30 +0000
+++ b/Makefile 2011-11-29 00:35:22 +0000
@@ -43,7 +43,8 @@
# Generate a stream for PQM to watch.
-$(RM) -f selftest.log
echo `date` ": selftest starts" 1>&2
- $(PYTHON) -Werror -Wignore::ImportWarning -O ./bzr selftest --subunit $(tests) | tee selftest.log
+ $(PYTHON) -Werror -Wignore::ImportWarning -O ./bzr selftest -Oselftest.timeout=120 \
+ --subunit $(tests) | tee selftest.log
echo `date` ": selftest ends" 1>&2
# An empty log file should catch errors in the $(PYTHON)
# command above (the '|' swallow any errors since 'make'
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2011-11-25 16:28:42 +0000
+++ b/bzrlib/config.py 2011-11-28 08:21:22 +0000
@@ -2602,6 +2602,14 @@
to physical disk. This is somewhat slower, but means data should not be
lost if the machine crashes. See also dirstate.fdatasync.
'''))
+
+option_registry.register(
+ Option('selftest.timeout',
+ default='600',
+ from_unicode=int_from_store,
+ help='Abort selftest if one test takes longer than this many seconds',
+ ))
+
option_registry.register(
Option('send_strict', default=None,
from_unicode=bool_from_store,
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2011-11-20 02:08:16 +0000
+++ b/bzrlib/tests/__init__.py 2011-11-29 00:49:17 +0000
@@ -94,6 +94,7 @@
deprecated_in,
)
from bzrlib.tests import (
+ fixtures,
test_server,
TestUtil,
treeshape,
@@ -995,12 +996,21 @@
def setUp(self):
super(TestCase, self).setUp()
+
+ timeout = config.GlobalStack().get('selftest.timeout')
+ if timeout:
+ timeout_fixture = fixtures.TimeoutFixture(timeout)
+ timeout_fixture.setUp()
+ self.addCleanup(timeout_fixture.cleanUp)
+
for feature in getattr(self, '_test_needs_features', []):
self.requireFeature(feature)
self._cleanEnvironment()
+
if bzrlib.global_state is not None:
self.overrideAttr(bzrlib.global_state, 'cmdline_overrides',
config.CommandLineStore())
+
self._silenceUI()
self._startLogFile()
self._benchcalls = []
=== modified file 'bzrlib/tests/fixtures.py'
--- a/bzrlib/tests/fixtures.py 2011-07-04 20:17:44 +0000
+++ b/bzrlib/tests/fixtures.py 2011-11-29 00:50:36 +0000
@@ -138,3 +138,23 @@
testcase.build_tree_contents([('t/hello', 'hello world')])
tree.add(['hello'], ['hello-id'])
return tree
+
+
+class TimeoutFixture(object):
+ """Kill a test with sigalarm if it runs too long.
+
+ Only works on Unix at present.
+ """
+
+ def __init__(self, timeout_secs):
+ import signal
+ self.timeout_secs = timeout_secs
+ self.alarm_fn = getattr(signal, 'alarm', None)
+
+ def setUp(self):
+ if self.alarm_fn is not None:
+ self.alarm_fn(self.timeout_secs)
+
+ def cleanUp(self):
+ if self.alarm_fn is not None:
+ self.alarm_fn(0)
=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt 2011-11-28 19:14:01 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt 2011-11-29 00:59:16 +0000
@@ -157,6 +157,11 @@
* Avoid failures in test_transform when OS error messages are localised.
(Martin Packman, #891582)
+* Tests are now subject to a time limit: by default 300s, and 120s when
+ run from 'make check', controlled by the `selftest.timeout`
+ configuration option. This is currently not supported on Windows.
+ (Martin Pool)
+
bzr 2.5b3
#########
More information about the bazaar-commits
mailing list