Beispiel #1
0
    def test_possibility_to_have_sds_path_references_in_argument(self):
        file_name_of_referenced_file = 'file-name.txt'
        symbol = ConstantSuffixPathDdvSymbolContext(
            'symbol_name', RelOptionType.REL_TMP, file_name_of_referenced_file)

        executable = 'the-executable'

        command_line = '{executable} {symbol}'.format(
            executable=executable,
            symbol=symbol.name__sym_ref_syntax,
        )

        arrangement = arrangement_w_tcds(
            hds_contents=relativity_configurations.ATC_FILE.
            populator_for_relativity_option_root__hds(
                fs.DirContents([
                    fs.python_executable_file(
                        executable,
                        PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES
                    )
                ])),
            symbol_table=symbol.symbol_table)

        expectation = Expectation(
            execute=eh_assertions.is_exit_code(0),
            symbol_usages=asrt.matches_singleton_sequence(
                symbol.reference_assertion__w_str_rendering),
            post_sds=PostSdsExpectation.constant(
                sub_process_result_from_execute=pr.stdout(
                    str_asrt.contains(file_name_of_referenced_file))),
        )

        check_execution(self, sut.actor(), [instr([command_line])],
                        arrangement, expectation)
Beispiel #2
0
    def runTest(self):
        # ARRANGE #
        exit_code_from_program = 0
        exe_file_in_path = fs.python_executable_file(
            'the-program',
            lines_content(py_program.exit_with_code(exit_code_from_program)),
        )
        program_symbol = StringConstantSymbolContext(
            'PROGRAM_NAME_SYMBOL',
            exe_file_in_path.name,
        )
        program_line = args.system_program_command_line(
            program_symbol.name__sym_ref_syntax).as_str

        with tmp_dir_in_path_with_files(DirContents([exe_file_in_path
                                                     ])) as environ:
            for source_case in valid_source_variants(program_line):
                with self.subTest(source_case.name):
                    # ACT & ASSERT #
                    integration_check.check_execution(
                        self,
                        sut.actor(),
                        [instr([program_line])],
                        arrangement_w_tcds(
                            symbol_table=program_symbol.symbol_table,
                            act_exe_input=AtcExeInputArr(environ=environ),
                        ),
                        Expectation(
                            symbol_usages=asrt.matches_singleton_sequence(
                                program_symbol.
                                reference_assertion__string__w_all_indirect_refs_are_strings
                            ),
                            execute=asrt_eh.is_exit_code(
                                exit_code_from_program)),
                    )
Beispiel #3
0
    def test_symbol_value_with_space_SHOULD_be_given_as_single_argument_to_program(
            self):
        symbol = StringConstantSymbolContext('symbol_name',
                                             'symbol value with space')

        expected_output = lines_content([symbol.str_value])

        executable_file_name = 'the-executable_file_name'

        command_line = '{executable_file_name} {symbol}'.format(
            executable_file_name=executable_file_name,
            symbol=symbol.name__sym_ref_syntax,
        )

        arrangement = arrangement_w_tcds(
            hds_contents=relativity_configurations.ATC_FILE.
            populator_for_relativity_option_root__hds(
                fs.DirContents([
                    fs.python_executable_file(
                        executable_file_name,
                        PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES
                    )
                ])),
            symbol_table=symbol.symbol_table)

        expectation = Expectation(
            symbol_usages=asrt.matches_sequence(
                [symbol.reference_assertion__w_str_rendering]),
            execute=eh_assertions.is_exit_code(0),
            post_sds=PostSdsExpectation.
            constant(sub_process_result_from_execute=pr.stdout(
                asrt.Equals(expected_output, 'CLI arguments, one per line'))),
        )
        check_execution(self, sut.actor(), [instr([command_line])],
                        arrangement, expectation)
    def _check_with_exit_code(self, exit_code: int):
        # ARRANGE #
        result = SubProcessResult(
            exitcode=exit_code,
            stdout='output on stdout',
            stderr='output on stderr',
        )

        command_py_program = py_program.program_that_prints_and_exits_with_exit_code(result)

        py_file = fs.File(
            'the-program.py',
            command_py_program,
        )
        program_wo_transformation = ProgramSymbolContext.of_sdv(
            'PROGRAM_SYMBOL',
            program_sdvs.interpret_py_source_file_that_must_exist(
                path_sdvs.of_rel_option_with_const_file_name(
                    RelOptionType.REL_HDS_CASE,
                    py_file.name,
                )
            )
        )

        source = args.program(
            args.symbol_ref_command_line(program_wo_transformation.name),
            transformation=TO_UPPER_CASE_TRANSFORMER.name__sym_ref_syntax)

        symbols = [
            program_wo_transformation,
            TO_UPPER_CASE_TRANSFORMER,
        ]
        # ACT & ASSERT #

        integration_check.check_execution(
            self,
            sut.actor(),
            [instr(source.as_arguments.lines)],
            arrangement_w_tcds(
                symbol_table=SymbolContext.symbol_table_of_contexts(symbols),
                hds_contents=hds_populators.contents_in(
                    RelHdsOptionType.REL_HDS_CASE,
                    DirContents([py_file]),
                )
            ),
            Expectation(
                symbol_usages=SymbolContext.references_assertion_of_contexts(symbols),
                execute=asrt_eh.is_exit_code(result.exitcode),
                post_sds=PostSdsExpectation.constant(
                    sub_process_result_from_execute=asrt_proc_result.matches_proc_result(
                        exit_code=asrt.equals(result.exitcode),
                        stdout=asrt.equals(result.stdout.upper()),
                        stderr=asrt.equals(result.stderr),
                    )
                )
            ),
        )
Beispiel #5
0
    def test_multiple_symbol_references_in_executable(self):
        sub_dir_of_home = 'sub-dir'
        dir_symbol = NameAndValue('dir_symbol_name',
                                  file_refs.rel_home_act(file_refs.constant_path_part(sub_dir_of_home)))

        executable_file_name_symbol = NameAndValue('executable_file_name_symbol_name',
                                                   'the-executable-file')

        argument = 'argument_string'

        expected_output = lines_content([argument])

        command_line = '{dir}/{file_name}  {argument} '.format(
            dir=symbol_reference_syntax_for_name(dir_symbol.name),
            file_name=symbol_reference_syntax_for_name(executable_file_name_symbol.name),
            argument=argument,
        )

        executable_file = fs.python_executable_file(
            executable_file_name_symbol.value,
            PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES)

        arrangement = Arrangement(
            hds_contents=contents_in(RelHomeOptionType.REL_HOME_ACT, fs.DirContents([
                fs.Dir(sub_dir_of_home, [executable_file])
            ])),
            symbol_table=SymbolTable({
                dir_symbol.name:
                    su.file_ref_constant_container(dir_symbol.value),

                executable_file_name_symbol.name:
                    su.string_constant_container(executable_file_name_symbol.value),
            })
        )

        expectation = Expectation(
            result_of_execute=eh_assertions.is_exit_code(0),
            sub_process_result_from_execute=pr.stdout(asrt.Equals(expected_output,
                                                                  'CLI arguments, one per line')),
            symbol_usages=equals_symbol_references([
                SymbolReference(dir_symbol.name,
                                path_or_string_reference_restrictions(PATH_RELATIVITY_VARIANTS_FOR_FILE_TO_RUN)),

                SymbolReference(executable_file_name_symbol.name,
                                PATH_COMPONENT_STRING_REFERENCES_RESTRICTION),
            ]),
        )
        check_execution(self,
                        sut.Parser(),
                        [instr([command_line])],
                        arrangement,
                        expectation)
Beispiel #6
0
 def runTest(self):
     with self.config.program_that_exits_with_code(87) as setup:
         self._check(
             setup.act_phase_instructions,
             arrangement_w_tcds(
                 symbol_table=setup.symbols,
                 hds_contents=_hds_pop_of(setup),
                 act_exe_input=AtcExeInputArr(environ=setup.environ),
             ),
             Expectation(
                 symbol_usages=setup.symbol_usages,
                 execute=eh_assertions.is_exit_code(87),
             ))
Beispiel #7
0
    def runTest(self):
        sub_dir_of_home = 'sub-dir'
        dir_symbol = ConstantSuffixPathDdvSymbolContext('dir_symbol_name',
                                                        RelOptionType.REL_HDS_ACT,
                                                        sub_dir_of_home,
                                                        PATH_RELATIVITY_VARIANTS_FOR_FILE_TO_RUN)

        source_file_name_symbol = StringConstantSymbolContext('source_file_name_symbol_name',
                                                              'the-source-file.py')

        argument = 'argument_string'

        expected_output = lines_content([argument])

        command_line = '{dir}/{file_name}  {argument} '.format(
            dir=dir_symbol.name__sym_ref_syntax,
            file_name=source_file_name_symbol.name__sym_ref_syntax,
            argument=argument,
        )

        executable_file = fs.File(
            source_file_name_symbol.str_value,
            PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES)

        arrangement = arrangement_w_tcds(
            hds_contents=contents_in(RelHdsOptionType.REL_HDS_ACT, fs.DirContents([
                fs.Dir(sub_dir_of_home, [executable_file])
            ])),
            symbol_table=SymbolContext.symbol_table_of_contexts([
                dir_symbol,
                source_file_name_symbol,
            ])
        )

        expectation = Expectation(
            symbol_usages=asrt.matches_sequence([
                dir_symbol.reference_assertion__path_or_string,
                source_file_name_symbol.reference_assertion__path_component,
            ]),
            execute=eh_assertions.is_exit_code(0),
            post_sds=PostSdsExpectation.constant(
                sub_process_result_from_execute=pr.stdout(asrt.Equals(expected_output,
                                                                      'CLI arguments, one per line'))
            ),
        )
        self._check(command_line,
                    arrangement,
                    expectation)
Beispiel #8
0
    def test_multiple_symbol_references_in_executable(self):
        sub_dir_of_home = 'sub-dir'
        dir_symbol = ConstantSuffixPathDdvSymbolContext(
            'dir_symbol_name', RelOptionType.REL_HDS_ACT, sub_dir_of_home,
            PATH_RELATIVITY_VARIANTS_FOR_FILE_TO_RUN)

        executable_file_name_symbol = StringConstantSymbolContext(
            'executable_file_name_symbol_name', 'the-executable-file')

        argument = 'argument_string'

        expected_output = lines_content([argument])

        command_line = '{dir}/{file_name}  {argument} '.format(
            dir=dir_symbol.name__sym_ref_syntax,
            file_name=executable_file_name_symbol.name__sym_ref_syntax,
            argument=argument,
        )

        executable_file = fs.python_executable_file(
            executable_file_name_symbol.str_value,
            PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES
        )

        arrangement = arrangement_w_tcds(
            hds_contents=relativity_configurations.ATC_FILE.
            populator_for_relativity_option_root__hds(
                fs.DirContents([fs.Dir(sub_dir_of_home, [executable_file])])),
            symbol_table=SymbolContext.symbol_table_of_contexts([
                dir_symbol,
                executable_file_name_symbol,
            ]))

        expectation = Expectation(
            symbol_usages=asrt.matches_sequence([
                dir_symbol.reference_assertion__path_or_string,
                executable_file_name_symbol.
                reference_assertion__string__w_all_indirect_refs_are_strings,
            ]),
            execute=eh_assertions.is_exit_code(0),
            post_sds=PostSdsExpectation.
            constant(sub_process_result_from_execute=pr.stdout(
                asrt.Equals(expected_output, 'CLI arguments, one per line'))),
        )
        check_execution(self, sut.actor(), [instr([command_line])],
                        arrangement, expectation)
Beispiel #9
0
    def runTest(self):
        symbol_for_source_file = NameAndValue('source_file_symbol_name',
                                              'the-source-file.py')

        argument_symbol = NameAndValue('argument_symbol_name', 'string-constant')

        expected_output = lines_content([argument_symbol.value])

        command_line = '{source_file} {argument} '.format(
            source_file=symbol_reference_syntax_for_name(symbol_for_source_file.name),
            argument=symbol_reference_syntax_for_name(argument_symbol.name),
        )

        arrangement = Arrangement(
            hds_contents=contents_in(RelHomeOptionType.REL_HOME_ACT, fs.DirContents([
                fs.File(
                    symbol_for_source_file.value,
                    PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES)
            ])),
            symbol_table=SymbolTable({
                symbol_for_source_file.name:
                    su.string_constant_container(symbol_for_source_file.value),
                argument_symbol.name:
                    su.string_constant_container(argument_symbol.value),
            })
        )

        expectation = Expectation(
            result_of_execute=eh_assertions.is_exit_code(0),
            sub_process_result_from_execute=pr.stdout(asrt.Equals(expected_output,
                                                                  'CLI arguments, one per line')),
            symbol_usages=equals_symbol_references([
                SymbolReference(symbol_for_source_file.name,
                                path_or_string_reference_restrictions(PATH_RELATIVITY_VARIANTS_FOR_FILE_TO_RUN)),
                SymbolReference(argument_symbol.name,
                                is_any_data_type()),
            ]),
        )
        self._check(command_line,
                    arrangement,
                    expectation)
Beispiel #10
0
    def test_symbol_reference_in_arguments(self):
        list_symbol = NameAndValue('list_symbol_name', ['first element',
                                                        'second element'])

        string_constant = 'string-constant'

        expected_output = lines_content(['string-constant'] + list_symbol.value)

        executable = 'the-executable'

        command_line = '{executable} {string_constant} {list_symbol}'.format(
            executable=executable,
            string_constant=string_constant,
            list_symbol=symbol_reference_syntax_for_name(list_symbol.name),
        )

        arrangement = Arrangement(
            hds_contents=contents_in(RelHomeOptionType.REL_HOME_ACT, fs.DirContents([
                fs.python_executable_file(
                    executable,
                    PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES)
            ])),
            symbol_table=SymbolTable({
                list_symbol.name:
                    su.list_value_constant_container(lv.list_value_of_string_constants(list_symbol.value)),
            })
        )

        expectation = Expectation(
            result_of_execute=eh_assertions.is_exit_code(0),
            sub_process_result_from_execute=pr.stdout(asrt.Equals(expected_output,
                                                                  'CLI arguments, one per line')),
            symbol_usages=equals_symbol_references(
                [SymbolReference(list_symbol.name, is_any_data_type())]
            )
        )
        check_execution(self,
                        sut.Parser(),
                        [instr([command_line])],
                        arrangement,
                        expectation)
Beispiel #11
0
    def test_string_symbol_reference_in_executable_and_argument(self):
        symbol_for_executable = StringConstantSymbolContext(
            'executable_symbol_name', 'the-executable')

        argument_symbol = StringConstantSymbolContext('argument_symbol_name',
                                                      'string-constant')

        expected_output = lines_content([argument_symbol.str_value])

        command_line = '{executable} {argument} '.format(
            executable=symbol_for_executable.name__sym_ref_syntax,
            argument=argument_symbol.name__sym_ref_syntax,
        )

        arrangement = arrangement_w_tcds(
            hds_contents=relativity_configurations.ATC_FILE.
            populator_for_relativity_option_root__hds(
                fs.DirContents([
                    fs.python_executable_file(
                        symbol_for_executable.str_value,
                        PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES
                    )
                ])),
            symbol_table=SymbolContext.symbol_table_of_contexts([
                symbol_for_executable,
                argument_symbol,
            ]))

        expectation = Expectation(
            execute=eh_assertions.is_exit_code(0),
            symbol_usages=asrt.matches_sequence([
                symbol_for_executable.reference_assertion__path_or_string(
                    PATH_RELATIVITY_VARIANTS_FOR_FILE_TO_RUN),
                argument_symbol.reference_assertion__w_str_rendering,
            ]),
            post_sds=PostSdsExpectation.
            constant(sub_process_result_from_execute=pr.stdout(
                asrt.Equals(expected_output, 'CLI arguments, one per line'))),
        )
        check_execution(self, sut.actor(), [instr([command_line])],
                        arrangement, expectation)
Beispiel #12
0
 def runTest(self):
     executor_constructor = sut.Parser()
     act_phase_instructions = [
         instr(['system-under-test first-argument "quoted argument"'])
     ]
     arrangement = Arrangement(
         hds_contents=contents_in(RelHomeOptionType.REL_HOME_ACT, fs.DirContents([
             fs.python_executable_file(
                 'system-under-test',
                 PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES)
         ])))
     expected_output = lines_content(['first-argument',
                                      'quoted argument'])
     expectation = Expectation(result_of_execute=eh_assertions.is_exit_code(0),
                               sub_process_result_from_execute=pr.stdout(asrt.Equals(expected_output,
                                                                                     'CLI arguments, one per line')))
     check_execution(self,
                     executor_constructor,
                     act_phase_instructions,
                     arrangement,
                     expectation)
Beispiel #13
0
    def runTest(self):
        # ARRANGE #

        result = SubProcessResult(
            exitcode=5,
            stdout='output on stdout from existing py program file',
            stderr='output on stderr from existing py program file',
        )

        py_file = fs.File(
            'the-program.py',
            py_program.program_that_prints_and_exits_with_exit_code(result),
        )

        source_w_relative_name_of_existing_file = args.interpret_py_source_file(
            py_file.name)

        # ACT & ASSERT #

        integration_check.check_execution(
            self,
            sut.actor(),
            [
                instr(
                    source_w_relative_name_of_existing_file.as_arguments.lines)
            ],
            arrangement_w_tcds(
                hds_contents=relativity_configurations.PROGRAM_FILE.
                populator_for_relativity_option_root__hds(
                    DirContents([py_file]))),
            Expectation(execute=asrt_eh.is_exit_code(result.exitcode),
                        post_sds=PostSdsExpectation.constant(
                            sub_process_result_from_execute=asrt_proc_result.
                            matches_proc_result(
                                exit_code=asrt.equals(result.exitcode),
                                stdout=asrt.equals(result.stdout),
                                stderr=asrt.equals(result.stderr),
                            ))),
        )
Beispiel #14
0
    def test_string_symbol_reference_in_executable(self):
        symbol_for_executable = NameAndValue('executable_symbol_name', 'the-executable')

        string_constant = 'string-constant'

        expected_output = lines_content(['string-constant'])

        command_line = '{executable} {string_constant} '.format(
            executable=symbol_reference_syntax_for_name(symbol_for_executable.name),
            string_constant=string_constant,
        )

        arrangement = Arrangement(
            hds_contents=contents_in(RelHomeOptionType.REL_HOME_ACT, fs.DirContents([
                fs.python_executable_file(
                    symbol_for_executable.value,
                    PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES)
            ])),
            symbol_table=SymbolTable({
                symbol_for_executable.name:
                    su.string_constant_container(symbol_for_executable.value),
            })
        )

        expectation = Expectation(
            result_of_execute=eh_assertions.is_exit_code(0),
            sub_process_result_from_execute=pr.stdout(asrt.Equals(expected_output,
                                                                  'CLI arguments, one per line')),
            symbol_usages=equals_symbol_references([
                SymbolReference(symbol_for_executable.name,
                                path_or_string_reference_restrictions(PATH_RELATIVITY_VARIANTS_FOR_FILE_TO_RUN)),
            ]
            )
        )
        check_execution(self,
                        sut.Parser(),
                        [instr([command_line])],
                        arrangement,
                        expectation)
Beispiel #15
0
 def runTest(self):
     actor = sut.actor()
     act_phase_instructions = [
         instr(['system-under-test first-argument "quoted argument"'])
     ]
     arrangement = arrangement_w_tcds(
         hds_contents=relativity_configurations.ATC_FILE.
         populator_for_relativity_option_root__hds(
             fs.DirContents([
                 fs.python_executable_file(
                     'system-under-test',
                     PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES
                 )
             ])))
     expected_output = lines_content(['first-argument', 'quoted argument'])
     expectation = Expectation(
         execute=eh_assertions.is_exit_code(0),
         post_sds=PostSdsExpectation.
         constant(sub_process_result_from_execute=pr.stdout(
             asrt.Equals(expected_output, 'CLI arguments, one per line'))))
     check_execution(self, actor, act_phase_instructions, arrangement,
                     expectation)
Beispiel #16
0
    def test_symbol_value_with_space_SHOULD_be_given_as_single_argument_to_program(self):
        symbol = NameAndValue('symbol_name', 'symbol value with space')

        expected_output = lines_content([symbol.value])

        executable_file_name = 'the-executable_file_name'

        command_line = '{executable_file_name} {symbol}'.format(
            executable_file_name=executable_file_name,
            symbol=symbol_reference_syntax_for_name(symbol.name),
        )

        arrangement = Arrangement(
            hds_contents=contents_in(RelHomeOptionType.REL_HOME_ACT, fs.DirContents([
                fs.python_executable_file(
                    executable_file_name,
                    PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES)
            ])),
            symbol_table=SymbolTable({
                symbol.name:
                    su.string_constant_container(symbol.value),
            })
        )

        expectation = Expectation(
            result_of_execute=eh_assertions.is_exit_code(0),
            sub_process_result_from_execute=pr.stdout(asrt.Equals(expected_output,
                                                                  'CLI arguments, one per line')),
            symbol_usages=equals_symbol_references(
                [SymbolReference(symbol.name,
                                 is_any_data_type())]
            )
        )
        check_execution(self,
                        sut.Parser(),
                        [instr([command_line])],
                        arrangement,
                        expectation)
Beispiel #17
0
    def test_symbol_reference_in_arguments(self):
        list_symbol = ListConstantSymbolContext(
            'list_symbol_name', ['first element', 'second element'])

        string_constant = 'string-constant'

        expected_output = lines_content(['string-constant'] +
                                        list_symbol.constant_list)

        executable = 'the-executable'

        command_line = '{executable} {string_constant} {list_symbol}'.format(
            executable=executable,
            string_constant=string_constant,
            list_symbol=list_symbol.name__sym_ref_syntax,
        )

        arrangement = arrangement_w_tcds(
            hds_contents=relativity_configurations.ATC_FILE.
            populator_for_relativity_option_root__hds(
                fs.DirContents([
                    fs.python_executable_file(
                        executable,
                        PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES
                    )
                ])),
            symbol_table=list_symbol.symbol_table)

        expectation = Expectation(
            symbol_usages=asrt.matches_singleton_sequence(
                list_symbol.reference_assertion),
            execute=eh_assertions.is_exit_code(0),
            post_sds=PostSdsExpectation.
            constant(sub_process_result_from_execute=pr.stdout(
                asrt.Equals(expected_output, 'CLI arguments, one per line'))),
        )
        check_execution(self, sut.actor(), [instr([command_line])],
                        arrangement, expectation)
Beispiel #18
0
    def test_possibility_to_have_sds_file_references_in_argument(self):
        file_name_of_referenced_file = 'file-name.txt'
        symbol = NameAndValue('symbol_name',
                              file_refs.of_rel_option(RelOptionType.REL_TMP,
                                                      file_refs.constant_path_part(file_name_of_referenced_file)))

        executable = 'the-executable'

        command_line = '{executable} {symbol}'.format(
            executable=executable,
            symbol=symbol_reference_syntax_for_name(symbol.name),
        )

        arrangement = Arrangement(
            hds_contents=contents_in(RelHomeOptionType.REL_HOME_ACT, fs.DirContents([
                fs.python_executable_file(
                    executable,
                    PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES)
            ])),
            symbol_table=SymbolTable({
                symbol.name:
                    su.file_ref_constant_container(symbol.value),
            })
        )

        expectation = Expectation(
            result_of_execute=eh_assertions.is_exit_code(0),
            sub_process_result_from_execute=pr.stdout(str_asrt.contains(file_name_of_referenced_file)),
            symbol_usages=equals_symbol_references(
                [SymbolReference(symbol.name, is_any_data_type())]
            )
        )
        check_execution(self,
                        sut.Parser(),
                        [instr([command_line])],
                        arrangement,
                        expectation)
Beispiel #19
0
    def test_symbol_value_with_space_SHOULD_be_given_as_single_argument_to_program(self):
        symbol = StringConstantSymbolContext('symbol_name', 'symbol value with space')

        expected_output = lines_content([symbol.str_value])

        source_file = 'the-source-file.py'

        command_line = '{source_file} {symbol}'.format(
            source_file=source_file,
            symbol=symbol.name__sym_ref_syntax,
        )

        arrangement = integration_check.arrangement_w_tcds(
            hds_contents=contents_in(RelHdsOptionType.REL_HDS_ACT, fs.DirContents([
                fs.File(
                    source_file,
                    PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES)
            ])),
            symbol_table=symbol.symbol_table
        )

        expectation = integration_check.Expectation(
            symbol_usages=asrt.matches_sequence(
                [symbol.reference_assertion__w_str_rendering]
            ),
            execute=eh_assertions.is_exit_code(0),
            post_sds=PostSdsExpectation.constant(
                sub_process_result_from_execute=asrt_pr.stdout(asrt.Equals(expected_output,
                                                                           'CLI arguments, one per line'))
            ),
        )
        integration_check.check_execution(self,
                                          ACTOR_THAT_RUNS_PYTHON_PROGRAM_FILE,
                                          [instr([command_line])],
                                          arrangement,
                                          expectation)
Beispiel #20
0
    def runTest(self):
        # ARRANGE #
        exit_code_from_program = 0
        py_file = fs.File(
            'the-program',
            lines_content(py_program.exit_with_code(exit_code_from_program)),
        )
        program_symbol = ProgramSymbolContext.of_sdv(
            'PROGRAM_SYMBOL',
            program_sdvs.interpret_py_source_file_that_must_exist(
                path_sdvs.of_rel_option_with_const_file_name(
                    RelOptionType.REL_HDS_CASE,
                    py_file.name,
                )))
        program_line = args.symbol_ref_command_line(program_symbol.name).as_str

        with tmp_dir_in_path_with_files(DirContents([py_file])) as environ:
            for source_case in valid_source_variants(program_line):
                with self.subTest(source_case.name):
                    # ACT & ASSERT #
                    integration_check.check_execution(
                        self,
                        sut.actor(),
                        [instr([program_line])],
                        arrangement_w_tcds(
                            symbol_table=program_symbol.symbol_table,
                            act_exe_input=AtcExeInputArr(environ=environ),
                            hds_contents=hds_populators.contents_in(
                                RelHdsOptionType.REL_HDS_CASE,
                                DirContents([py_file])),
                        ),
                        Expectation(
                            symbol_usages=program_symbol.usages_assertion,
                            execute=asrt_eh.is_exit_code(
                                exit_code_from_program)),
                    )