'Drive a L{LocalWorkerAMP} instance, iterating the tests and calling
C{run} for every one of them.
@param worker: The L{LocalWorkerAMP} to drive.
@param result: The global L{DistReporter} instance.
@param testCases: The global list of tests to iterate.
@param cooperate: The cooperate function to use, to be customized in
tests.
@type cooperate: C{function}
@return: A C{Deferred} firing when all the tests are finished.'

def _driveWorker(self, worker, result, testCases, cooperate):

    def resultErrback(error, case):
        result.original.addFailure(case, error)
        return error
    def task(case):
        d = worker.run(case, result)
        d.addErrback(resultErrback, case)
        return d
    return cooperate((task(case) for case in testCases)).whenDone()
