Rev 4691: (robertc) Support dropping into pdb on failing tests. (Robert Collins) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Sep 16 03:52:18 BST 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4691 [merge]
revision-id: pqm at pqm.ubuntu.com-20090916025214-6cyz9179xs7f1w70
parent: pqm at pqm.ubuntu.com-20090915060711-9vf2j4piarn8fgp9
parent: robertc at robertcollins.net-20090916021132-7p0m4ltyr3f9ezb0
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2009-09-16 03:52:14 +0100
message:
  (robertc) Support dropping into pdb on failing tests. (Robert Collins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
=== modified file 'NEWS'
--- a/NEWS	2009-09-15 02:57:23 +0000
+++ b/NEWS	2009-09-16 02:52:14 +0000
@@ -115,6 +115,9 @@
 * Passing ``--lsprof-tests -v`` to bzr selftest will cause lsprof output to
   be output for every test. Note that this is very verbose! (Robert Collins)
 
+* Setting ``BZR_TEST_PDB=1`` when running selftest will cause a pdb
+  post_mortem to be triggered when a test failure occurs. (Robert Collins)
+
 * Test parameterisation now does a shallow copy, not a deep copy of the test
   to be parameterised. This is not expected to break external use of test
   parameterisation, and is substantially faster. (Robert Collins)

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2009-09-15 01:52:34 +0000
+++ b/bzrlib/builtins.py	2009-09-16 02:52:14 +0000
@@ -3340,6 +3340,9 @@
     Tests that need working space on disk use a common temporary directory,
     typically inside $TMPDIR or /tmp.
 
+    If you set BZR_TEST_PDB=1 when running selftest, failing tests will drop
+    into a pdb postmortem session.
+
     :Examples:
         Run only tests relating to 'ignore'::
 

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2009-09-09 17:21:56 +0000
+++ b/bzrlib/tests/__init__.py	2009-09-14 02:15:45 +0000
@@ -298,6 +298,7 @@
         elif isinstance(err[1], UnavailableFeature):
             return self.addNotSupported(test, err[1].args[0])
         else:
+            self._post_mortem()
             unittest.TestResult.addError(self, test, err)
             self.error_count += 1
             self.report_error(test, err)
@@ -315,6 +316,7 @@
         if isinstance(err[1], KnownFailure):
             return self._addKnownFailure(test, err)
         else:
+            self._post_mortem()
             unittest.TestResult.addFailure(self, test, err)
             self.failure_count += 1
             self.report_failure(test, err)
@@ -404,6 +406,11 @@
             self.stream.writeln(self.separator2)
             self.stream.writeln("%s" % err)
 
+    def _post_mortem(self):
+        """Start a PDB post mortem session."""
+        if os.environ.get('BZR_TEST_PDB', None):
+            import pdb;pdb.post_mortem()
+
     def progress(self, offset, whence):
         """The test is adjusting the count of tests to run."""
         if whence == SUBUNIT_SEEK_SET:




More information about the bazaar-commits mailing list