コード例 #1
0
ファイル: local.py プロジェクト: willfrey/cosmic-ray
def _execute_work_item(work_item):
    log.info('Executing worker in %s, PID=%s', _workspace.clone_dir,
             os.getpid())

    with excursion(_workspace.clone_dir):
        result = worker(work_item.module_path, _config.python_version,
                        work_item.operator_name, work_item.occurrence,
                        _config.test_command, _config.timeout)

    return work_item.job_id, result
コード例 #2
0
ファイル: test_worker.py プロジェクト: sixty-north/cosmic-ray
def test_no_test_return_value(path_utils, data_dir, python_version):
    with path_utils.excursion(data_dir):
        result = worker(
            Path("a/b.py"), python_version, 'core/ReplaceTrueWithFalse', 100,
            'python -m unittest tests', 1000)
        expected = WorkResult(
            output=None,
            test_outcome=None,
            diff=None,
            worker_outcome=WorkerOutcome.NO_TEST)
        assert result == expected
コード例 #3
0
ファイル: local.py プロジェクト: sixty-north/cosmic-ray
def _execute_work_item(work_item):
    log.info('Executing worker in %s, PID=%s', _workspace.clone_dir, os.getpid())

    os.chdir(_workspace.clone_dir)

    result = worker(
        work_item.module_path,
        _config.python_version,
        work_item.operator_name,
        work_item.occurrence,
        _workspace.replace_variables(_config.test_command),
        _config.timeout)

    return work_item.job_id, result
コード例 #4
0
def worker_task(work_item, config):
    """The celery task which performs a single mutation and runs a test suite.

    Args:
        work_item: A dict describing a WorkItem.
        config: The configuration to use for the test execution.

    Returns: An updated WorkItem
    """
    _ensure_workspace(config)

    result = worker(work_item.module_path, config.python_version,
                    work_item.operator_name, work_item.occurrence,
                    config.test_command, config.timeout)
    return work_item.job_id, result
コード例 #5
0
def test_no_test_return_value():
    with extend_path(DATA_DIR), excursion(DATA_DIR):
        test_runner = get_test_runner("unittest", ".")
        result = worker("a.b", zero_iteration_loop.ZeroIterationLoop, 100,
                        test_runner)
        expected = WorkItem(data=None,
                            test_outcome=None,
                            worker_outcome=WorkerOutcome.NO_TEST,
                            diff=None,
                            module=None,
                            operator=None,
                            occurrence=None,
                            line_number=None,
                            command_line=None,
                            job_id=None)

        assert result == expected
コード例 #6
0
def worker_task(work_item, config):
    """The celery task which performs a single mutation and runs a test suite.

    This runs `cosmic-ray worker` in a subprocess and returns the results,
    passing `config` to it via stdin.

    Args:
        work_item: A dict describing a WorkItem.
        config: The configuration to use for the test execution.

    Returns: An updated WorkItem
    """
    global _workspace

    _ensure_workspace(config)

    result = worker(
        work_item.module_path,
        config.python_version,
        work_item.operator_name,
        work_item.occurrence,
        config.test_command(_workspace.python_executable),
        config.timeout)
    return work_item.job_id, result
コード例 #7
0
ファイル: worker.py プロジェクト: sixty-north/cosmic-ray
def worker_task(work_item, config):
    """The celery task which performs a single mutation and runs a test suite.

    This runs `cosmic-ray worker` in a subprocess and returns the results,
    passing `config` to it via stdin.

    Args:
        work_item: A dict describing a WorkItem.
        config: The configuration to use for the test execution.

    Returns: An updated WorkItem
    """
    global _workspace

    _ensure_workspace(config)

    result = worker(
        work_item.module_path,
        config.python_version,
        work_item.operator_name,
        work_item.occurrence,
        config.test_command,
        config.timeout)
    return work_item.job_id, result