def remaining_part_of_current_line_as_literal( remaining_part_of_current_line: WithToString, ) -> ArgumentElementsRenderer: return ab.sequence([ syntax_elements.REMAINING_PART_OF_CURRENT_LINE_AS_LITERAL_MARKER, remaining_part_of_current_line, ])
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 interpret_py_source_line( python_source: WithToString) -> ArgumentElementsRenderer: return ab.sequence([ ab.option(syntax_elements.PYTHON_EXECUTABLE_OPTION_NAME), python_program_execution.PY_ARG_FOR_EXECUTING_SOURCE_ON_COMMAND_LINE, syntax_elements.REMAINING_PART_OF_CURRENT_LINE_AS_LITERAL_MARKER, python_source ])
def test_check_non_zero_exit_code(self): self._check_single_line_arguments_with_source_variants( args.sequence([pgm_args.interpret_py_source_file('exit-with-value-on-command-line.py'), 2]).as_str, tcds_test.Arrangement( hds_contents_before=hds_case_dir_contents(DirContents([ File('exit-with-value-on-command-line.py', py_pgm_that_exits_with_1st_value_on_command_line('on stderr'))]))), tcds_test.Expectation( expected_action_result=result_assertions.equals(2, 'on stderr'), ) )
def test_check_zero_exit_code__rel_tmp(self): self._check_single_line_arguments_with_source_variants( args.sequence([ pgm_args.interpret_py_source_file( path_arguments.RelOptPathArgument('exit-with-value-on-command-line.py', RelOptionType.REL_TMP)), 0, ]).as_str, tcds_test.Arrangement( sds_contents_before=contents_in(RelSdsOptionType.REL_TMP, DirContents([ File('exit-with-value-on-command-line.py', py_pgm_that_exits_with_1st_value_on_command_line(''))]))), tcds_test.Expectation( expected_action_result=result_assertions.equals(0, None)), )
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 interpret_py_source_file( py_file: WithToString) -> ArgumentElementsRenderer: return ab.sequence([ ab.option(syntax_elements.PYTHON_EXECUTABLE_OPTION_NAME), ab.option(syntax_elements.EXISTING_FILE_OPTION_NAME), py_file ])
def system_program_command_line( command_line: WithToString) -> ArgumentElementsRenderer: return ab.sequence([syntax_elements.SYSTEM_PROGRAM_TOKEN, command_line])
def shell_command_line(command_line: WithToString) -> ArgumentElementsRenderer: return ab.sequence([syntax_elements.SHELL_COMMAND_TOKEN, command_line])
def symbol_ref_command_line( command_line: WithToString) -> ArgumentElementsRenderer: return ab.sequence( [syntax_elements.SYMBOL_REF_PROGRAM_TOKEN, command_line])