'Helper function for running an individual test.
The caller wraps this to trap and handle exceptions.
Args:
test_name: The test being run.
spec: The test specification profile.
This argument will be pruned as values are consumed from it.'

def run_test_profile_helper(self, test_name, spec):

    quota = spec.pop('quota', {})
    command = self.make_test_command_or_none(test_name, spec)
    if (command is None):
        return
    capture = CommandOutputMediator(test_name)
    logging.info('Acquiring    quota    for    test    "%s"...', test_name)
    quota_tracker = self.__quota_tracker
    acquired_quota = quota_tracker.acquire_all_safe(test_name, quota)
    if acquired_quota:
        logging.info('"%s"    acquired    quota    %s', test_name, acquired_quota)
    execute_time = None
    start_time = time.time()
    try:
        logging.info('Scheduling    "%s"...', test_name)
        self.__semaphore.acquire(True)
        execute_time = time.time()
        wait_time = int(((execute_time - start_time) + 0.5))
        if (wait_time > 1):
            logging.info('"%s"    had    a    semaphore    contention    for    %d    secs.', test_name, wait_time)
        logging.info('Executing    "%s"...', test_name)
        logging.debug('Running    %s', '    '.join(command))
        result = run_and_monitor('    '.join(command), echo=False, observe_stdout=capture.capture_stdout, observe_stderr=capture.capture_stderr)
    finally:
        logging.info('Finished    executing    "%s"...', test_name)
        self.__semaphore.release()
        if acquired_quota:
            quota_tracker.release_all_safe(test_name, acquired_quota)
    capture.flush()
    end_time = time.time()
    delta_time = int(((end_time - execute_time) + 0.5))
    with self.__lock:
        if (result.returncode == 0):
            logging.info('%s    PASSED    after    %d    secs', test_name, delta_time)
            self.__passed.append((test_name, result.stdout))
        else:
            logging.info('FAILED    %s    after    %d    secs', test_name, delta_time)
            self.__failed.append((test_name, result.stderr))
