~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 01:18:57 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-20050918011857-4e68e60cbbcfcaaf
- remove code to test bzr externally - now all tests run in-process

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import os
22
22
import sys
23
23
import errno
24
 
import subprocess
25
24
from warnings import warn
26
25
from cStringIO import StringIO
27
26
 
271
270
        os.chdir(self._currentdir)
272
271
        super(TestCaseInTempDir, self).tearDown()
273
272
 
274
 
    def _formcmd(self, cmd):
275
 
        if isinstance(cmd, basestring):
276
 
            cmd = cmd.split()
277
 
        if cmd[0] == 'bzr':
278
 
            cmd[0] = self.BZRPATH
279
 
            if self.OVERRIDE_PYTHON:
280
 
                cmd.insert(0, self.OVERRIDE_PYTHON)
281
 
        self.log('$ %r' % cmd)
282
 
        return cmd
283
 
 
284
 
    def runcmd(self, cmd, retcode=0):
285
 
        """Run one command and check the return code.
286
 
 
287
 
        Returns a tuple of (stdout,stderr) strings.
288
 
 
289
 
        If a single string is based, it is split into words.
290
 
        For commands that are not simple space-separated words, please
291
 
        pass a list instead."""
292
 
        warn('TestBase.runcmd is deprecated', stacklevel=2)
293
 
        cmd = self._formcmd(cmd)
294
 
        self.log('$ ' + ' '.join(cmd))
295
 
        actual_retcode = subprocess.call(cmd, stdout=self._log_file,
296
 
                                         stderr=self._log_file)
297
 
        if retcode != actual_retcode:
298
 
            raise CommandFailed("test failed: %r returned %d, expected %d"
299
 
                                % (cmd, actual_retcode, retcode))
300
 
 
301
 
    def backtick(self, cmd, retcode=0):
302
 
        """Run a command and return its output"""
303
 
        warn('TestBase.backtick is deprecated', stacklevel=2)
304
 
        cmd = self._formcmd(cmd)
305
 
        child = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=self._log_file)
306
 
        outd, errd = child.communicate()
307
 
        self.log(outd)
308
 
        actual_retcode = child.wait()
309
 
 
310
 
        outd = outd.replace('\r', '')
311
 
 
312
 
        if retcode != actual_retcode:
313
 
            raise CommandFailed("test failed: %r returned %d, expected %d"
314
 
                                % (cmd, actual_retcode, retcode))
315
 
 
316
 
        return outd
317
 
 
318
 
 
319
 
 
 
273
    
320
274
    def build_tree(self, shape):
321
275
        """Build a test tree according to a pattern.
322
276