Beispiel #1
0
    def _check_failing_validation_of_referenced_program__for_relativity(self, missing_file_relativity: RelOptionType):
        relativity_conf = relativity_options.conf_rel_any(missing_file_relativity)

        program_symbol_with_ref_to_non_exiting_exe_file = ProgramSymbolContext.of_sdv(
            'PGM_WITH_REF_TO_EXE_FILE',
            program_sdvs.ref_to_exe_file(
                constant(simple_of_rel_option(relativity_conf.relativity_option,
                                              'non-existing-exe-file')))
        )

        program_symbol_with_ref_to_non_exiting_file_as_argument = ProgramSymbolContext.of_sdv(
            'PGM_WITH_ARG_WITH_REF_TO_FILE',
            program_sdvs.interpret_py_source_file_that_must_exist(
                constant(simple_of_rel_option(relativity_conf.relativity_option,
                                              'non-existing-python-file.py')))
        )

        expectation = MultiSourceExpectation.of_const(
            symbol_references=asrt.anything_goes(),
            primitive=asrt.anything_goes(),
            execution=ExecutionExpectation(
                validation=FAILING_VALIDATION_ASSERTION_FOR_PARTITION[relativity_conf.directory_structure_partition],
            )
        )

        symbols = SymbolContext.symbol_table_of_contexts([
            program_symbol_with_ref_to_non_exiting_exe_file,
            program_symbol_with_ref_to_non_exiting_file_as_argument,
        ])
        arrangement = arrangement_w_tcds(
            symbols=symbols,
        )

        cases = [
            NameAndValue(
                'executable does not exist',
                RawProgramOfSymbolReferenceAbsStx(program_symbol_with_ref_to_non_exiting_exe_file.name),
            ),
            NameAndValue(
                'file referenced from argument does not exist',
                RawProgramOfSymbolReferenceAbsStx(program_symbol_with_ref_to_non_exiting_file_as_argument.name),
            ),
        ]

        for case in cases:
            with self.subTest(case=case.name):
                # ACT & ASSERT #
                CHECKER_WO_EXECUTION.check__abs_stx__layouts__source_variants__wo_input(
                    self,
                    equivalent_source_variants__for_consume_until_end_of_last_line__s__nsc,
                    case.value,
                    arrangement,
                    expectation,
                )
Beispiel #2
0
def environment_exe_case(
    environment: Dict[str, str],
    program_symbol_name: str,
) -> NExArr[PrimAndExeExpectation[MatcherWTrace, MatchingResult], Arrangement]:
    py_file = File(
        'environment-vars-check.py',
        py_programs.
        pgm_that_exists_with_zero_exit_code_iff_environment_vars_not_included(
            environment))

    py_file_rel_opt_conf = rel_opt.conf_rel_any(RelOptionType.REL_TMP)
    py_file_conf = py_file_rel_opt_conf.named_file_conf(py_file.name)

    program_symbol = ProgramSymbolContext.of_sdv(
        program_symbol_name,
        program_sdvs.interpret_py_source_file_that_must_exist(
            py_file_conf.path_sdv))

    return NExArr(
        'Environment: {}'.format(repr(environment)),
        PrimAndExeExpectation.of_exe(
            main_result=asrt_run.is_result_for_py_interpreter(
                py_run_programs.EXIT_CODE_FOR_SUCCESS)),
        arrangement_w_tcds(
            tcds_contents=py_file_rel_opt_conf.
            populator_for_relativity_option_root(DirContents([py_file])),
            symbols=program_symbol.symbol_table,
            process_execution=ProcessExecutionArrangement(
                process_execution_settings=ProcessExecutionSettings.
                with_environ(environment))))
    def run_test(self):
        def resolve_validator_that_fails_pre_sds(
                symbols: SymbolTable) -> DdvValidator:
            return ConstantDdvValidator.of_pre_sds(
                asrt_text_doc.new_single_string_text_for_test('err msg'))

        referenced_system_program_sdv_w_invalid_arguments = program_sdvs.system_program(
            string_sdvs.str_constant('valid-system-program'),
            ArgumentsSdv(list_sdvs.from_str_constant('the arg'),
                         [resolve_validator_that_fails_pre_sds]))

        valid_program_symbol = ProgramSymbolContext.of_sdv(
            'VALID_PROGRAM', referenced_system_program_sdv_w_invalid_arguments)

        argument_syntax = ArgumentOfRichStringAbsStx.of_str('valid-arg')

        reference_and_additional_invalid_argument = self.source_to_parse(
            valid_program_symbol.name,
            [argument_syntax],
        )
        # ACT & ASSERT #
        self.integration_checker(
        ).check__abs_stx__layouts__source_variants__wo_input(
            self.put,
            equivalent_source_variants__for_consume_until_end_of_last_line__s__nsc,
            reference_and_additional_invalid_argument,
            arrangement_w_tcds(symbols=valid_program_symbol.symbol_table, ),
            MultiSourceExpectation.of_const(
                symbol_references=valid_program_symbol.references_assertion,
                primitive=asrt.anything_goes(),
                execution=ExecutionExpectation(
                    validation=validation.ValidationAssertions.
                    pre_sds_fails__w_any_msg(), )),
        )
    def run_test(self):
        relativity_conf = relativity_options.conf_rel_any(
            self._missing_file_relativity)

        referenced_program_arguments = [
            'valid arg 1 of referenced', 'valid arg 2 of referenced'
        ]
        referenced_system_program_sdv = program_sdvs.system_program(
            string_sdvs.str_constant('valid-system-program'),
            ArgumentsSdv.new_without_validation(
                list_sdvs.from_str_constants(referenced_program_arguments)))

        valid_program_symbol = ProgramSymbolContext.of_sdv(
            'VALID_PROGRAM', referenced_system_program_sdv)

        invalid_argument_syntax = ArgumentOfExistingPathAbsStx(
            relativity_conf.path_abs_stx_of_name('non-existing-file'))
        reference_and_additional_invalid_argument = self.source_to_parse(
            valid_program_symbol.name,
            [invalid_argument_syntax],
        )
        # ACT & ASSERT #
        self.integration_checker(
        ).check__abs_stx__layouts__source_variants__wo_input(
            self.put,
            equivalent_source_variants__for_consume_until_end_of_last_line__s__nsc,
            reference_and_additional_invalid_argument,
            arrangement_w_tcds(symbols=valid_program_symbol.symbol_table, ),
            MultiSourceExpectation.of_const(
                symbol_references=valid_program_symbol.references_assertion,
                primitive=asrt.anything_goes(),
                execution=ExecutionExpectation(
                    validation=FAILING_VALIDATION_ASSERTION_FOR_PARTITION[
                        relativity_conf.directory_structure_partition], )),
        )
Beispiel #5
0
    def runTest(self):
        output_to_stderr = 'on stderr'
        py_file = File(
            'exit-with-value-on-command-line.py',
            py_pgm_that_exits_with_1st_value_on_command_line(output_to_stderr))

        py_file_rel_opt_conf = relativity_options.conf_rel_any(
            RelOptionType.REL_TMP)
        py_file_conf = py_file_rel_opt_conf.named_file_conf(py_file.name)

        program_that_executes_py_pgm_symbol = ProgramSymbolContext.of_sdv(
            'PROGRAM_THAT_EXECUTES_PY_FILE',
            program_sdvs.interpret_py_source_file_that_must_exist(
                py_file_conf.path_sdv))

        symbols = program_that_executes_py_pgm_symbol.symbol_table

        instruction_arguments = [
            pgm_args.symbol_ref_command_line(
                program_that_executes_py_pgm_symbol.name),
            0,
        ]
        self.conf.run_test(
            self,
            single_line_source(args.sequence(instruction_arguments).as_str),
            self.conf.arrangement(tcds_contents=py_file_rel_opt_conf.
                                  populator_for_relativity_option_root(
                                      DirContents([py_file])),
                                  symbols=symbols),
            self.conf.expect_success(symbol_usages=asrt.matches_sequence(
                [program_that_executes_py_pgm_symbol.reference_assertion])),
        )
    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),
                    )
                )
            ),
        )
    def runTest(self):
        # ARRANGE #

        command_py_program = py_program.exit_with_code(0)

        py_file = fs.File(
            'the-program.py',
            lines_content(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,
                )
            )
        )

        error_message = 'error message from transformer'
        transformer = StringTransformerPrimitiveSymbolContext(
            'HARD_ERROR_TRANSFORMER',
            string_transformers.model_access_raises_hard_error(error_message),
        )

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

        symbols = [
            program_wo_transformation,
            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.matches_hard_error(
                    asrt_failure_details.is_failure_message_matching__td(
                        asrt_text_doc.is_string_for_test_that_equals(error_message)
                    )
                ),
            ),
        )
Beispiel #8
0
class TestProgramViaSymbolReference(unittest.TestCase):
    output_to_stderr = 'on stderr'
    py_file = File(
        'exit-with-value-on-command-line.py',
        py_pgm_that_exits_with_1st_value_on_command_line(output_to_stderr))

    py_file_rel_opt_conf = relativity_options.conf_rel_any(
        RelOptionType.REL_TMP)
    py_file_conf = py_file_rel_opt_conf.named_file_conf(py_file.name)

    program_that_executes_py_pgm_symbol = ProgramSymbolContext.of_sdv(
        'PROGRAM_THAT_EXECUTES_PY_FILE',
        program_sdvs.interpret_py_source_file_that_must_exist(
            py_file_conf.path_sdv))

    symbols = program_that_executes_py_pgm_symbol.symbol_table

    def test_check_zero_exit_code(self):
        EXECUTION_CHECKER.check__w_source_variants(
            self,
            args.sequence([
                pgm_args.symbol_ref_command_line(
                    self.program_that_executes_py_pgm_symbol.name), 0
            ]).as_str,
            Arrangement.phase_agnostic(
                tcds=TcdsArrangement(tcds_contents=self.py_file_rel_opt_conf.
                                     populator_for_relativity_option_root(
                                         DirContents([self.py_file])), ),
                symbols=self.symbols),
            MultiSourceExpectation.phase_agnostic(
                main_result=result_assertions.equals(0, None),
                symbol_usages=asrt.matches_sequence([
                    self.program_that_executes_py_pgm_symbol.
                    reference_assertion
                ])))

    def test_check_non_zero_exit_code(self):
        exit_code = 87
        EXECUTION_CHECKER.check__w_source_variants(
            self,
            args.sequence([
                pgm_args.symbol_ref_command_line(
                    self.program_that_executes_py_pgm_symbol.name), exit_code
            ]).as_str,
            Arrangement.phase_agnostic(
                tcds=TcdsArrangement(tcds_contents=self.py_file_rel_opt_conf.
                                     populator_for_relativity_option_root(
                                         DirContents([self.py_file])), ),
                symbols=self.symbols),
            MultiSourceExpectation.phase_agnostic(
                main_result=result_assertions.equals(exit_code,
                                                     self.output_to_stderr),
                symbol_usages=asrt.matches_sequence([
                    self.program_that_executes_py_pgm_symbol.
                    reference_assertion
                ])))
Beispiel #9
0
    def _check(
        self,
        output: StdOutputFilesContents,
        exit_code_cases: List[int],
        ignore_exit_code: bool,
        execution_expectation: ExecutionExpectation,
    ):
        # ARRANGE #

        py_file_rel_opt_conf = rel_opt.conf_rel_any(RelOptionType.REL_TMP)

        for exit_code in exit_code_cases:
            with self.subTest(non_zero_exit_code=exit_code):
                py_file = File(
                    'exit-with-hard-coded-exit-code.py',
                    py_programs.py_pgm_with_stdout_stderr_exit_code(
                        stdout_output=output.out,
                        stderr_output=output.err,
                        exit_code=exit_code,
                    ),
                )

                py_file_conf = py_file_rel_opt_conf.named_file_conf(
                    py_file.name)

                program_symbol = ProgramSymbolContext.of_sdv(
                    'PROGRAM_SYMBOL_NAME',
                    program_sdvs.interpret_py_source_file_that_must_exist(
                        py_file_conf.path_sdv))

                # ACT && ASSERT #

                integration_check.CHECKER__PARSE_FULL.check(
                    self,
                    args.syntax_for_run(
                        program_args.symbol_ref_command_elements(
                            program_symbol.name),
                        ignore_exit_code=ignore_exit_code,
                    ).as_remaining_source,
                    model_constructor.arbitrary(self),
                    arrangement_w_tcds(
                        symbols=program_symbol.symbol_table,
                        tcds_contents=py_file_rel_opt_conf.
                        populator_for_relativity_option_root(
                            DirContents([py_file])),
                    ),
                    Expectation(
                        ParseExpectation(
                            source=asrt_source.is_at_end_of_line(1),
                            symbol_references=program_symbol.
                            references_assertion),
                        execution_expectation,
                    ),
                )
Beispiel #10
0
 def __init__(
         self,
         output_file: ProcOutputFile,
         stdin_defined_for_program: Sequence[StringSourceSdv] = (),
 ):
     self.output_file = output_file
     self._copy_program_symbol = ProgramSymbolContext.of_sdv(
         'COPY_STDIN',
         program_sdvs.for_py_source_on_command_line(
             py_programs.copy_stdin_to(output_file),
             stdin=stdin_defined_for_program))
    def _check(
        self,
        command_driver: CommandDriverSdvCase,
        arguments_of_referenced_command: List[str],
        accumulated_arguments_of_referenced_program: List[str],
        additional_argument: List[str],
    ):
        # ARRANGE #
        all_arguments = (arguments_of_referenced_command +
                         accumulated_arguments_of_referenced_program +
                         additional_argument)

        def expected_program(
                env: AssertionResolvingEnvironment) -> Assertion[Program]:
            return asrt_pgm_val.matches_program(
                asrt_command.matches_command(
                    driver=command_driver.expected_command_driver(env),
                    arguments=asrt.equals(all_arguments)),
                stdin=asrt_pgm_val.is_no_stdin(),
                transformer=asrt_pgm_val.is_no_transformation(),
            )

        referenced_program_symbol = ProgramSymbolContext.of_sdv(
            'REFERENCED_PROGRAM',
            command_program_sdv.ProgramSdvForCommand(
                CommandSdv(
                    command_driver.command_driver,
                    ArgumentsSdv.new_without_validation(
                        list_sdvs.from_str_constants(
                            arguments_of_referenced_command))),
                AccumulatedComponents.of_arguments(
                    ArgumentsSdv.new_without_validation(
                        list_sdvs.from_str_constants(
                            accumulated_arguments_of_referenced_program)))))
        source_to_parse = self.source_to_parse(
            referenced_program_symbol.name,
            [
                ArgumentOfRichStringAbsStx.of_str(arg)
                for arg in additional_argument
            ],
        )
        # ACT & ASSERT #
        self.integration_checker().check__abs_stx__wo_input(
            self.put,
            source_to_parse,
            command_driver.mk_arrangement(
                referenced_program_symbol.symbol_table),
            Expectation(
                parse=ParseExpectation(
                    symbol_references=referenced_program_symbol.
                    references_assertion, ),
                primitive=expected_program,
            ),
        )
Beispiel #12
0
    def __init__(self,
                 put: unittest.TestCase,
                 exit_code: int = 0,
                 additional_stdin: str = ''):
        super().__init__(
            put, exit_code,
            self.CONCATENATED_STRING_SOURCES_CONTENTS + additional_stdin)

        self.program_w_stdin_symbol = ProgramSymbolContext.of_sdv(
            'REFERENCED_PROGRAM',
            self._program_sdv_w_stdin__wo_sym_refs(
                self.STR_SRC_CONTENTS__OF_REFERENCED_PROGRAM))
Beispiel #13
0
    def runTest(self):
        # ARRANGE #

        py_file = File('stdin-to-upper.py',
                       _PGM_THAT_OUTPUTS_STDIN_IN_UPPER_CASE)

        py_file_rel_opt_conf = rel_opt.conf_rel_any(RelOptionType.REL_TMP)
        py_file_conf = py_file_rel_opt_conf.named_file_conf(py_file.name)

        program_symbol = ProgramSymbolContext.of_sdv(
            'PROGRAM_THAT_EXECUTES_PY_FILE',
            program_sdvs.interpret_py_source_file_that_must_exist(py_file_conf.path_sdv)
        )

        input_model_lines = [
            'the\n',
            'input\n',
            'model',
        ]
        expected_output_model_lines = list(map(str.upper, input_model_lines))

        for with_ignored_exit_code in [False, True]:
            with self.subTest(with_ignored_exit_code=with_ignored_exit_code):
                # ACT && ASSERT #

                integration_check.CHECKER__PARSE_FULL.check__w_source_variants_for_full_line_parser(
                    self,
                    args.syntax_for_run(
                        program_args.symbol_ref_command_elements(program_symbol.name),
                        ignore_exit_code=with_ignored_exit_code,
                    ),
                    model_constructor.of_lines(self, input_model_lines),
                    arrangement_w_tcds(
                        tcds_contents=py_file_rel_opt_conf.populator_for_relativity_option_root(
                            DirContents([py_file])
                        ),
                        symbols=program_symbol.symbol_table,
                    ),
                    MultiSourceExpectation(
                        symbol_references=program_symbol.references_assertion,
                        execution=ExecutionExpectation(
                            main_result=asrt_string_source.pre_post_freeze__matches_lines(
                                asrt.equals(expected_output_model_lines),
                                may_depend_on_external_resources=asrt.equals(True),
                                frozen_may_depend_on_external_resources=asrt.anything_goes(),
                            )
                        ),
                        primitive=prim_asrt__constant(
                            asrt_string_transformer.is_identity_transformer(False)
                        ),
                    ),
                )
Beispiel #14
0
def program_reference__w_argument_list() -> PgmAndArgsCase:
    system_program = 'the-system-program'
    system_program_sdv = program_sdvs.system_program(string_sdvs.str_constant(system_program))
    system_program_symbol = ProgramSymbolContext.of_sdv('SYSTEM_PROGRAM_SYMBOL', system_program_sdv)

    return PgmAndArgsCase.wo_tcds(
        'reference to program w argument list',
        pgm_and_args=ProgramOfSymbolReferenceAbsStx(system_program_symbol.name),
        symbols=[system_program_symbol],
        expected_command_driver=prim_asrt__constant(
            asrt_command.matches_system_program_command_driver(
                asrt.equals(system_program)
            )),
    )
Beispiel #15
0
    def __init__(
        self,
        symbol_name: str,
        string_transformer_case: str_trans_validation_cases.ValidationCase,
    ):
        self._string_transformer_case = string_transformer_case
        additional_components = AccumulatedComponents.of_transformation(
            StringTransformerSdvReference(
                string_transformer_case.symbol_context.name))
        program_w_transformer = program_sdvs.system_program(
            string_sdvs.str_constant('system-program')).new_accumulated(
                additional_components)

        self._program_symbol_context = ProgramSymbolContext.of_sdv(
            symbol_name, program_w_transformer)
Beispiel #16
0
 def _instructions_for_executing_py_source(
         self, py_src: List[str]) -> ContextManager[TestCaseSourceSetup]:
     py_file = fs.File('the-program.py', lines_content(py_src))
     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_ACT,
                 py_file.name,
             )))
     program_line = args.symbol_ref_command_line(symbol.name).as_str
     yield TestCaseSourceSetup(
         act_phase_instructions=[instr([program_line])],
         home_act_dir_contents=DirContents([py_file]),
         symbols=symbol.symbol_table,
         symbol_usages=symbol.usages_assertion)
Beispiel #17
0
 def runTest(self):
     # ARRANGE #
     symbol = ProgramSymbolContext.of_sdv(
         'PROGRAM_SYMBOL',
         program_sdvs.system_program(
             string_sdvs.str_constant('non-existing-system-program')))
     program_line = args.symbol_ref_command_line(symbol.name).as_str
     # ACT & ASSERT #
     integration_check.check_execution(
         self,
         sut.actor(),
         [instr([program_line])],
         arrangement_w_tcds(symbol_table=symbol.symbol_table),
         Expectation.hard_error_from_execute(
             symbol_usages=symbol.usages_assertion),
     )
Beispiel #18
0
def exit_code_exe_cases(
    program_symbol_name: str,
    exit_code_symbol_name: str,
) -> Sequence[NExArr[PrimAndExeExpectation[MatcherWTrace, MatchingResult],
                     Arrangement]]:
    py_file = File(
        'exit-with-value-on-command-line.py',
        py_programs.py_pgm_that_exits_with_1st_value_on_command_line(''))

    py_file_rel_opt_conf = rel_opt.conf_rel_any(RelOptionType.REL_TMP)
    py_file_conf = py_file_rel_opt_conf.named_file_conf(py_file.name)

    program_symbol = ProgramSymbolContext.of_sdv(
        program_symbol_name,
        program_sdvs.interpret_py_source_file_that_must_exist(
            py_file_conf.path_sdv))

    def case(
        exit_code_from_program: int
    ) -> NExArr[PrimAndExeExpectation[MatcherWTrace, MatchingResult],
                Arrangement]:
        exit_code_symbol = StringIntConstantSymbolContext(
            exit_code_symbol_name, exit_code_from_program)

        return NExArr(
            'Exit code {}'.format(exit_code_from_program),
            PrimAndExeExpectation.of_exe(
                main_result=asrt_run.is_result_for_py_interpreter(
                    exit_code_from_program)),
            arrangement_w_tcds(
                tcds_contents=py_file_rel_opt_conf.
                populator_for_relativity_option_root(DirContents([py_file])),
                symbols=SymbolContext.symbol_table_of_contexts([
                    program_symbol,
                    exit_code_symbol,
                ]),
            ))

    exit_code_from_program_cases = [0, 1, 3, 69, 72]

    return [
        case(exit_code_from_program)
        for exit_code_from_program in exit_code_from_program_cases
    ]
Beispiel #19
0
    def runTest(self):
        python_source = 'exit(72)'

        name_of_defined_symbol = 'the_symbol'

        referred_symbol = ProgramSymbolContext.of_sdv(
            'PRE_EXISTING_PROGRAM_SYMBOL',
            program_sdvs.for_py_source_on_command_line(python_source))

        symbols = referred_symbol.symbol_table

        program_abs_stx = ProgramOfSymbolReferenceAbsStx(referred_symbol.name)

        define_symbol_syntax = DefineSymbolWMandatoryValue(
            name_of_defined_symbol,
            ValueType.PROGRAM,
            program_abs_stx,
        )

        expected_symbol_container = matches_container(
            asrt.equals(ValueType.PROGRAM),
            sdv=type_sdv_assertions.matches_sdv_of_program_constant(
                references=asrt.matches_sequence(
                    [referred_symbol.reference_assertion]),
                primitive_value=matches_py_source_on_cmd_line_program(
                    python_source),
                symbols=symbols))
        expectation = MultiSourceExpectation.phase_agnostic(
            symbol_usages=asrt.matches_sequence([
                asrt_sym_usage.matches_definition(
                    name=asrt.equals(name_of_defined_symbol),
                    container=expected_symbol_container)
            ]),
            symbols_after_main=assert_symbol_table_is_singleton(
                expected_name=name_of_defined_symbol,
                value_assertion=expected_symbol_container,
            ))
        INSTRUCTION_CHECKER.check__abs_stx__layout_and_source_variants(
            self,
            define_symbol_syntax,
            Arrangement.phase_agnostic(),
            expectation,
        )
Beispiel #20
0
    def runTest(self):
        # ARRANGE #
        program_symbol = ProgramSymbolContext.of_sdv(
            'A_PROGRAM', program_sdvs.arbitrary__without_symbol_references())

        pgm_and_args_cases = [
            NameAndValue('shell command',
                         pgm_args.shell_command('shell-command arg')),
            NameAndValue(
                'system command',
                pgm_args.system_program_argument_elements(
                    'system command arg')),
            NameAndValue('python',
                         pgm_args.interpret_py_source_elements('exit(0)')),
            NameAndValue(
                'symbol reference',
                pgm_args.symbol_ref_command_elements(program_symbol.name, [])),
        ]
        for pgm_and_args_case in pgm_and_args_cases:
            for validation_case in failing_validation_cases():
                arguments = pgm_and_args_case.value.followed_by_lines(
                    [validation_case.value.transformer_arguments_elements])

                symbols = SymbolContext.symbol_table_of_contexts([
                    program_symbol,
                    validation_case.value.symbol_context,
                ])

                with self.subTest(pgm_and_args_case=pgm_and_args_case.name,
                                  validation_case=validation_case.name):
                    # ACT & ASSERT #
                    CHECKER_W_TRANSFORMATION.check(
                        self, arguments.as_remaining_source,
                        ProcOutputFile.STDOUT,
                        arrangement_w_tcds(symbols=symbols),
                        Expectation(
                            ParseExpectation(
                                symbol_references=asrt.anything_goes(), ),
                            ExecutionExpectation(
                                validation=validation_case.value.expectation,
                            )))
Beispiel #21
0
 def runTest(self):
     for case in VALIDATION_CASES:
         with self.subTest(case.name):
             program_sdv = program_sdvs.ref_to_exe_file(
                 path_sdvs.of_rel_option_with_const_file_name(
                     case.path_relativity, 'non-existing'))
             program_symbol = ProgramSymbolContext.of_sdv(
                 'PROGRAM_SYMBOL', program_sdv)
             integration_check.check_execution(
                 self,
                 sut.actor(),
                 [
                     instr([
                         args.symbol_ref_command_line(
                             program_symbol.name).as_str
                     ])
                 ],
                 arrangement_w_tcds(
                     symbol_table=program_symbol.symbol_table, ),
                 Expectation(symbol_usages=program_symbol.usages_assertion,
                             validation=case.expectation),
             )
Beispiel #22
0
def argument_list_exe_case(
    command_line_arguments: List[str],
    expected_program_arguments: List[str],
    program_symbol_name: str,
    list_arg_symbol_name: str,
) -> NExArr[PrimAndExeExpectation[MatcherWTrace, MatchingResult], Arrangement]:
    py_file = File(
        'arguments-check.py',
        py_run_programs.
        pgm_that_exists_with_zero_exit_code_iff_arguments_are_expected(
            expected_program_arguments))

    py_file_rel_opt_conf = rel_opt.conf_rel_any(RelOptionType.REL_TMP)
    py_file_conf = py_file_rel_opt_conf.named_file_conf(py_file.name)

    program_symbol = ProgramSymbolContext.of_sdv(
        program_symbol_name,
        program_sdvs.interpret_py_source_file_that_must_exist(
            py_file_conf.path_sdv))

    arg_list_symbol = ListSymbolContext.of_constants(list_arg_symbol_name,
                                                     command_line_arguments)

    return NExArr(
        'Command line arguments: {}'.format(repr(command_line_arguments), ),
        PrimAndExeExpectation.of_exe(
            main_result=asrt_run.is_result_for_py_interpreter(
                py_run_programs.EXIT_CODE_FOR_SUCCESS)),
        arrangement_w_tcds(
            tcds_contents=py_file_rel_opt_conf.
            populator_for_relativity_option_root(DirContents([py_file])),
            symbols=SymbolContext.symbol_table_of_contexts([
                program_symbol,
                arg_list_symbol,
            ]),
        ))
Beispiel #23
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)),
                    )
Beispiel #24
0
    def test_stdin_in_referenced_program_and_as_source_argument(self):
        # ARRANGE #
        str_src_contents__of_argument = 'the_str_src_contents__of_argument'
        str_src_contents__of_referenced_pgm = 'the_str_src_contents__of_program'
        stdin_argument_syntax = str_src_abs_stx.StringSourceOfStringAbsStx.of_str(
            str_src_contents__of_argument)
        stdin_sdv__of_referenced = str_src_sdvs.ConstantStringStringSourceSdv(
            string_sdvs.str_constant(str_src_contents__of_referenced_pgm))

        referenced_program__system_program = 'the-system-program'
        referenced_program__sdv = program_sdvs.system_program(
            string_sdvs.str_constant(referenced_program__system_program),
            stdin=[stdin_sdv__of_referenced],
        )
        referenced_program = ProgramSymbolContext.of_sdv(
            'REFERENCED_PROGRAM', referenced_program__sdv)

        symbols__symbol_table = [referenced_program]
        symbols__expected_references = [referenced_program]

        arguments_cases = [
            NameAndValue(
                'no arguments',
                [],
            ),
            NameAndValue(
                'single argument',
                ['arg1'],
            )
        ]

        for arguments_case in arguments_cases:
            with self.subTest(arguments=arguments_case.name):
                program_w_stdin = FullProgramAbsStx(
                    ProgramOfSymbolReferenceAbsStx(referenced_program.name, [
                        ArgumentOfRichStringAbsStx.of_str(arg)
                        for arg in arguments_case.value
                    ]),
                    stdin=stdin_argument_syntax,
                )

                expected_primitive = asrt_pgm_val.matches_program(
                    asrt_command.matches_command(
                        driver=asrt_command.
                        matches_system_program_command_driver(
                            asrt.equals(referenced_program__system_program)),
                        arguments=asrt.equals(arguments_case.value),
                    ),
                    stdin=asrt.matches_sequence([
                        asrt_str_src.matches__str(
                            asrt.equals(str_src_contents__of_referenced_pgm)),
                        asrt_str_src.matches__str(
                            asrt.equals(str_src_contents__of_argument)),
                    ]),
                    transformer=asrt_pgm_val.is_no_transformation(),
                )

                # ACT & ASSERT #
                CHECKER_WO_EXECUTION.check__abs_stx__layouts__source_variants__wo_input(
                    self, equivalent_source_variants__for_expr_parse__s__nsc,
                    program_w_stdin,
                    arrangement_w_tcds(
                        symbols=SymbolContext.symbol_table_of_contexts(
                            symbols__symbol_table), ),
                    MultiSourceExpectation.of_const(
                        symbol_references=SymbolContext.
                        references_assertion_of_contexts(
                            symbols__expected_references),
                        primitive=expected_primitive,
                    ))
Beispiel #25
0
    def test_stdin_in_referenced_program_and_as_source_argument(self):
        # ARRANGE #
        stdin_contents = 'str_src_contents'
        valid_stdin_sdv = sdvs.ConstantStringStringSourceSdv(
            string_sdvs.str_constant(stdin_contents))
        valid_stdin_syntax = str_src_abs_stx.StringSourceOfStringAbsStx.of_str(
            stdin_contents)

        referenced_program__system_program = 'the-system-program'

        for validation_case in validation_cases.failing_validation_cases():
            invalid_stdin_location_cases = [
                ValidationCaseWAccumulation(
                    'in referenced symbol',
                    sdv_of_referenced_program=validation_case.value.
                    symbol_context.sdv,
                    syntax_accumulated=valid_stdin_syntax,
                    symbols=[],
                ),
                ValidationCaseWAccumulation(
                    'as source argument',
                    sdv_of_referenced_program=valid_stdin_sdv,
                    syntax_accumulated=validation_case.value.syntax,
                    symbols=[validation_case.value.symbol_context],
                ),
            ]
            for invalid_stdin_location_case in invalid_stdin_location_cases:
                referenced_program__sdv = program_sdvs.system_program(
                    string_sdvs.str_constant(
                        referenced_program__system_program),
                    stdin=[
                        invalid_stdin_location_case.sdv_of_referenced_program
                    ])
                referenced_program = ProgramSymbolContext.of_sdv(
                    'REFERENCED_PROGRAM', referenced_program__sdv)
                program_w_stdin = FullProgramAbsStx(
                    ProgramOfSymbolReferenceAbsStx(referenced_program.name, ),
                    stdin=invalid_stdin_location_case.syntax_of_accumulated,
                )
                symbols__all = [
                    validation_case.value.symbol_context, referenced_program
                ]
                symbols__expected_references = [
                    referenced_program
                ] + invalid_stdin_location_case.symbols

                # ACT & ASSERT #
                CHECKER_WO_EXECUTION.check__abs_stx__layouts__source_variants__wo_input(
                    self,
                    equivalent_source_variants__for_expr_parse__s__nsc,
                    program_w_stdin,
                    arrangement_w_tcds(
                        symbols=SymbolContext.symbol_table_of_contexts(
                            symbols__all), ),
                    MultiSourceExpectation.of_const(
                        symbol_references=SymbolContext.
                        references_assertion_of_contexts(
                            symbols__expected_references),
                        execution=ExecutionExpectation(
                            validation=validation_case.value.assertion, ),
                        primitive=asrt.anything_goes(),
                    ),
                    sub_test_identifiers={
                        'validation': validation_case.name,
                        'invalid_stdin_location':
                        invalid_stdin_location_case.name,
                    })
Beispiel #26
0
    def runTest(self):
        # ARRANGE #

        py_file = File('output-env-vars.py',
                       _PGM_THAT_OUTPUTS_ENVIRONMENT_VARS)

        py_file_rel_opt_conf = rel_opt.conf_rel_any(RelOptionType.REL_TMP)
        py_file_conf = py_file_rel_opt_conf.named_file_conf(py_file.name)

        program_symbol = ProgramSymbolContext.of_sdv(
            'PROGRAM_THAT_EXECUTES_PY_FILE',
            program_sdvs.interpret_py_source_file_that_must_exist(
                py_file_conf.path_sdv))
        environment_cases = [
            {
                '1': 'one',
            },
            {
                '1': 'one',
                '2': 'two',
            },
        ]

        for with_ignored_exit_code in [False, True]:
            with self.subTest(with_ignored_exit_code=with_ignored_exit_code):
                # ACT && ASSERT #

                integration_check.CHECKER__PARSE_FULL.check_multi(
                    self,
                    args.syntax_for_run(
                        program_args.symbol_ref_command_elements(
                            program_symbol.name),
                        ignore_exit_code=with_ignored_exit_code,
                    ),
                    ParseExpectation(
                        source=asrt_source.is_at_end_of_line(1),
                        symbol_references=program_symbol.references_assertion,
                    ),
                    model_constructor.arbitrary(self),
                    [
                        NExArr(
                            'Environment: {}'.format(repr(environment)),
                            PrimAndExeExpectation(
                                ExecutionExpectation(
                                    main_result=asrt_string_source.
                                    pre_post_freeze__matches_lines(
                                        _AssertLinesRepresentSubSetOfDict(
                                            environment),
                                        may_depend_on_external_resources=asrt.
                                        equals(True),
                                        frozen_may_depend_on_external_resources
                                        =asrt.anything_goes(),
                                    )),
                                prim_asrt__constant(
                                    asrt_string_transformer.
                                    is_identity_transformer(False)),
                            ),
                            arrangement_w_tcds(
                                tcds_contents=py_file_rel_opt_conf.
                                populator_for_relativity_option_root(
                                    DirContents([py_file])),
                                symbols=program_symbol.symbol_table,
                                process_execution=ProcessExecutionArrangement(
                                    process_execution_settings=
                                    ProcessExecutionSettings.with_environ(
                                        environment))))
                        for environment in environment_cases
                    ],
                )
Beispiel #27
0
    def runTest(self):
        # ARRANGE #

        py_file = File(
            'print-arguments-on-stdout.py',
            _PY_PROGRAM_THAT_PRINTS_ONE_ARGUMENT_PER_LINE_ON_STDOUT,
        )
        py_file_rel_opt_conf = rel_opt.conf_rel_any(RelOptionType.REL_TMP)

        py_file_conf = py_file_rel_opt_conf.named_file_conf(py_file.name)

        program_symbol = ProgramSymbolContext.of_sdv(
            'PROGRAM_SYMBOL_NAME',
            program_sdvs.interpret_py_source_file_that_must_exist(
                py_file_conf.path_sdv))

        command_line_arg_list_symbol_name = 'COMMAND_LINE_ARGUMENTS_LIST'

        command_line_arguments_cases = [
            [],
            ['one'],
            ['one', 'two'],
        ]

        def arguments_case(
            command_line_arguments: List[str],
        ) -> NExArr[PrimAndExeExpectation[StringTransformer, StringSource],
                    Arrangement]:
            arg_list_symbol = ListSymbolContext.of_constants(
                command_line_arg_list_symbol_name, command_line_arguments)

            symbols = [
                program_symbol,
                arg_list_symbol,
            ]

            expected_lines_on_stdout = asrt.matches_sequence(
                [asrt.equals(arg + '\n') for arg in command_line_arguments])

            return NExArr(
                'Arguments: ' + repr(command_line_arguments),
                PrimAndExeExpectation(
                    ExecutionExpectation(
                        main_result=asrt_string_source.
                        pre_post_freeze__matches_lines(
                            expected_lines_on_stdout,
                            may_depend_on_external_resources=asrt.equals(True),
                            frozen_may_depend_on_external_resources=asrt.
                            anything_goes(),
                        )),
                    prim_asrt__constant(
                        asrt_string_transformer.is_identity_transformer(
                            False)),
                ),
                arrangement_w_tcds(
                    symbols=SymbolContext.symbol_table_of_contexts(symbols),
                    tcds_contents=py_file_rel_opt_conf.
                    populator_for_relativity_option_root(DirContents([py_file
                                                                      ])),
                ),
            )

        for with_ignored_exit_code in [False, True]:
            with self.subTest(with_ignored_exit_code=with_ignored_exit_code):
                # ACT && ASSERT #

                integration_check.CHECKER__PARSE_FULL.check_multi(
                    self,
                    args.syntax_for_run(
                        program_args.symbol_ref_command_elements(
                            program_symbol.name,
                            arguments=[
                                symbol_reference_syntax_for_name(
                                    command_line_arg_list_symbol_name)
                            ],
                        ),
                        ignore_exit_code=with_ignored_exit_code,
                    ),
                    ParseExpectation(
                        source=asrt_source.is_at_end_of_line(1),
                        symbol_references=asrt.matches_sequence([
                            program_symbol.reference_assertion,
                            is_reference_to__w_str_rendering(
                                command_line_arg_list_symbol_name),
                        ]),
                    ),
                    model_constructor.arbitrary(self),
                    [
                        arguments_case(command_line_arguments) for
                        command_line_arguments in command_line_arguments_cases
                    ],
                )
Beispiel #28
0
    def test_transformation_in_referenced_program_and_as_source_argument(self):
        # ARRANGE #
        valid_transformer = StringTransformerSymbolContext.of_arbitrary_value(
            'VALID_TRANSFORMER', )

        referenced_program__system_program = 'the-system-program'

        for validation_case in validation_cases.failing_validation_cases(
                'INVALID_TRANSFORMER'):
            invalid_transformer_location_cases = [
                ValidationCaseWAccumulation(
                    'in referenced program',
                    of_referenced_program=validation_case.value.symbol_context,
                    accumulated=valid_transformer,
                ),
                ValidationCaseWAccumulation(
                    'in referenced program',
                    of_referenced_program=valid_transformer,
                    accumulated=validation_case.value.symbol_context,
                ),
            ]
            for invalid_transformer_location_case in invalid_transformer_location_cases:
                referenced_program__sdv = program_sdvs.system_program(
                    string_sdvs.str_constant(
                        referenced_program__system_program),
                    transformations=[
                        invalid_transformer_location_case.
                        of_referenced_program.reference_sdv
                    ])
                referenced_program = ProgramSymbolContext.of_sdv(
                    'REFERENCED_PROGRAM', referenced_program__sdv)
                program_w_transformer = FullProgramAbsStx(
                    ProgramOfSymbolReferenceAbsStx(referenced_program.name, ),
                    transformation=invalid_transformer_location_case.
                    accumulated.abstract_syntax,
                )
                symbols__all = [
                    referenced_program,
                    valid_transformer,
                    validation_case.value.symbol_context,
                ]
                symbols__expected_references = [
                    referenced_program,
                    invalid_transformer_location_case.accumulated
                ]

                with self.subTest(validation=validation_case.name,
                                  invalid_transformer_location=
                                  invalid_transformer_location_case.name):
                    # ACT & ASSERT #
                    CHECKER_WO_EXECUTION.check__abs_stx__layouts__source_variants__wo_input(
                        self,
                        equivalent_source_variants__for_expr_parse__s__nsc,
                        program_w_transformer,
                        arrangement_wo_tcds(
                            symbols=SymbolContext.symbol_table_of_contexts(
                                symbols__all), ),
                        MultiSourceExpectation.of_const(
                            symbol_references=SymbolContext.
                            references_assertion_of_contexts(
                                symbols__expected_references),
                            execution=ExecutionExpectation(
                                validation=validation_case.value.expectation,
                            ),
                            primitive=asrt.anything_goes(),
                        ))
Beispiel #29
0
    def test_transformation_in_referenced_program_and_as_source_argument(self):
        # ARRANGE #
        transformer__in_referenced_program = StringTransformerPrimitiveSymbolContext(
            'TRANSFORMER_IN_REFERENCED_PROGRAM',
            string_transformers.delete_everything())
        referenced_program__system_program = 'the-system-program'
        referenced_program__sdv = program_sdvs.system_program(
            string_sdvs.str_constant(referenced_program__system_program),
            transformations=[transformer__in_referenced_program.reference_sdv])
        referenced_program = ProgramSymbolContext.of_sdv(
            'REFERENCED_PROGRAM', referenced_program__sdv)

        transformer__in_source = StringTransformerPrimitiveSymbolContext(
            'TRANSFORMER_IN_SOURCE', string_transformers.to_uppercase())
        symbols__symbol_table = [
            referenced_program, transformer__in_referenced_program,
            transformer__in_source
        ]
        symbols__expected_references = [
            referenced_program, transformer__in_source
        ]

        arguments_cases = [
            NameAndValue(
                'no arguments',
                [],
            ),
            NameAndValue(
                'single argument',
                ['arg1'],
            )
        ]

        for arguments_case in arguments_cases:
            with self.subTest(arguments=arguments_case.name):
                program_w_transformer = FullProgramAbsStx(
                    ProgramOfSymbolReferenceAbsStx(referenced_program.name, [
                        ArgumentOfRichStringAbsStx.of_str(arg)
                        for arg in arguments_case.value
                    ]),
                    transformation=transformer__in_source.abstract_syntax)

                expected_primitive = asrt_pgm_val.matches_program(
                    asrt_command.matches_command(
                        driver=asrt_command.
                        matches_system_program_command_driver(
                            asrt.equals(referenced_program__system_program)),
                        arguments=asrt.equals(arguments_case.value),
                    ),
                    stdin=asrt_pgm_val.is_no_stdin(),
                    transformer=asrt.matches_sequence([
                        asrt.is_(transformer__in_referenced_program.primitive),
                        asrt.is_(transformer__in_source.primitive),
                    ]),
                )

                # ACT & ASSERT #
                CHECKER_WO_EXECUTION.check__abs_stx__layouts__source_variants__wo_input(
                    self, equivalent_source_variants__for_expr_parse__s__nsc,
                    program_w_transformer,
                    arrangement_wo_tcds(
                        symbols=SymbolContext.symbol_table_of_contexts(
                            symbols__symbol_table), ),
                    MultiSourceExpectation.of_const(
                        symbol_references=SymbolContext.
                        references_assertion_of_contexts(
                            symbols__expected_references),
                        primitive=expected_primitive,
                    ))
Beispiel #30
0
    def test_shell_program_via_symbol_reference(self):
        shell_command_line_of_referenced_program = 'initial shell command line'
        arguments_of_referenced_program = ['arg1', 'arg 2']
        referenced_shell_program_sdv = program_sdvs.shell_program(
            string_sdvs.str_constant(shell_command_line_of_referenced_program),
            ArgumentsSdv.new_without_validation(
                list_sdvs.from_str_constants(arguments_of_referenced_program)),
        )
        referenced_program_symbol = ProgramSymbolContext.of_sdv(
            'SHELL_PROGRAM_REFERENCE',
            referenced_shell_program_sdv,
        )

        string_argument_symbol = StringConstantSymbolContext(
            'STRING_ARGUMENT_SYMBOL',
            'string argument',
        )
        list_argument_symbol = ListConstantSymbolContext(
            'LIST_ARGUMENT_SYMBOL', ['list_arg_value_1', 'list arg value 2'])
        str_w_list_template = 'before{}after'
        str_w_list_ref = str_w_list_template.format(
            list_argument_symbol.name__sym_ref_syntax)

        expected_argument_strings = (
            arguments_of_referenced_program +
            [string_argument_symbol.str_value] +
            list_argument_symbol.constant_list + [
                str_w_list_template.format(' '.join(
                    list_argument_symbol.constant_list))
            ])

        symbols = [
            referenced_program_symbol, string_argument_symbol,
            list_argument_symbol
        ]

        syntax = ProgramOfSymbolReferenceAbsStx(
            referenced_program_symbol.name, [
                ArgumentOfSymbolReferenceAbsStx(string_argument_symbol.name),
                ArgumentOfSymbolReferenceAbsStx(list_argument_symbol.name),
                ArgumentOfRichStringAbsStx.of_str(str_w_list_ref),
            ])

        def expected_program(
                env: AssertionResolvingEnvironment) -> Assertion[Program]:
            return asrt_pgm_val.matches_program(
                command=asrt_command.equals_shell_command(
                    command_line=shell_command_line_of_referenced_program,
                    arguments=expected_argument_strings,
                ),
                stdin=asrt_pgm_val.is_no_stdin(),
                transformer=asrt_pgm_val.is_no_transformation(),
            )

        expectation = MultiSourceExpectation(
            symbol_references=asrt.matches_sequence([
                referenced_program_symbol.reference_assertion,
                string_argument_symbol.reference_assertion__w_str_rendering,
                list_argument_symbol.reference_assertion__w_str_rendering,
                list_argument_symbol.reference_assertion__w_str_rendering,
            ]),
            primitive=expected_program,
        )

        # ACT & ASSERT #
        CHECKER_WO_EXECUTION.check__abs_stx__layouts__source_variants__wo_input(
            self,
            equivalent_source_variants__for_consume_until_end_of_last_line__s__nsc,
            syntax,
            arrangement_wo_tcds(
                symbols=SymbolContext.symbol_table_of_contexts(symbols), ),
            expectation,
        )