Rev 5946: (spiv) Include log details from start_bzr_subprocess in test failures. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Jun 1 06:08:55 UTC 2011
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5946 [merge]
revision-id: pqm at pqm.ubuntu.com-20110601060852-17r5jvh87xohjf22
parent: pqm at pqm.ubuntu.com-20110531215047-sxah2raqyplbxwcw
parent: andrew.bennetts at canonical.com-20110601052143-3k9f0s7h6ajmoll7
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2011-06-01 06:08:52 +0000
message:
(spiv) Include log details from start_bzr_subprocess in test failures.
(Andrew Bennetts)
modified:
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2011-05-31 21:08:52 +0000
+++ b/bzrlib/tests/__init__.py 2011-06-01 05:21:43 +0000
@@ -988,6 +988,7 @@
# settled on or a the FIXME associated with _get_expand_default_value
# is addressed -- vila 20110219
self.overrideAttr(config, '_expand_default_value', None)
+ self._log_files = set()
def debug(self):
# debug a frame up.
@@ -1638,7 +1639,7 @@
pseudo_log_file = StringIO()
def _get_log_contents_for_weird_testtools_api():
return [pseudo_log_file.getvalue().decode(
- "utf-8", "replace").encode("utf-8")]
+ "utf-8", "replace").encode("utf-8")]
self.addDetail("log", content.Content(content.ContentType("text",
"plain", {"charset": "utf8"}),
_get_log_contents_for_weird_testtools_api))
@@ -2066,6 +2067,9 @@
# so we will avoid using it on all platforms, just to
# make sure the code path is used, and we don't break on win32
cleanup_environment()
+ # Include the subprocess's log file in the test details, in case
+ # the test fails due to an error in the subprocess.
+ self._add_subprocess_log(trace._get_bzr_log_filename())
command = [sys.executable]
# frozen executables don't need the path to bzr
if getattr(sys, "frozen", None) is None:
@@ -2083,6 +2087,33 @@
return process
+ def _add_subprocess_log(self, log_file_path):
+ if len(self._log_files) == 0:
+ # Register an addCleanup func. We do this on the first call to
+ # _add_subprocess_log rather than in TestCase.setUp so that this
+ # addCleanup is registered after any cleanups for tempdirs that
+ # subclasses might create, which will probably remove the log file
+ # we want to read.
+ self.addCleanup(self._subprocess_log_cleanup)
+ # self._log_files is a set, so if a log file is reused we won't grab it
+ # twice.
+ self._log_files.add(log_file_path)
+
+ def _subprocess_log_cleanup(self):
+ for count, log_file_path in enumerate(self._log_files):
+ # We use buffer_now=True to avoid holding the file open beyond
+ # the life of this function, which might interfere with e.g.
+ # cleaning tempdirs on Windows.
+ # XXX: Testtools 0.9.5 doesn't have the content_from_file helper
+ #detail_content = content.content_from_file(
+ # log_file_path, buffer_now=True)
+ with open(log_file_path, 'rb') as log_file:
+ log_file_bytes = log_file.read()
+ detail_content = content.Content(content.ContentType("text",
+ "plain", {"charset": "utf8"}), lambda: [log_file_bytes])
+ self.addDetail("start_bzr_subprocess-log-%d" % (count,),
+ detail_content)
+
def _popen(self, *args, **kwargs):
"""Place a call to Popen.
=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt 2011-05-31 12:13:05 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt 2011-06-01 03:27:06 +0000
@@ -96,13 +96,19 @@
* Fix spurious test failure on OSX for WorkingTreeFormat2.
(Vincent Ladeuil, #787942)
+
* Skip ``utextwrap`` tests when ``sphinx`` breaks text_wrap by an hostile
monkeypatch to textwrap.TextWrapper.wordsep_re.
(Vincent Ladeuil, #785098)
+* Show log file contents from subprocesses started by
+ `start_bzr_subprocess` in test failure details. This may help diagnose
+ strange hangs and failures involving subprocesses. (Andrew Bennetts)
+
* Multiple ``selftest --exclude`` options are now combined instead of
overriding each other. (Vincent Ladeuil, #746991)
+
bzr 2.4b3
#########
More information about the bazaar-commits
mailing list