def runTest(self):
     execution_setup_parser = _SetupParserForExecutingPythonSourceFromInstructionArgumentOnCommandLine(
     )
     self.conf.run_sub_process_test(
         self, source4(SCRIPT_THAT_EXISTS_WITH_STATUS_0),
         execution_setup_parser, self.conf.arrangement(),
         self.conf.expectation_for_zero_exitcode())
    def runTest(self):
        var_name = 'TEST_VAR_' + str(random.getrandbits(32))
        var_value = str(random.getrandbits(32))

        environ = {var_name: var_value}
        py_pgm_file = File(
            'check-env.py',
            py_programs.
            pgm_that_exists_with_zero_exit_code_iff_environment_vars_not_included(
                environ))
        source = source4(py_pgm_file.name)

        execution_setup_parser = _SetupParserForExecutingPythonSourceFileRelAct(
        )
        instruction_name = 'name-of-the-instruction'
        self.conf.run_sub_process_test(
            self,
            source,
            execution_setup_parser,
            self.conf.arrangement(
                environ=environ,
                sds_contents_before_main=sds_populator.contents_in(
                    RelSdsOptionType.REL_ACT,
                    DirContents([py_pgm_file]),
                )),
            self.conf.expect_success(),
            instruction_name=instruction_name)
    def runTest(self):
        var_name = 'TEST_VAR_' + str(random.getrandbits(32))
        var_value = str(random.getrandbits(32))
        expected_sub_process_result = SubProcessResult(exitcode=0,
                                                       stdout=var_value + '\n',
                                                       stderr='')
        environ = {var_name: var_value}
        program = lines_content(py.write_value_of_environment_variable_to_stdout(var_name))
        program_source_as_single_line = program.replace('\n', ';')
        source = source4(program_source_as_single_line)

        execution_setup_parser = _SetupParserForExecutingPythonSourceFromInstructionArgumentOnCommandLine(
            pre_or_post_validation.ConstantSuccessValidator())
        instruction_name = 'name-of-the-instruction'
        source_info = InstructionSourceInfo(source.current_line_number,
                                            instruction_name)
        self.conf.run_sub_process_test(
            self,
            source,
            execution_setup_parser,
            self.conf.arrangement(environ=environ),
            self.conf.expect_success(_InstructionLogDirContainsOutFiles(self.conf.phase(),
                                                                        source_info,
                                                                        expected_sub_process_result)),
            instruction_name=instruction_name)
예제 #4
0
파일: env.py 프로젝트: emilkarlen/exactly
 def test_a_references_to_a_non_existing_env_var_SHOULD_be_replaced_with_empty_string(self):
     parser = sut.EmbryoParser()
     instruction_embryo = parser.parse(ARBITRARY_FS_LOCATION_INFO, source4('name = ${NON_EXISTING_VAR}'))
     assert isinstance(instruction_embryo, sut.TheInstructionEmbryo)
     environ = {}
     instruction_embryo.executor.execute(environ, dummy_resolving_env())
     self.assertEqual(environ,
                      {'name': ''})
예제 #5
0
파일: env.py 프로젝트: emilkarlen/exactly
 def test_unset(self):
     parser = sut.EmbryoParser()
     instruction_embryo = parser.parse(ARBITRARY_FS_LOCATION_INFO, source4('unset a'))
     assert isinstance(instruction_embryo, sut.TheInstructionEmbryo)
     environ = {'a': 'A', 'b': 'B'}
     instruction_embryo.executor.execute(environ, dummy_resolving_env())
     self.assertEqual(environ,
                      {'b': 'B'})
예제 #6
0
파일: env.py 프로젝트: emilkarlen/exactly
 def test_set(self):
     parser = sut.EmbryoParser()
     instruction_embryo = parser.parse(ARBITRARY_FS_LOCATION_INFO, source4('name = value'))
     assert isinstance(instruction_embryo, sut.TheInstructionEmbryo)
     environ = {}
     instruction_embryo.executor.execute(environ, dummy_resolving_env())
     self.assertEqual(environ,
                      {'name': 'value'})
 def runTest(self):
     execution_setup_parser = _SetupParserForExecutingShellCommandFromInstructionArgumentOnCommandLine(
     )
     command_that_exits_with_code = shell_commands.command_that_exits_with_code(
         0)
     self.conf.run_sub_process_test(
         self, source4(command_that_exits_with_code),
         execution_setup_parser, self.conf.arrangement(),
         self.conf.expectation_for_zero_exitcode())
    def runTest(self):
        script_that_exists_with_non_zero_status = 'import sys; sys.exit(1)'

        execution_setup_parser = _SetupParserForExecutingPythonSourceFromInstructionArgumentOnCommandLine(
        )
        self.conf.run_sub_process_test(
            self, source4(script_that_exists_with_non_zero_status),
            execution_setup_parser, self.conf.arrangement(),
            self.conf.expectation_for_non_zero_exitcode())
예제 #9
0
파일: env.py 프로젝트: emilkarlen/exactly
 def test_set_value_that_references_an_env_var(self):
     parser = sut.EmbryoParser()
     environ = {'MY_VAR': 'MY_VAL'}
     instruction_embryo = parser.parse(ARBITRARY_FS_LOCATION_INFO, source4('name = ${MY_VAR}'))
     assert isinstance(instruction_embryo, sut.TheInstructionEmbryo)
     instruction_embryo.executor.execute(environ, dummy_resolving_env())
     self.assertEqual(environ,
                      {'name': 'MY_VAL',
                       'MY_VAR': 'MY_VAL'})
 def runTest(self):
     execution_setup_parser = _SetupParserForExecutingPythonSourceFromInstructionArgumentOnCommandLine(
         pre_or_post_validation.ConstantSuccessValidator())
     self.conf.run_sub_process_test(
         self,
         source4(SCRIPT_THAT_EXISTS_WITH_STATUS_0),
         execution_setup_parser,
         self.conf.arrangement(),
         self.conf.expectation_for_zero_exitcode())
 def runTest(self):
     execution_setup_parser = _SetupParserForExecutingPythonSourceFromInstructionArgumentOnCommandLine(
         ConstantResultValidator(post_setup='validation error message post setup')
     )
     self.conf.run_sub_process_test(
         self,
         source4(SCRIPT_THAT_EXISTS_WITH_STATUS_0),
         execution_setup_parser,
         self.conf.arrangement(),
         self.conf.expect_failing_validation_post_setup(asrt.Equals('validation error message post setup')))
 def runTest(self):
     execution_setup_parser = _SetupParserForExecutingShellCommandFromInstructionArgumentOnCommandLine(
         pre_or_post_validation.ConstantSuccessValidator())
     command_that_exits_with_code = shell_commands.command_that_exits_with_code(0)
     self.conf.run_sub_process_test(
         self,
         source4(command_that_exits_with_code),
         execution_setup_parser,
         self.conf.arrangement(),
         self.conf.expectation_for_zero_exitcode())
    def runTest(self):
        script_that_exists_with_non_zero_status = 'import sys; sys.exit(1)'

        execution_setup_parser = _SetupParserForExecutingPythonSourceFromInstructionArgumentOnCommandLine(
            pre_or_post_validation.ConstantSuccessValidator())
        self.conf.run_sub_process_test(
            self,
            source4(script_that_exists_with_non_zero_status),
            execution_setup_parser,
            self.conf.arrangement(),
            self.conf.expectation_for_non_zero_exitcode())
예제 #14
0
파일: env.py 프로젝트: emilkarlen/exactly
 def test_set_value_that_contains_text_and_references_to_env_vars(self):
     parser = sut.EmbryoParser()
     environ = {'MY_VAR': 'MY_VAL',
                'YOUR_VAR': 'YOUR_VAL'}
     instruction_embryo = parser.parse(ARBITRARY_FS_LOCATION_INFO,
                                       source4('name = "pre ${MY_VAR} ${YOUR_VAR} post"'))
     assert isinstance(instruction_embryo, sut.TheInstructionEmbryo)
     instruction_embryo.executor.execute(environ, dummy_resolving_env())
     self.assertEqual(environ,
                      {'name': 'pre MY_VAL YOUR_VAL post',
                       'MY_VAR': 'MY_VAL',
                       'YOUR_VAR': 'YOUR_VAL'})
    def runTest(self):
        timeout_in_seconds = 1
        script_that_sleeps = lines_content(py.program_that_sleeps_at_least_and_then_exists_with_zero_exit_status(4))
        program_source_as_single_line = script_that_sleeps.replace('\n', ';')
        source = source4(program_source_as_single_line)

        execution_setup_parser = _SetupParserForExecutingPythonSourceFromInstructionArgumentOnCommandLine(
            pre_or_post_validation.ConstantSuccessValidator())
        self.conf.run_sub_process_test(
            self,
            source,
            execution_setup_parser,
            self.conf.arrangement_with_timeout(timeout_in_seconds),
            self.conf.expect_hard_error_in_main())
 def runTest(self):
     sub_process_result = SubProcessResult(exitcode=72,
                                           stdout='output on stdout',
                                           stderr='output on stderr')
     program = py.program_that_prints_and_exits_with_exit_code(sub_process_result)
     program_source_as_single_line = program.replace('\n', ';')
     program_parser = _SetupParserForExecutingPythonSourceFromInstructionArgumentOnCommandLine(
         pre_or_post_validation.ConstantSuccessValidator())
     source = source4(program_source_as_single_line)
     self.conf.run_sub_process_test(
         self,
         source,
         program_parser,
         self.conf.arrangement(),
         self.conf.expect_failure_of_main(va_str.contains('output on stderr')))
 def runTest(self):
     sub_process_result = SubProcessResult(exitcode=72,
                                           stdout='output on stdout',
                                           stderr='output on stderr')
     program = py.program_that_prints_and_exits_with_exit_code(
         sub_process_result)
     program_source_as_single_line = program.replace('\n', ';')
     program_parser = _SetupParserForExecutingPythonSourceFromInstructionArgumentOnCommandLine(
     )
     source = source4(program_source_as_single_line)
     self.conf.run_sub_process_test(
         self, source, program_parser, self.conf.arrangement(),
         self.conf.expect_failure_of_main(
             asrt_text_doc.rendered_text_matches(
                 asrt_str.contains('output on stderr'))))
    def runTest(self):
        timeout_in_seconds = 1
        script_that_sleeps = lines_content(
            py.
            program_that_sleeps_at_least_and_then_exists_with_zero_exit_status(
                4))
        program_source_as_single_line = script_that_sleeps.replace('\n', ';')
        source = source4(program_source_as_single_line)

        execution_setup_parser = _SetupParserForExecutingPythonSourceFromInstructionArgumentOnCommandLine(
        )
        self.conf.run_sub_process_test(
            self, source, execution_setup_parser,
            self.conf.arrangement_with_timeout(timeout_in_seconds),
            self.conf.expect_hard_error_in_main())
예제 #19
0
파일: stdin.py 프로젝트: emilkarlen/exactly
 def test_invalid_syntax(self):
     test_cases = [
         source4(''),
         assignment_of('string superfluous-argument'),
         assignment_of('{file_option} {rel_home} file superfluous-argument'.format(
             file_option=option_syntax(parse_here_doc_or_file_ref.FILE_ARGUMENT_OPTION),
             rel_home=file_ref_syntax.REL_HOME_CASE_OPTION,
         )),
         assignment_of('<<MARKER superfluous argument',
                       ['single line',
                        'MARKER']),
         assignment_of('<<MARKER ',
                       ['single line',
                        'NOT_MARKER']),
     ]
     parser = sut.Parser()
     for source in test_cases:
         with self.subTest(msg='first line of source=' + source.remaining_part_of_current_line):
             with self.assertRaises(SingleInstructionInvalidArgumentException):
                 parser.parse(ARBITRARY_FS_LOCATION_INFO, source)
 def runTest(self):
     sub_process_result = SubProcessResult(exitcode=0,
                                           stdout='output on stdout',
                                           stderr='output on stderr')
     program = py.program_that_prints_and_exits_with_exit_code(sub_process_result)
     program_source_as_single_line = program.replace('\n', ';')
     source = source4(program_source_as_single_line)
     execution_setup_parser = _SetupParserForExecutingPythonSourceFromInstructionArgumentOnCommandLine(
         pre_or_post_validation.ConstantSuccessValidator())
     instruction_name = 'name-of-the-instruction'
     source_info = InstructionSourceInfo(source.current_line_number,
                                         instruction_name)
     self.conf.run_sub_process_test(
         self,
         source,
         execution_setup_parser,
         self.conf.arrangement(),
         self.conf.expect_success(_InstructionLogDirContainsOutFiles(self.conf.phase(),
                                                                     source_info,
                                                                     sub_process_result)),
         instruction_name=instruction_name)
예제 #21
0
파일: env.py 프로젝트: emilkarlen/exactly
 def test_succeed_when_there_is_exactly_one_argument(self):
     source = source4('unset name')
     self.parser.parse(ARBITRARY_FS_LOCATION_INFO, source)
예제 #22
0
파일: env.py 프로젝트: emilkarlen/exactly
 def test_fail_when_there_is_more_than_one_argument(self):
     source = source4('unset name superfluous')
     with self.assertRaises(SingleInstructionInvalidArgumentException):
         self.parser.parse(ARBITRARY_FS_LOCATION_INFO, source)
예제 #23
0
파일: env.py 프로젝트: emilkarlen/exactly
 def test_fail_when_there_is_no_arguments(self):
     source = source4('unset')
     with self.assertRaises(SingleInstructionInvalidArgumentException):
         self.parser.parse(ARBITRARY_FS_LOCATION_INFO, source)
예제 #24
0
파일: env.py 프로젝트: emilkarlen/exactly
 def test_raise_invalid_argument_if_invalid_quoting(self):
     source = source4("unset 'invalid_name")
     with self.assertRaises(SingleInstructionInvalidArgumentException):
         self.parser.parse(ARBITRARY_FS_LOCATION_INFO, source)
예제 #25
0
파일: env.py 프로젝트: emilkarlen/exactly
 def test_variable_name_must_not_be_quoted(self):
     source = source4("'long name' = 'long value'")
     with self.assertRaises(SingleInstructionInvalidArgumentException):
         self.parser.parse(ARBITRARY_FS_LOCATION_INFO, source)
예제 #26
0
파일: env.py 프로젝트: emilkarlen/exactly
 def test_succeed_when_there_is_exactly_one_assignment(self):
     source = source4('name = value')
     self.parser.parse(ARBITRARY_FS_LOCATION_INFO, source)
예제 #27
0
파일: env.py 프로젝트: emilkarlen/exactly
 def test_fail_when_there_is_more_than_three_argument(self):
     source = source4('argument1 = argument3 argument4')
     with self.assertRaises(SingleInstructionInvalidArgumentException):
         self.parser.parse(ARBITRARY_FS_LOCATION_INFO, source)
예제 #28
0
 def _source(self, argument_template: str) -> ParseSource:
     return source4(argument_template.format(relativity_option=self.relativity_option.option_argument))
예제 #29
0
파일: env.py 프로젝트: emilkarlen/exactly
 def test_unset_identifier_must_not_be_quoted(self):
     with self.assertRaises(SingleInstructionInvalidArgumentException):
         source = source4("'unset' 'long name'")
         self.parser.parse(ARBITRARY_FS_LOCATION_INFO, source)
예제 #30
0
 def test_fail_when_the_quoting_is_invalid(self):
     source = source4('argument-1 "argument-2')
     with self.assertRaises(SingleInstructionInvalidArgumentException):
         sut.Parser().parse(ARBITRARY_FS_LOCATION_INFO, source)
예제 #31
0
 def test_fail_when_extra_unexpected_argument(self):
     source = source4(actor_utils.COMMAND_LINE_ACTOR_NAME +
                      ' extra-unexpected-argument')
     with self.assertRaises(SingleInstructionInvalidArgumentException):
         sut.Parser().parse(ARBITRARY_FS_LOCATION_INFO, source)
예제 #32
0
def single_line_source() -> ParseSource:
    return source4('instruction arguments')
예제 #33
0
 def test_fail_when_missing_arg_to_eq_token(self):
     source = source4(' =  ')
     with self.assertRaises(SingleInstructionInvalidArgumentException):
         sut.Parser().parse(ARBITRARY_FS_LOCATION_INFO, source)
예제 #34
0
 def test_fail_when_missing_program_argument(self):
     source = source4(actor_utils.SOURCE_INTERPRETER_NAME)
     with self.assertRaises(SingleInstructionInvalidArgumentException):
         sut.Parser().parse(ARBITRARY_FS_LOCATION_INFO, source)
예제 #35
0
 def test_fail_when_there_is_no_arguments(self):
     source = source4('   ')
     with self.assertRaises(SingleInstructionInvalidArgumentException):
         sut.Parser().parse(ARBITRARY_FS_LOCATION_INFO, source)
예제 #36
0
def single_line_source() -> ParseSource:
    return source4('instruction arguments')