def test_get_execution_plan_target_step_case():
    mock_config_unit = get_mock_config_unit()
    step_name = 'dependency_2.dependency_2_build_step_1'
    execution_plan = get_execution_plan(mock_config_unit, step_name)
    prefixed_names = [prefixed_name for _, _, prefixed_name in execution_plan]

    assert ('dependency_1.sub_dependency_1.sub_dependency_1_check_step_1'
            not in prefixed_names)
    assert ('dependency_1.dependency_1_check_step_1' not in prefixed_names)
    assert ('root_check_step_1' not in prefixed_names)

    assert ('dependency_2.dependency_2_check_step_1' in prefixed_names)
    assert ('dependency_2.dependency_2_build_step_1' in prefixed_names)
    # clean up no matter what
    assert ('dependency_2.dependency_2_cleanup_step_1' in prefixed_names)

    step_name = 'dependency_1.dependency_1_check_step_1'
    execution_plan = get_execution_plan(mock_config_unit, step_name)
    prefixed_names = [prefixed_name for _, _, prefixed_name in execution_plan]

    assert ('dependency_1.sub_dependency_1.sub_dependency_1_check_step_1'
            not in prefixed_names)  # check do not trigger dependencies
    assert ('dependency_1.dependency_1_check_step_1' in prefixed_names)
    assert ('dependency_1.dependency_1_cleanup_step_1' in prefixed_names)

    step_name = 'dependency_1.dependency_1_build_step_1'
    execution_plan = get_execution_plan(mock_config_unit, step_name)
    prefixed_names = [prefixed_name for _, _, prefixed_name in execution_plan]

    assert ('dependency_1.sub_dependency_1.sub_dependency_1_check_step_1'
            in prefixed_names)  # build do trigger dependencies
def test_get_execution_plan_loop_should_be_detected():
    mock_config_unit = get_mock_config_unit()
    mock_config_unit.dependencies[0].dependencies[0] = \
        mock_config_unit

    exception_count = 0
    try:
        get_execution_plan(mock_config_unit)
    except CircularDependencyException:
        exception_count += 1

    assert (exception_count == 1)
Пример #3
0
def get_debug_information(config_unit: ConfigUnit):
    execution_plan = get_execution_plan(config_unit)
    output_elements = [
        _get_hash_debug_information(execution_plan),
        _get_execution_plan_debug_information(execution_plan)
    ]

    return '\n\n'.join(output_elements)
    def _load_execution_plan_units(self):
        execution_plan = get_execution_plan(self._root_config_unit)

        for config_unit, _, _ in execution_plan:
            if config_unit in self._execution_plan_units:
                continue

            self._execution_plan_units.append(config_unit)
def test_get_execution_plan_target_dependency_case():
    mock_config_unit = get_mock_config_unit()
    step_name = 'dependency_2'
    execution_plan = get_execution_plan(mock_config_unit, step_name)
    prefixed_names = [prefixed_name for _, _, prefixed_name in execution_plan]

    assert ('dependency_2.dependency_2_check_step_1' in prefixed_names)
    assert ('dependency_1.dependency_1_check_step_1' not in prefixed_names)
    assert ('root_check_step_1' not in prefixed_names)
Пример #6
0
def run(
        root_config_unit: ConfigUnit,
        target_step_name: Optional[str] = None,
        summary: bool = False,
        limit_output: bool = False) \
        -> Tuple[int, List[str]]:
    plan = get_execution_plan(root_config_unit, target_step_name)
    status_history = run_plan(plan)
    return get_successful_flag_and_combined_output(status_history, summary,
                                                   limit_output)
def test_get_execution_plan_nominal_case():
    mock_config_unit = get_mock_config_unit()
    execution_plan = get_execution_plan(mock_config_unit)
    prefixed_names = [prefixed_name for _, _, prefixed_name in execution_plan]

    assert ('dependency_1.sub_dependency_1.sub_dependency_1_check_step_1'
            in prefixed_names)
    assert ('dependency_1.dependency_1_check_step_1' in prefixed_names)
    assert ('root_check_step_1' in prefixed_names)

    # All checks should be performed before build
    assert (prefixed_names.index('root_build_step_1') >
            prefixed_names.index('dependency_1.dependency_1_check_step_1'))
    assert (prefixed_names.index('dependency_1.dependency_1_check_step_1') >
            prefixed_names.index(
                'dependency_1.sub_dependency_1.sub_dependency_1_check_step_1'))
Пример #8
0
 def _list(self):
     config_unit = self._get_config_unit()
     execution_plan = get_execution_plan(config_unit)
     step_names = \
         [prefixed_step_name for _, _, prefixed_step_name in execution_plan]
     print('\n'.join(step_names))