コード例 #1
0
 def runTest(self):
     exe_file = fs.python_executable_file('program-name',
                                          py_programs.exit_with(0))
     cases = [
         NameAndValue(
             'pre sds',
             (
                 RelOptionType.REL_HDS_CASE,
                 self.conf.expect_failing_validation_pre_sds(),
             ),
         ),
         NameAndValue(
             'post sds',
             (
                 RelOptionType.REL_ACT,
                 self.conf.expect_hard_error_of_main__any(),
             ),
         ),
     ]
     for case in cases:
         with self.subTest(case.name):
             arguments = sys_cmd.command_line(
                 exe_file.name,
                 program_arguments.existing_file(
                     path_arguments.RelOptPathArgument(
                         'non-existing', case.value[0])),
             )
             with tmp_dir_in_path_with_files(fs.DirContents([exe_file
                                                             ])) as env:
                 self.conf.run_single_line_test_with_source_variants_and_source_check(
                     self,
                     arguments.as_str,
                     self.conf.arrangement(environ=env),
                     case.value[1],
                 )
コード例 #2
0
ファイル: system_program.py プロジェクト: emilkarlen/exactly
    def runTest(self):
        # ARRANGE #
        exit_code_from_program = 0
        exe_file_in_path = fs.python_executable_file(
            'the-program',
            lines_content(py_program.exit_with_code(exit_code_from_program)),
        )
        program_symbol = StringConstantSymbolContext(
            'PROGRAM_NAME_SYMBOL',
            exe_file_in_path.name,
        )
        program_line = args.system_program_command_line(
            program_symbol.name__sym_ref_syntax).as_str

        with tmp_dir_in_path_with_files(DirContents([exe_file_in_path
                                                     ])) as environ:
            for source_case in valid_source_variants(program_line):
                with self.subTest(source_case.name):
                    # ACT & ASSERT #
                    integration_check.check_execution(
                        self,
                        sut.actor(),
                        [instr([program_line])],
                        arrangement_w_tcds(
                            symbol_table=program_symbol.symbol_table,
                            act_exe_input=AtcExeInputArr(environ=environ),
                        ),
                        Expectation(
                            symbol_usages=asrt.matches_singleton_sequence(
                                program_symbol.
                                reference_assertion__string__w_all_indirect_refs_are_strings
                            ),
                            execute=asrt_eh.is_exit_code(
                                exit_code_from_program)),
                    )
コード例 #3
0
 def runTest(self):
     exe_file = fs.python_executable_file('program-name',
                                          py_programs.exit_with(0))
     with tmp_dir_in_path_with_files(fs.DirContents([exe_file])) as env:
         instruction_argument = exe_file.name
         self.conf.run_single_line_test_with_source_variants_and_source_check(
             self,
             instruction_argument,
             self.conf.arrangement(environ=env),
             self.conf.expectation_for_zero_exitcode(),
         )
コード例 #4
0
ファイル: system_program.py プロジェクト: emilkarlen/exactly
    def _instructions_for_executing_py_source(
            self, py_src: List[str]) -> ContextManager[TestCaseSourceSetup]:
        exe_file_in_path = fs.python_executable_file('the-program',
                                                     lines_content(py_src))
        with tmp_dir_in_path_with_files(DirContents([exe_file_in_path
                                                     ])) as environ:
            program_line = args.system_program_command_line(
                exe_file_in_path.name).as_str

            yield TestCaseSourceSetup(
                act_phase_instructions=[instr([program_line])],
                environ=environ)
コード例 #5
0
 def runTest(self):
     non_zero_exit_code = 1
     exe_file = fs.python_executable_file(
         'program-name',
         py_programs.copy_stdin_to_stderr_and_exit_with(non_zero_exit_code)
     )
     with tmp_dir_in_path_with_files(fs.DirContents([exe_file])) as env:
         # ACT & ASSERT #
         CHECKER.check(
             self,
             command_line(
                 exe_file.name,
             ).as_remaining_source,
             Arrangement.phase_agnostic(
                 process_execution_settings=proc_exe_env_for_test(environ=env),
                 tcds=TcdsArrangement(),
             ),
             Expectation.phase_agnostic_2(
                 source=asrt_source.source_is_at_end,
                 main_result=result_assertions.equals(non_zero_exit_code, ''),
             ),
         )
コード例 #6
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)),
                    )