~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-13 00:47:09 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-20050913004709-ec9e0610b4239d5d
- name test tmpdirs sequentially, not randomly

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import tempfile
21
21
import os
22
22
import sys
 
23
import errno
23
24
import subprocess
 
25
import shutil
24
26
 
25
27
from testsweet import run_suite
26
28
import bzrlib.commands
189
191
            self.fail("contents of %s not as expected")
190
192
 
191
193
    def _make_test_root(self):
192
 
        import os
193
 
        import shutil
194
 
        import tempfile
195
 
        
196
194
        if TestCaseInTempDir.TEST_ROOT is not None:
197
195
            return
198
 
        TestCaseInTempDir.TEST_ROOT = os.path.abspath(
199
 
                                 tempfile.mkdtemp(suffix='.tmp',
200
 
                                                  prefix=self._TEST_NAME + '-',
201
 
                                                  dir=os.curdir))
202
 
    
 
196
        i = 0
 
197
        while True:
 
198
            root = 'test%04d.tmp' % i
 
199
            try:
 
200
                os.mkdir(root)
 
201
            except IOError, e:
 
202
                if e.errno == errno.EEXISTS:
 
203
                    continue
 
204
                else:
 
205
                    raise
 
206
            # successfully created
 
207
            TestCaseInTempDir.TEST_ROOT = os.path.abspath(root)
 
208
            break
203
209
        # make a fake bzr directory there to prevent any tests propagating
204
210
        # up onto the source directory's real branch
205
211
        os.mkdir(os.path.join(TestCaseInTempDir.TEST_ROOT, '.bzr'))