Пример #1
0
    def execute_test_case(
        self,
        settings: TestCaseExecutionSettings,
    ) -> ProcessResultReporter:
        from exactly_lib.processing.standalone import processor

        the_processor = processor.Processor(
            self._test_case_definition, _resolve_os_services(),
            self._test_suite_definition.configuration_section_parser,
            self._mem_buff_size)
        return processor.ProcessorExecutionReporter(the_processor, settings)
Пример #2
0
    def _run(self, suite_file_name: str,
             run_as_part_of_explicit_suite: Optional[Path]):
        # ARRANGE #

        default_test_case_handling = setup_with_null_act_phase_and_null_preprocessing(
        )

        conf_parser_with_no_instructions = configuration_section_parser({})

        test_case_definition = test_case_definition_with_only_assert_phase_instructions(
            [])

        case_file = File.empty('test.case')

        suite_file = File(
            suite_file_name,
            lines_content([
                phase_names.ASSERT.syntax,
                ' '.join([
                    INCLUDING_DIRECTIVE_INFO.singular_name,
                    'non-existing-file.txt'
                ]),
            ]))

        suite_and_case_files = DirContents([
            suite_file,
            case_file,
        ])

        processor = sut.Processor(
            test_case_definition,
            os_services_access.new_for_cmd_exe(
                CommandExecutorThatJustReturnsConstant()),
            conf_parser_with_no_instructions, 2**10)

        with tmp_dir_as_cwd(suite_and_case_files) as tmp_dir:
            execution_settings = TestCaseExecutionSettings(
                case_file.name_as_path,
                tmp_dir,
                ReportingOption.STATUS_CODE,
                default_test_case_handling,
                run_as_part_of_explicit_suite=run_as_part_of_explicit_suite)
            # ACT #
            actual_result = capture_output_from_processor(
                processor, execution_settings)

        # ASSERT #

        expectation = is_result_for_exit_value(
            exit_values.NO_EXECUTION__FILE_ACCESS_ERROR)
        expectation.apply_without_message(self, actual_result)
Пример #3
0
    def run(self, parsing_setup: TestCaseParsingSetup,
            test_case_handling_setup: TestCaseHandlingSetup,
            test_suite_definition: TestSuiteDefinition, case_file: Path,
            explicit_suite_file_path: Optional[Path]) -> SubProcessResult:
        processor = sut.Processor(
            TestCaseDefinition(parsing_setup,
                               _predefined_properties.new_empty()),
            os_services_access.new_for_cmd_exe(
                CommandExecutorThatJustReturnsConstant()),
            test_suite_definition.configuration_section_parser, 2**10)

        execution_settings = TestCaseExecutionSettings(
            case_file,
            case_file.parent,
            ReportingOption.STATUS_CODE,
            test_case_handling_setup,
            run_as_part_of_explicit_suite=explicit_suite_file_path)
        return capture_output_from_processor(processor, execution_settings)
Пример #4
0
    def _run(self,
             suite_file_name: str,
             suite_file_overriding: Optional[Path]):
        default_test_case_handling = setup_with_null_act_phase_and_null_preprocessing()

        suite_conf_instruction = SuiteConfInstructionThatSets(
            preprocessor=preprocessor_that_gives_const_source_with_single_assert_instruction(
                ASSERT_PHASE_INSTRUCTION_THAT_PASS_IFF_STDOUT_IS_SUCCESS_INDICATOR_STRING__NAME),
            act_phase_setup=act_setup_that_prints_single_string_on_stdout(SUCCESS_INDICATOR_STRING))

        suite_conf_instructions = {
            SUITE_CONF_INSTRUCTION_THAT_SETS_PREPROCESSOR_AND_ACTOR__NAME:
                single_instruction_setup(SUITE_CONF_INSTRUCTION_THAT_SETS_PREPROCESSOR_AND_ACTOR__NAME,
                                         suite_conf_instruction)

        }

        suite_conf_parser = configuration_section_parser(suite_conf_instructions)

        test_case_definition = test_case_definition_with_only_assert_phase_instructions([
            (
                ASSERT_PHASE_INSTRUCTION_THAT_PASS_IFF_STDOUT_IS_SUCCESS_INDICATOR_STRING__NAME,
                assert_phase_instruction_that_pass_iff_stdout_is_success_indicator_string(SUCCESS_INDICATOR_STRING)
            ),
            (
                ASSERT_PHASE_INSTRUCTION_THAT_FAILS_UNCONDITIONALLY__NAME,
                ASSERT_PHASE_INSTRUCTION_THAT_FAILS_UNCONDITIONALLY,
            ),
        ])
        processor = sut.Processor(test_case_definition,
                                  os_services_access.new_for_cmd_exe(CommandExecutorThatJustReturnsConstant()),
                                  suite_conf_parser,
                                  2 ** 10)

        suite_file = File(
            suite_file_name,
            test_suite_source_with_single_conf_instruction(
                SUITE_CONF_INSTRUCTION_THAT_SETS_PREPROCESSOR_AND_ACTOR__NAME)
        )
        case_file = File(
            'test.case',
            test_case_source_with_single_assert_phase_instruction(
                ASSERT_PHASE_INSTRUCTION_THAT_FAILS_UNCONDITIONALLY__NAME)
        )

        sub_dir_path = Path('sub-dir')

        suite_and_case_files = DirContents([
            suite_file,
            case_file,
        ]).in_dir(str(sub_dir_path))

        explicit_suite_file_path = None
        if suite_file_overriding:
            explicit_suite_file_path = sub_dir_path / suite_file_overriding

        with tmp_dir_as_cwd(suite_and_case_files) as tmp_dir:
            execution_settings = TestCaseExecutionSettings(sub_dir_path / case_file.name_as_path,
                                                           tmp_dir / sub_dir_path,
                                                           ReportingOption.STATUS_CODE,
                                                           default_test_case_handling,
                                                           run_as_part_of_explicit_suite=explicit_suite_file_path)

            # ACT #
            actual_result = capture_output_from_processor(processor,
                                                          execution_settings)
        # ASSERT #
        if actual_result.exitcode != exit_values.EXECUTION__PASS.exit_code:
            self.fail(_error_message(actual_result))