Ejemplo n.º 1
0
    def test_two_populators_populate_hds(self):
        # ARRANGE #
        expected_dir_contents = fs.DirContents([self.first_file,
                                                self.second_file])
        first_populator = sut.hds_case_dir_contents(fs.DirContents([self.first_file]))
        second_populator = sut.hds_case_dir_contents(fs.DirContents([self.second_file]))
        populator = sut.multiple([first_populator,
                                  second_populator])
        expectation = f_asrt.dir_contains_exactly(expected_dir_contents)

        with home_directory_structure() as hds:
            # ACT #
            populator.populate_hds(hds)
            # ASSERT #
            expectation.apply_with_message(self, hds.case_dir,
                                           'contents of HDS/case dir')
Ejemplo n.º 2
0
    def test_quoting(self):
        interpreter_exe_file_name = 'interpreter with space'
        src_file_name = 'file.src'

        self._check_both_single_and_multiple_line_source(
            "= {actor_option} 'interpreter with space' arg2 \"arg 3\"",
            [src_file_name],
            asrt.is_empty_sequence,
            is_exe_file_command_for_source_file(interpreter_exe_file_name,
                                                src_file_name,
                                                ['arg2', 'arg 3']),
            hds_contents=hds_populators.multiple([
                exe_file_in_interpreter_default_relativity_dir(
                    interpreter_exe_file_name),
                file_in_hds_act_dir(src_file_name),
            ]),
        )
Ejemplo n.º 3
0
    def test_command_with_arguments(self):
        interpreter_exe_file_name = 'interpreter'
        src_file_name = 'file.src'

        self._check_both_single_and_multiple_line_source(
            ' = {actor_option}   interpreter   arg1     -arg2   ',
            ['file.src'],
            asrt.is_empty_sequence,
            is_exe_file_command_for_source_file(interpreter_exe_file_name,
                                                src_file_name,
                                                ['arg1', '-arg2']),
            hds_contents=hds_populators.multiple([
                exe_file_in_interpreter_default_relativity_dir(
                    interpreter_exe_file_name),
                file_in_hds_act_dir(src_file_name),
            ]),
        )
Ejemplo n.º 4
0
    def runTest(self):
        # ARRANGE #
        actor = sut.actor(COMMAND_THAT_RUNS_PYTHON_PROGRAM_FILE)

        exe_file = fs.python_executable_file(
            'program-name',
            py_programs.exit_with_0()
        )
        text_until_end_of_line = 'some {}invalidly quoted text'.format(SOFT_QUOTE_CHAR)

        existing_path_relativity = relativity_options.conf_rel_hds(RelHdsOptionType.REL_HDS_CASE)

        existing_path_argument = path_arguments.RelOptPathArgument(
            'existing-path',
            existing_path_relativity.relativity,
        )
        act_contents = ab.sequence__r([
            ab.singleton(exe_file.name),
            program_arguments.existing_path(
                existing_path_argument
            ),
            program_arguments.remaining_part_of_current_line_as_literal(text_until_end_of_line),
        ])

        def get_command_assertion(tcds: TestCaseDs) -> Assertion[Command]:
            symbols = SymbolTable.empty()
            return asrt_command.matches_command(
                asrt.anything_goes(),
                asrt.equals([
                    str(relativity_configurations.ATC_FILE
                        .named_file_conf(exe_file.name)
                        .path_sdv
                        .resolve(symbols)
                        .value_of_any_dependency__d(tcds)
                        .primitive
                        ),
                    str(existing_path_relativity
                        .named_file_conf(existing_path_argument.name)
                        .path_sdv
                        .resolve(symbols)
                        .value_of_any_dependency__d(tcds)
                        .primitive
                        ),
                    text_until_end_of_line,
                ])
            )

        act_instruction = instr([act_contents.as_str])
        executor_that_records_arguments = CommandExecutorThatRecordsArguments()
        # ACT & ASSERT #
        integration_check.check_execution(
            self,
            actor,
            [act_instruction],
            arrangement_w_tcds(
                process_execution=ProcessExecutionArrangement(
                    os_services=os_services_access.new_for_cmd_exe(executor_that_records_arguments)
                ),
                hds_contents=hds_populators.multiple([
                    relativity_configurations.ATC_FILE.populator_for_relativity_option_root__hds(
                        fs.DirContents([exe_file])
                    ),
                    existing_path_relativity.populator_for_relativity_option_root__hds(
                        fs.DirContents([fs.File.empty(existing_path_argument.name)])
                    ),
                ])
            ),
            Expectation(
                after_execution=ExecutedCommandAssertion(
                    executor_that_records_arguments,
                    get_command_assertion,
                )
            ),
        )