'L{DistTrialRunner} checks if the test directory is already locked, and
if it is generates a name based on it.'

def test_runUsedDirectory(self):

    class FakeReactorWithLock(FakeReactor, ):
        def spawnProcess(oself, worker, *args, **kwargs):
            self.assertEqual(os.path.abspath(worker._logDirectory), os.path.abspath(os.path.join((workingDirectory + '-1'), str(oself.spawnCount))))
            localLock = FilesystemLock((workingDirectory + '-1.lock'))
            self.assertFalse(localLock.lock())
            oself.spawnCount += 1
            worker.makeConnection(FakeTransport())
            worker._ampProtocol.run = (lambda *args: succeed(None))
    newDirectory = self.mktemp()
    os.mkdir(newDirectory)
    workingDirectory = os.path.join(newDirectory, '_trial_temp')
    lock = FilesystemLock((workingDirectory + '.lock'))
    lock.lock()
    self.addCleanup(lock.unlock)
    self.runner._workingDirectory = workingDirectory
    fakeReactor = FakeReactorWithLock()
    suite = TrialSuite()
    for i in range(10):
        suite.addTest(TestCase())
    self.runner.run(suite, fakeReactor)
