Rev 6083: Yes we can... debug blackbox tests interactively in file:///home/vila/src/bzr/bugs/412201-mv-case-insensitive/

Vincent Ladeuil v.ladeuil+lp at free.fr
Fri Aug 19 14:58:55 UTC 2011


At file:///home/vila/src/bzr/bugs/412201-mv-case-insensitive/

------------------------------------------------------------
revno: 6083
revision-id: v.ladeuil+lp at free.fr-20110819145855-oubrcf59cokg2bct
parent: pqm at pqm.ubuntu.com-20110818042306-neji85pljf86z885
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 412201-mv-case-insensitive
timestamp: Fri 2011-08-19 16:58:55 +0200
message:
  Yes we can... debug blackbox tests interactively
-------------- next part --------------
=== modified file 'bzrlib/debug.py'
--- a/bzrlib/debug.py	2011-08-12 16:25:56 +0000
+++ b/bzrlib/debug.py	2011-08-19 14:58:55 +0000
@@ -24,6 +24,8 @@
 for a list of the available options.
 """
 
+import pdb
+import sys
 
 debug_flags = set()
 
@@ -36,3 +38,27 @@
     c = config.GlobalStack()
     for f in c.get('debug_flags'):
         debug_flags.add(f)
+
+
+class BzrPdb(pdb.Pdb):
+    """Pdb using original stdin and stdout.
+
+    When debugging blackbox tests, sys.stdin and sys.stdout are captured for
+    test purposes and cannot be used for interactive debugging. This class uses
+    the origianl stdin/stdout to allow such use.
+
+    Instead of doing:
+
+       import pdb; pdb.set_trace()
+
+    you can do:
+
+       from bzrlib import debug; debug.set_trace()
+    """
+
+    def __init__(self):
+        pdb.Pdb.__init__(self, stdin=sys.__stdin__, stdout=sys.__stdout__)
+
+
+def set_trace():
+    BzrPdb().set_trace(sys._getframe().f_back)

=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt	2011-08-18 04:23:06 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt	2011-08-19 14:58:55 +0000
@@ -192,6 +192,9 @@
    suite.  This can include new facilities for writing tests, fixes to 
    spurious test failures and changes to the way things should be tested.
 
+* Blackbox tests can be debugged interactively (see bzrlib.debug.BzrPdb for
+  details). (Vincent Ladeuil)
+
 * `BranchBuilder.build_snapshot` now supports a "flush" action.  This
   cleanly and reliably allows tests using `BranchBuilder` to construct
   branches that e.g. rename files out of a directory and unversion that



More information about the bazaar-commits mailing list