Пример #1
0
    def test_single_definition_with_single_reference_in_act_phase__with_actor_set_in_conf(
            self):
        symbol_name = 'STRING_SYMBOL'
        case_with_single_def = File(
            'test.xly',
            lines_content([
                phase_names.CONFIGURATION.syntax,
                sym_def.SET_ACTOR_THAT_PARSES_REFERENCES_INSTRUCTION_NAME,
                phase_names.SETUP.syntax,
                sym_def.define_string(symbol_name, 'value'),
                phase_names.ACT.syntax,
                sym_def.reference_to(symbol_name, ValueType.STRING),
            ]))

        check_case_and_suite(
            self,
            symbol_command_arguments=[case_with_single_def.name],
            arrangement=Arrangement(
                main_program_config=sym_def.main_program_config(
                    ActorThatRaisesParseException()),
                cwd_contents=DirContents([
                    case_with_single_def,
                ]),
            ),
            expectation=asrt_proc_result.sub_process_result(
                exitcode=asrt.equals(exit_codes.EXIT_OK),
                stdout=asrt.equals(
                    output.list_of([
                        output.SymbolSummary(symbol_name,
                                             ValueType.STRING,
                                             num_refs=1),
                    ])),
            ))
    def check(self,
              put: unittest.TestCase,
              actual_result: SubProcessResult):
        expectation = asrt_process_result.sub_process_result(
            exitcode=asrt.equals(exit_codes.EXIT_INVALID_USAGE))

        expectation.apply_without_message(put, actual_result)
Пример #3
0
    def test_single_definition_in_default_suite_file(self):
        symbol_name = 'STRING_SYMBOL'
        suite_with_single_def = File(
            DEFAULT_SUITE_FILE,
            lines_content([
                phase_names.SETUP.syntax,
                sym_def.define_string(symbol_name, 'value'),
            ]))
        dir_arg = Dir('a-dir', [suite_with_single_def])

        test_with_files_in_tmp_dir.check(
            self,
            command_line_arguments=symbol_args.arguments__suite([dir_arg.name
                                                                 ]),
            arrangement=Arrangement(
                cwd_contents=DirContents([
                    dir_arg,
                ]),
                main_program_config=sym_def.main_program_config(),
            ),
            expectation=asrt_proc_result.sub_process_result(
                exitcode=asrt.equals(exit_codes.EXIT_OK),
                stdout=asrt.equals(
                    output.list_of([
                        output.SymbolSummary(symbol_name,
                                             ValueType.STRING,
                                             num_refs=0),
                    ])),
            ))
Пример #4
0
    def test_single_definition_with_reference_to_builtin_symbol(self):
        builtin_symbol = StringSymbolContext.of_constant(
            'BUILTIN_STRING_SYMBOL', 'builtin string symbol value')
        user_defined_symbol_name = 'STRING_SYMBOL'
        case_with_single_def = File(
            'test.xly',
            lines_content([
                phase_names.SETUP.syntax,
                sym_def.define_string(
                    user_defined_symbol_name,
                    symbol_reference_syntax_for_name(builtin_symbol.name)),
            ]))

        check_case_and_suite(
            self,
            symbol_command_arguments=[case_with_single_def.name],
            arrangement=Arrangement(
                cwd_contents=DirContents([
                    case_with_single_def,
                ]),
                main_program_config=sym_def.main_program_config(
                    builtin_symbols=[
                        sym_def.builtin_symbol(builtin_symbol),
                    ]),
            ),
            expectation=asrt_proc_result.sub_process_result(
                exitcode=asrt.equals(exit_codes.EXIT_OK),
                stdout=asrt.equals(
                    output.list_of([
                        output.SymbolSummary(user_defined_symbol_name,
                                             ValueType.STRING,
                                             num_refs=0),
                    ])),
            ))
Пример #5
0
    def test(self):
        name_of_existing_symbol = 'STRING_SYMBOL'

        case_with_single_def = File('test.case',
                                    lines_content([
                                        phase_names.SETUP.syntax,
                                        sym_def.define_string(name_of_existing_symbol, 'value'),
                                    ]))

        expected_first_line = output.list_of([output.SymbolReport(name_of_existing_symbol,
                                                                  ValueType.STRING,
                                                                  num_refs=0)]).rstrip()
        test_with_files_in_tmp_dir.check(
            self,
            command_line_arguments=
            symbol_args.individual__definition(
                case_with_single_def.name,
                name_of_existing_symbol,
            ),
            arrangement=
            Arrangement(
                cwd_contents=DirContents([
                    case_with_single_def,
                ]),
                main_program_config=sym_def.main_program_config(),
            ),
            expectation=
            asrt_proc_result.sub_process_result(
                exitcode=asrt.equals(exit_codes.EXIT_OK),
                stdout=asrt_str.first_line(asrt.equals(expected_first_line)))
        )
Пример #6
0
    def test_definition_and_reference_in_definition(self):
        leaf_name = 'LEAF_SYMBOL_SYMBOL'
        referrer_name = 'REFERRER_SYMBOL'
        case_with_single_def = File(
            'test.xly',
            lines_content([
                phase_names.SETUP.syntax,
                sym_def.define_string(leaf_name, 'value'),
                sym_def.define_string(
                    referrer_name,
                    symbol_reference_syntax_for_name(leaf_name)),
            ]))

        check_case_and_suite(
            self,
            symbol_command_arguments=[case_with_single_def.name],
            arrangement=Arrangement(
                cwd_contents=DirContents([
                    case_with_single_def,
                ]),
                main_program_config=sym_def.main_program_config(),
            ),
            expectation=asrt_proc_result.sub_process_result(
                exitcode=asrt.equals(exit_codes.EXIT_OK),
                stdout=asrt.equals(
                    output.list_of([
                        output.SymbolSummary(leaf_name,
                                             ValueType.STRING,
                                             num_refs=1),
                        output.SymbolSummary(referrer_name,
                                             ValueType.STRING,
                                             num_refs=0),
                    ])),
            ))
Пример #7
0
    def test_single_reference_in_act_phase(self):
        name_of_existing_symbol = 'STRING_SYMBOL'

        reference_source = sym_def.reference_to(name_of_existing_symbol,
                                                ValueType.STRING)
        case_with_single_def = File(
            'test.xly',
            lines_content([
                phase_names.SETUP.syntax,
                sym_def.define_string(name_of_existing_symbol, 'value'),
                phase_names.ACT.syntax,
                reference_source,
            ]))

        expected_reference_output = output.Reference(phase_identifier.ACT,
                                                     None, [
                                                         reference_source,
                                                     ])
        check_case_and_suite(
            self,
            symbol_command_arguments=symbol_args.individual__references(
                case_with_single_def.name,
                name_of_existing_symbol,
            ),
            arrangement=Arrangement(
                cwd_contents=DirContents([
                    case_with_single_def,
                ]),
                main_program_config=sym_def.main_program_config(),
            ),
            expectation=asrt_proc_result.sub_process_result(
                exitcode=asrt.equals(exit_codes.EXIT_OK),
                stdout=asrt.equals(
                    lines_content(expected_reference_output.output_lines()))))
    def check(self,
              put: unittest.TestCase,
              actual_result: SubProcessResult):
        expectation = asrt_process_result.sub_process_result(
            exitcode=asrt.equals(exit_codes.EXIT_INVALID_USAGE))

        expectation.apply_without_message(put, actual_result)
Пример #9
0
    def test_symbol_without_references(self):
        name_of_existing_symbol = 'STRING_SYMBOL'

        case_with_single_def = File(
            'test.case',
            lines_content([
                phase_names.SETUP.syntax,
                sym_def.define_string(name_of_existing_symbol, 'value'),
            ]))

        expected_first_line = output.summary_of_single(
            output.SymbolSummary(name_of_existing_symbol,
                                 ValueType.STRING,
                                 num_refs=0))
        check_case_and_suite(
            self,
            symbol_command_arguments=symbol_args.individual__definition(
                case_with_single_def.name,
                name_of_existing_symbol,
            ),
            arrangement=Arrangement(
                cwd_contents=DirContents([
                    case_with_single_def,
                ]),
                main_program_config=sym_def.main_program_config(),
            ),
            expectation=asrt_proc_result.sub_process_result(
                exitcode=asrt.equals(exit_codes.EXIT_OK),
                stdout=asrt_str.first_line(asrt.equals(expected_first_line))))
Пример #10
0
    def test_builtin_symbol_with_reference_to_it(self):
        existing_builtin_symbol = StringSymbolContext.of_constant(
            'BUILTIN_STRING_SYMBOL', 'the builtin symbol value')

        case_with_single_def = File(
            'test.case',
            lines_content([
                phase_names.SETUP.syntax,
                sym_def.reference_to(existing_builtin_symbol.name,
                                     existing_builtin_symbol.value.value_type),
            ]))

        check_case_and_suite(
            self,
            symbol_command_arguments=symbol_args.individual__definition(
                case_with_single_def.name,
                existing_builtin_symbol.name,
            ),
            arrangement=Arrangement(
                cwd_contents=DirContents([
                    case_with_single_def,
                ]),
                main_program_config=sym_def.main_program_config(
                    builtin_symbols=[
                        sym_def.builtin_symbol(existing_builtin_symbol)
                    ], ),
            ),
            expectation=asrt_proc_result.sub_process_result(
                exitcode=asrt.equals(exit_codes.EXIT_OK),
                stdout=definition_of_builtin_symbol(
                    existing_builtin_symbol.name,
                    existing_builtin_symbol.value.value_type,
                    num_refs=1)))
Пример #11
0
    def test_definition_and_reference_in_definition(self):
        leaf_name = 'LEAF_SYMBOL_SYMBOL'
        referrer_name = 'REFERRER_SYMBOL'
        case_with_single_def = File(
            'test.case',
            lines_content([
                phase_names.SETUP.syntax,
                sym_def.define_string(leaf_name, 'value'),
                sym_def.define_string(referrer_name,
                                      symbol_reference_syntax_for_name(leaf_name)),
            ]))

        test_with_files_in_tmp_dir.check(
            self,
            command_line_arguments=
            symbol_args.arguments([case_with_single_def.name]),
            arrangement=
            Arrangement(
                cwd_contents=DirContents([
                    case_with_single_def,
                ]),
                main_program_config=sym_def.main_program_config(),
            ),
            expectation=
            asrt_proc_result.sub_process_result(
                exitcode=asrt.equals(exit_codes.EXIT_OK),
                stdout=asrt.equals(output.list_of([
                    output.SymbolReport(leaf_name, ValueType.STRING, num_refs=1),
                    output.SymbolReport(referrer_name, ValueType.STRING, num_refs=0),
                ])),
            )
        )
Пример #12
0
    def runTest(self):
        # ARRANGE #

        source_file = fs.File.empty('source-file.src')

        python_interpreter_symbol = PathSymbolContext.of_sdv(
            'PYTHON_INTERPRETER_SYMBOL',
            path_sdvs.constant(
                path_ddvs.absolute_path(pathlib.Path(sys.executable))))

        interpreter_with_symbol_reference = command_sdvs.for_executable_file(
            python_interpreter_symbol.reference_sdv__path_or_string(
                relativity_configurations.INTERPRETER_FILE.relativity))

        arrangement = arrangement_w_tcds(
            symbol_table=python_interpreter_symbol.symbol_table,
            hds_contents=relativity_configurations.ATC_FILE.
            populator_for_relativity_option_root__hds(
                fs.DirContents([source_file])))
        expectation = Expectation(
            symbol_usages=asrt.matches_singleton_sequence(
                python_interpreter_symbol.reference_assertion__path_or_string),
            post_sds=PostSdsExpectation.constant(
                sub_process_result_from_execute=asrt_pr.sub_process_result(
                    exitcode=asrt.equals(0),
                    stdout=asrt.equals(''),
                    stderr=asrt.equals(''),
                )),
        )
        # ACT & ASSERT #
        check_execution(self, sut.actor(interpreter_with_symbol_reference),
                        [instr([])], arrangement, expectation)
Пример #13
0
    def test_definition_in_suite_and_case(self):
        # ARRANGE #

        symbol_in_suite = 'SUITE_STRING_SYMBOL'
        symbol_in_case__before_preproc = 'CASE_STRING_SYMBOL__BEFORE_PRE_PROC'
        symbol_in_case__after_preproc = 'CASE_STRING_SYMBOL'

        suite_with_preprocessor = File(
            'with-preprocessor.suite',
            lines_content([
                section_names.CONFIGURATION.syntax,
                suite_instructions.set_search_replace_preprocessor(
                    symbol_in_case__before_preproc,
                    symbol_in_case__after_preproc
                ),

                phase_names.SETUP.syntax,
                sym_def.define_string(symbol_in_suite, 'suite-value'),
            ])
        )

        case_with_single_def = File(
            'test.case',
            lines_content([
                phase_names.SETUP.syntax,
                sym_def.define_string(symbol_in_case__before_preproc, 'case-value'),
            ]))

        # ACT & ASSERT #

        test_with_files_in_tmp_dir.check(
            self,
            command_line_arguments=
            symbol_args.explicit_suite_and_case(suite_with_preprocessor.name,
                                                case_with_single_def.name),
            arrangement=
            Arrangement(
                cwd_contents=DirContents([
                    suite_with_preprocessor,
                    case_with_single_def,
                ]),
                main_program_config=sym_def.main_program_config(),
            ),
            expectation=
            asrt_proc_result.sub_process_result(
                exitcode=asrt.equals(exit_codes.EXIT_OK),
                stdout=asrt.equals(output.list_of([
                    output.SymbolReport(symbol_in_suite, ValueType.STRING, num_refs=0),
                    output.SymbolReport(symbol_in_case__after_preproc, ValueType.STRING, num_refs=0),
                ])),
            )
        )
Пример #14
0
    def test_definition_in_suite_and_case(self):
        # ARRANGE #

        symbol_in_suite = 'SUITE_STRING_SYMBOL'
        symbol_in_case__before_preproc = 'CASE_STRING_SYMBOL__BEFORE_PRE_PROC'
        symbol_in_case__after_preproc = 'CASE_STRING_SYMBOL'

        suite_with_preprocessor = File(
            'with-preprocessor.suite',
            lines_content([
                section_names.CONFIGURATION.syntax,
                suite_instructions.set_search_replace_preprocessor(
                    symbol_in_case__before_preproc,
                    symbol_in_case__after_preproc),
                phase_names.SETUP.syntax,
                sym_def.define_string(symbol_in_suite, 'suite-value'),
            ]))

        case_with_single_def = File(
            'test.case',
            lines_content([
                phase_names.SETUP.syntax,
                sym_def.define_string(symbol_in_case__before_preproc,
                                      'case-value'),
            ]))

        # ACT & ASSERT #

        test_with_files_in_tmp_dir.check(
            self,
            command_line_arguments=symbol_args.explicit_suite_and_case(
                suite_with_preprocessor.name, case_with_single_def.name),
            arrangement=Arrangement(
                cwd_contents=DirContents([
                    suite_with_preprocessor,
                    case_with_single_def,
                ]),
                main_program_config=sym_def.main_program_config(),
            ),
            expectation=asrt_proc_result.sub_process_result(
                exitcode=asrt.equals(exit_codes.EXIT_OK),
                stdout=asrt.equals(
                    output.list_of([
                        output.SymbolSummary(symbol_in_suite,
                                             ValueType.STRING,
                                             num_refs=0),
                        output.SymbolSummary(symbol_in_case__after_preproc,
                                             ValueType.STRING,
                                             num_refs=0),
                    ])),
            ))
Пример #15
0
    def test_multiple_definition(self):
        setup_symbol_name = 'SETUP_SYMBOL'
        before_assert_symbol_name = 'BEFORE_ASSERT_SYMBOL'
        assert_symbol_name = 'ASSERT_SYMBOL'
        cleanup_symbol_name = 'CLEANUP_SYMBOL'
        case_with_one_def_per_phase = File(
            'test.xly',
            lines_content([
                phase_names.SETUP.syntax,
                sym_def.define_string(setup_symbol_name,
                                      setup_symbol_name + 'value'),
                phase_names.BEFORE_ASSERT.syntax,
                sym_def.define_string(before_assert_symbol_name,
                                      before_assert_symbol_name + 'value'),
                phase_names.ASSERT.syntax,
                sym_def.define_string(assert_symbol_name,
                                      assert_symbol_name + 'value'),
                phase_names.CLEANUP.syntax,
                sym_def.define_string(cleanup_symbol_name,
                                      cleanup_symbol_name + 'value'),
            ]))

        check_case_and_suite(
            self,
            symbol_command_arguments=[case_with_one_def_per_phase.name],
            arrangement=Arrangement(
                cwd_contents=DirContents([
                    case_with_one_def_per_phase,
                ]),
                main_program_config=sym_def.main_program_config(),
            ),
            expectation=asrt_proc_result.sub_process_result(
                exitcode=asrt.equals(exit_codes.EXIT_OK),
                stdout=asrt.equals(
                    output.list_of([
                        output.SymbolSummary(setup_symbol_name,
                                             ValueType.STRING,
                                             num_refs=0),
                        output.SymbolSummary(before_assert_symbol_name,
                                             ValueType.STRING,
                                             num_refs=0),
                        output.SymbolSummary(assert_symbol_name,
                                             ValueType.STRING,
                                             num_refs=0),
                        output.SymbolSummary(cleanup_symbol_name,
                                             ValueType.STRING,
                                             num_refs=0),
                    ])),
            ))
Пример #16
0
    def test_multiple_definition(self):
        setup_symbol_name = 'SETUP_SYMBOL'
        before_assert_symbol_name = 'BEFORE_ASSERT_SYMBOL'
        assert_symbol_name = 'ASSERT_SYMBOL'
        cleanup_symbol_name = 'CLEANUP_SYMBOL'
        case_with_one_def_per_phase = File(
            'test.case',
            lines_content([
                phase_names.SETUP.syntax,
                sym_def.define_string(setup_symbol_name, setup_symbol_name + 'value'),

                phase_names.BEFORE_ASSERT.syntax,
                sym_def.define_string(before_assert_symbol_name,
                                      before_assert_symbol_name + 'value'),

                phase_names.ASSERT.syntax,
                sym_def.define_string(assert_symbol_name, assert_symbol_name + 'value'),

                phase_names.CLEANUP.syntax,
                sym_def.define_string(cleanup_symbol_name,
                                      cleanup_symbol_name + 'value'),
            ]))

        test_with_files_in_tmp_dir.check(
            self,
            command_line_arguments=
            symbol_args.arguments([case_with_one_def_per_phase.name]),
            arrangement=
            Arrangement(
                cwd_contents=DirContents([
                    case_with_one_def_per_phase,
                ]),
                main_program_config=sym_def.main_program_config(),
            ),
            expectation=
            asrt_proc_result.sub_process_result(
                exitcode=asrt.equals(exit_codes.EXIT_OK),
                stdout=asrt.equals(output.list_of([
                    output.SymbolReport(setup_symbol_name, ValueType.STRING, num_refs=0),
                    output.SymbolReport(before_assert_symbol_name, ValueType.STRING, num_refs=0),
                    output.SymbolReport(assert_symbol_name, ValueType.STRING, num_refs=0),
                    output.SymbolReport(cleanup_symbol_name, ValueType.STRING, num_refs=0),
                ])),
            )
        )
Пример #17
0
    def test_definition_in_suite_and_case(self):
        symbol_in_suite_name = 'SUITE_SYMBOL'
        symbol_in_case_name = 'CASE_SYMBOL'

        suite_with_single_def = lines_content([
            section_names.CASE__SETUP.syntax,
            sym_def.define_string(symbol_in_suite_name, 'value'),
        ])

        case_with_single_def = File(
            'test.case',
            lines_content([
                phase_names.SETUP.syntax,
                sym_def.define_string(symbol_in_case_name, 'value'),
            ]))

        for suite_case in suite_cases('single-definition.suite'):
            with self.subTest(suite_case.name):
                test_with_files_in_tmp_dir.check(
                    self,
                    command_line_arguments=symbol_args.arguments(
                        suite_case.value.suite_arguments +
                        [case_with_single_def.name]),
                    arrangement=Arrangement(
                        cwd_contents=DirContents([
                            suite_case.value.suite_file(suite_with_single_def),
                            case_with_single_def,
                        ]),
                        main_program_config=sym_def.main_program_config(),
                    ),
                    expectation=asrt_proc_result.sub_process_result(
                        exitcode=asrt.equals(exit_codes.EXIT_OK),
                        stdout=asrt.equals(
                            output.list_of([
                                output.SymbolSummary(symbol_in_suite_name,
                                                     ValueType.STRING,
                                                     num_refs=0),
                                output.SymbolSummary(symbol_in_case_name,
                                                     ValueType.STRING,
                                                     num_refs=0),
                            ])),
                    ))
Пример #18
0
    def test_single_reference_to_builtin_symbol(self):
        name_of_user_defined_symbol = 'USER_DEFINED_SYMBOL'
        builtin_symbol = StringSymbolContext.of_constant(
            'BUILTIN_SYMBOL', 'builtin string symbol value')

        definition_source = sym_def.define_string(
            name_of_user_defined_symbol,
            symbol_reference_syntax_for_name(builtin_symbol.name))
        case_with_single_def = File(
            'test.xly',
            lines_content([
                phase_names.SETUP.syntax,
                definition_source,
            ]))

        expected_reference_output = output.Reference(
            phase_identifier.SETUP,
            output.LineInFilePosition(case_with_single_def.name, 2), [
                definition_source,
            ])

        check_case_and_suite(
            self,
            symbol_command_arguments=symbol_args.individual__references(
                case_with_single_def.name,
                builtin_symbol.name,
            ),
            arrangement=Arrangement(
                cwd_contents=DirContents([
                    case_with_single_def,
                ]),
                main_program_config=sym_def.main_program_config(
                    builtin_symbols=[
                        sym_def.builtin_symbol(builtin_symbol),
                    ]),
            ),
            expectation=asrt_proc_result.sub_process_result(
                exitcode=asrt.equals(exit_codes.EXIT_OK),
                stdout=asrt.equals(
                    lines_content(expected_reference_output.output_lines()))))
Пример #19
0
 def runTest(self):
     expected_output = pr.sub_process_result(exitcode=asrt.equals(0),
                                             stdout=asrt.equals(''),
                                             stderr=asrt.equals(''))
     cases = [
         (
             'no act phase contents',
             []
         ),
         (
             'act phase contents of just comments',
             [instr([LINE_COMMENT_MARKER + ' a comment'])]
         ),
         (
             'act phase contents of just comments and empty lines',
             [instr([LINE_COMMENT_MARKER + ' a comment',
                     '',
                     LINE_COMMENT_MARKER + ' a second comment',
                     ])]
         ),
         (
             'act phase contents with non-comment and non-empty line',
             [instr(['not a comment and not empty',
                     ])]
         ),
     ]
     actor = sut.actor()
     for case_name, act_phase_instructions in cases:
         with self.subTest(case_name=case_name):
             arrangement = arrangement_w_tcds()
             expectation = Expectation(
                 post_sds=PostSdsExpectation.constant(
                     sub_process_result_from_execute=expected_output
                 )
             )
             check_execution(self,
                             actor,
                             act_phase_instructions,
                             arrangement,
                             expectation)
Пример #20
0
    def test_single_reference_in_act_phase(self):
        name_of_existing_symbol = 'STRING_SYMBOL'

        reference_source = sym_def.reference_to(name_of_existing_symbol, ValueType.STRING)
        case_with_single_def = File('test.case',
                                    lines_content([
                                        phase_names.SETUP.syntax,
                                        sym_def.define_string(name_of_existing_symbol, 'value'),

                                        phase_names.ACT.syntax,
                                        reference_source,
                                    ]))

        expected_reference_output = output.Reference(
            phase_identifier.ACT,
            None,
            [
                reference_source,
            ]
        )
        test_with_files_in_tmp_dir.check(
            self,
            command_line_arguments=
            symbol_args.individual__references(
                case_with_single_def.name,
                name_of_existing_symbol,
            ),
            arrangement=
            Arrangement(
                cwd_contents=DirContents([
                    case_with_single_def,
                ]),
                main_program_config=sym_def.main_program_config(),
            ),
            expectation=
            asrt_proc_result.sub_process_result(
                exitcode=asrt.equals(exit_codes.EXIT_OK),
                stdout=asrt.equals(lines_content(expected_reference_output.output_lines()))
            )
        )
Пример #21
0
    def test_definition_in_suite_and_case(self):
        symbol_in_suite_name = 'SUITE_SYMBOL'
        symbol_in_case_name = 'CASE_SYMBOL'

        suite_with_single_def = lines_content([
            section_names.CASE__SETUP.syntax,
            sym_def.define_string(symbol_in_suite_name, 'value'),
        ])

        case_with_single_def = File('test.case',
                                    lines_content([
                                        phase_names.SETUP.syntax,
                                        sym_def.define_string(symbol_in_case_name, 'value'),
                                    ]))

        for suite_case in suite_cases('single-definition.suite'):
            with self.subTest(suite_case.name):
                test_with_files_in_tmp_dir.check(
                    self,
                    command_line_arguments=
                    symbol_args.arguments(suite_case.value.suite_arguments + [case_with_single_def.name]),
                    arrangement=
                    Arrangement(
                        cwd_contents=DirContents([
                            suite_case.value.suite_file(suite_with_single_def),
                            case_with_single_def,
                        ]),
                        main_program_config=sym_def.main_program_config(),
                    ),
                    expectation=
                    asrt_proc_result.sub_process_result(
                        exitcode=asrt.equals(exit_codes.EXIT_OK),
                        stdout=asrt.equals(output.list_of([
                            output.SymbolReport(symbol_in_suite_name, ValueType.STRING, num_refs=0),
                            output.SymbolReport(symbol_in_case_name, ValueType.STRING, num_refs=0),
                        ])),
                    )
                )
Пример #22
0
    def test_single_definition(self):
        symbol_name__before_preproc = 'STRING_SYMBOL__BEFORE_PRE_PROC'
        symbol_name__after_preproc = 'STRING_SYMBOL'

        py_pgm_that_replaces_symbol_name = File(
            'replace.py',
            preprocessor_utils.SEARCH_REPLACE_PREPROCESSOR__PY_SRC)

        case_with_single_def = File(
            'test.case',
            lines_content([
                phase_names.SETUP.syntax,
                sym_def.define_string(symbol_name__before_preproc, 'value'),
            ]))

        test_with_files_in_tmp_dir.check(
            self,
            command_line_arguments=symbol_args.
            py_search_replace_preprocessing_and_case(
                py_pgm_that_replaces_symbol_name.name,
                symbol_name__before_preproc, symbol_name__after_preproc,
                case_with_single_def.name),
            arrangement=Arrangement(
                cwd_contents=DirContents([
                    py_pgm_that_replaces_symbol_name,
                    case_with_single_def,
                ]),
                main_program_config=sym_def.main_program_config(),
            ),
            expectation=asrt_proc_result.sub_process_result(
                exitcode=asrt.equals(exit_codes.EXIT_OK),
                stdout=asrt.equals(
                    output.list_of([
                        output.SymbolSummary(symbol_name__after_preproc,
                                             ValueType.STRING,
                                             num_refs=0),
                    ])),
            ))
Пример #23
0
    def test_single_definition(self):
        symbol_name__before_preproc = 'STRING_SYMBOL__BEFORE_PRE_PROC'
        symbol_name__after_preproc = 'STRING_SYMBOL'

        py_pgm_that_replaces_symbol_name = File(
            'replace.py',
            preprocessor_utils.SEARCH_REPLACE_PREPROCESSOR__PY_SRC
        )

        case_with_single_def = File('test.case',
                                    lines_content([
                                        phase_names.SETUP.syntax,
                                        sym_def.define_string(symbol_name__before_preproc, 'value'),
                                    ]))

        test_with_files_in_tmp_dir.check(
            self,
            command_line_arguments=
            symbol_args.py_search_replace_preprocessing_and_case(py_pgm_that_replaces_symbol_name.name,
                                                                 symbol_name__before_preproc,
                                                                 symbol_name__after_preproc,
                                                                 case_with_single_def.name),
            arrangement=
            Arrangement(
                cwd_contents=DirContents([
                    py_pgm_that_replaces_symbol_name,
                    case_with_single_def,
                ]),
                main_program_config=sym_def.main_program_config(),
            ),
            expectation=
            asrt_proc_result.sub_process_result(
                exitcode=asrt.equals(exit_codes.EXIT_OK),
                stdout=asrt.equals(output.list_of([
                    output.SymbolReport(symbol_name__after_preproc, ValueType.STRING, num_refs=0),
                ])),
            )
        )
Пример #24
0
    def test_symbol_with_reference_to_builtin_symbol(self):
        existing_builtin_symbol = StringSymbolContext.of_constant(
            'BUILTIN_STRING_SYMBOL', 'the builtin symbol value')
        name_of_existing_user_defined_symbol = 'USER_DEFINED_STRING_SYMBOL'

        case_with_single_def = File(
            'test.case',
            lines_content([
                phase_names.SETUP.syntax,
                sym_def.define_string(
                    name_of_existing_user_defined_symbol,
                    symbol_reference_syntax_for_name(
                        existing_builtin_symbol.name)),
            ]))

        expected_first_line = output.summary_of_single(
            output.SymbolSummary(name_of_existing_user_defined_symbol,
                                 ValueType.STRING,
                                 num_refs=0))
        check_case_and_suite(
            self,
            symbol_command_arguments=symbol_args.individual__definition(
                case_with_single_def.name,
                name_of_existing_user_defined_symbol,
            ),
            arrangement=Arrangement(
                cwd_contents=DirContents([
                    case_with_single_def,
                ]),
                main_program_config=sym_def.main_program_config(
                    builtin_symbols=[
                        sym_def.builtin_symbol(existing_builtin_symbol)
                    ], ),
            ),
            expectation=asrt_proc_result.sub_process_result(
                exitcode=asrt.equals(exit_codes.EXIT_OK),
                stdout=asrt_str.first_line(asrt.equals(expected_first_line))))
Пример #25
0
 def runTest(self):
     expected_output = pr.sub_process_result(exitcode=asrt.equals(0),
                                             stdout=asrt.equals(''),
                                             stderr=asrt.equals(''))
     cases = [
         (
             'no act phase contents',
             []
         ),
         (
             'act phase contents of just comments',
             [instr([LINE_COMMENT_MARKER + ' a comment'])]
         ),
         (
             'act phase contents of just comments and empty lines',
             [instr([LINE_COMMENT_MARKER + ' a comment',
                     '',
                     LINE_COMMENT_MARKER + ' a second comment',
                     ])]
         ),
         (
             'act phase contents with non-comment and non-empty line',
             [instr(['not a comment and not empty',
                     ])]
         ),
     ]
     executor_parser = sut.Parser()
     for case_name, act_phase_instructions in cases:
         with self.subTest(case_name=case_name):
             arrangement = Arrangement()
             expectation = Expectation(sub_process_result_from_execute=expected_output)
             check_execution(self,
                             executor_parser,
                             act_phase_instructions,
                             arrangement,
                             expectation)
 def expected_result(self) -> Assertion[SubProcessResultInfo]:
     return asrt_process_result_info.assertion_on_process_result(
         asrt_process_result.sub_process_result(
             exitcode=asrt.equals(self.exit_code),
             stdout=asrt.equals(self.std_out),
         ))
Пример #27
0
    def test_references_SHOULD_be_listed_phase_order(self):
        name_of_existing_symbol = 'STRING_SYMBOL'

        reference_source = sym_def.reference_to(name_of_existing_symbol,
                                                ValueType.STRING)
        case_with_references = File(
            'test.xly',
            lines_content([
                phase_names.SETUP.syntax,
                sym_def.define_string(name_of_existing_symbol, 'value'),
                phase_names.CLEANUP.syntax,
                reference_source,
                phase_names.ASSERT.syntax,
                reference_source,
                phase_names.BEFORE_ASSERT.syntax,
                reference_source,
                phase_names.ACT.syntax,
                reference_source,
                phase_names.SETUP.syntax,
                reference_source,
            ]))

        expected_reference_outputs = [
            output.Reference(
                phase_identifier.SETUP,
                output.LineInFilePosition(case_with_references.name, 12),
                [reference_source]),
            output.Reference(phase_identifier.ACT, None, [reference_source]),
            output.Reference(
                phase_identifier.BEFORE_ASSERT,
                output.LineInFilePosition(case_with_references.name, 8),
                [reference_source]),
            output.Reference(
                phase_identifier.ASSERT,
                output.LineInFilePosition(case_with_references.name, 6),
                [reference_source]),
            output.Reference(
                phase_identifier.CLEANUP,
                output.LineInFilePosition(case_with_references.name, 4),
                [reference_source]),
        ]

        expected_output_lines = list(
            itertools.chain.from_iterable(
                intersperse_list(['', ''],
                                 list(
                                     map(output.Reference.output_lines,
                                         expected_reference_outputs)))))
        check_case_and_suite(
            self,
            symbol_command_arguments=symbol_args.individual__references(
                case_with_references.name,
                name_of_existing_symbol,
            ),
            arrangement=Arrangement(
                cwd_contents=DirContents([
                    case_with_references,
                ]),
                main_program_config=sym_def.main_program_config(),
            ),
            expectation=asrt_proc_result.sub_process_result(
                exitcode=asrt.equals(exit_codes.EXIT_OK),
                stdout=asrt.equals(lines_content(expected_output_lines))))
Пример #28
0
    def test_references_SHOULD_be_listed_phase_order(self):
        name_of_existing_symbol = 'STRING_SYMBOL'

        reference_source = sym_def.reference_to(name_of_existing_symbol, ValueType.STRING)
        case_with_references = File('test.case',
                                    lines_content([
                                        phase_names.SETUP.syntax,
                                        sym_def.define_string(name_of_existing_symbol, 'value'),

                                        phase_names.CLEANUP.syntax,
                                        reference_source,

                                        phase_names.ASSERT.syntax,
                                        reference_source,

                                        phase_names.BEFORE_ASSERT.syntax,
                                        reference_source,

                                        phase_names.ACT.syntax,
                                        reference_source,

                                        phase_names.SETUP.syntax,
                                        reference_source,

                                    ]))

        expected_reference_outputs = [
            output.Reference(
                phase_identifier.SETUP,
                output.LineInFilePosition(case_with_references.name, 12),
                [reference_source]
            ),
            output.Reference(
                phase_identifier.ACT,
                None,
                [reference_source]
            ),
            output.Reference(
                phase_identifier.BEFORE_ASSERT,
                output.LineInFilePosition(case_with_references.name, 8),
                [reference_source]
            ),
            output.Reference(
                phase_identifier.ASSERT,
                output.LineInFilePosition(case_with_references.name, 6),
                [reference_source]
            ),
            output.Reference(
                phase_identifier.CLEANUP,
                output.LineInFilePosition(case_with_references.name, 4),
                [reference_source]
            ),
        ]

        expected_output_lines = list(itertools.chain.from_iterable(
            intersperse_list([''],
                             list(map(output.Reference.output_lines,
                                      expected_reference_outputs)))
        )
        )
        test_with_files_in_tmp_dir.check(
            self,
            command_line_arguments=
            symbol_args.individual__references(
                case_with_references.name,
                name_of_existing_symbol,
            ),
            arrangement=
            Arrangement(
                cwd_contents=DirContents([
                    case_with_references,
                ]),
                main_program_config=sym_def.main_program_config(),
            ),
            expectation=
            asrt_proc_result.sub_process_result(
                exitcode=asrt.equals(exit_codes.EXIT_OK),
                stdout=asrt.equals(lines_content(expected_output_lines)))
        )