~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/__init__.py

  • Committer: Martin Pool
  • Date: 2005-09-18 00:57:26 UTC
  • mto: (1185.8.2) (974.1.91)
  • mto: This revision was merged to the branch mainline in revision 1390.
  • Revision ID: mbp@sourcefrog.net-20050918005726-9cbc228aeeaf4849
- run_bzr_captured also includes logged errors in 
  captured stderr
- simple test that exercises this

Show diffs side-by-side

added added

removed removed

Lines of Context:
105
105
        Much of the old code runs bzr by forking a new copy of Python, but
106
106
        that is slower, harder to debug, and generally not necessary.
107
107
 
 
108
        This runs bzr through the interface that catches and reports
 
109
        errors, and with logging set to something approximating the
 
110
        default, so that error reporting can be checked.
 
111
 
108
112
        argv -- arguments to invoke bzr
109
113
        retcode -- expected return code, or None for don't-care.
110
114
        """
111
115
        stdout = StringIO()
112
116
        stderr = StringIO()
113
117
        self.log('run bzr: %s', ' '.join(argv))
114
 
        result = self.apply_redirected(None, stdout, stderr,
115
 
                                       bzrlib.commands.run_bzr, argv)
 
118
        handler = logging.StreamHandler(stderr)
 
119
        handler.setFormatter(bzrlib.trace.QuietFormatter())
 
120
        handler.setLevel(logging.INFO)
 
121
        logger = logging.getLogger('')
 
122
        logger.addHandler(handler)
 
123
        try:
 
124
            result = self.apply_redirected(None, stdout, stderr,
 
125
                                           bzrlib.commands.run_bzr_catch_errors,
 
126
                                           argv)
 
127
        finally:
 
128
            logger.removeHandler(handler)
116
129
        out = stdout.getvalue()
117
130
        err = stderr.getvalue()
118
131
        if out: