Пример #1
0
    def test_two_populators_populate_hds(self):
        # ARRANGE #
        expected_dir_contents = fs.DirContents([self.first_file,
                                                self.second_file])
        first_populator = sut.hds_case_dir_contents(fs.DirContents([self.first_file]))
        second_populator = sut.hds_case_dir_contents(fs.DirContents([self.second_file]))
        populator = sut.multiple([first_populator,
                                  second_populator])
        expectation = f_asrt.dir_contains_exactly(expected_dir_contents)

        with home_directory_structure() as hds:
            # ACT #
            populator.populate_hds(hds)
            # ASSERT #
            expectation.apply_with_message(self, hds.case_dir,
                                           'contents of HDS/case dir')
Пример #2
0
 def test_file__rel_hds(self):
     accepted_relativity_configurations = [
         rel_opt_conf.conf_rel_any(RelOptionType.REL_HDS_CASE),
         rel_opt_conf.default_conf_rel_any(RelOptionType.REL_HDS_CASE),
         rel_opt_conf.symbol_conf_rel_any(
             RelOptionType.REL_HDS_CASE, 'SYMBOL',
             RELATIVITY_OPTIONS_CONFIGURATION.options.
             accepted_relativity_variants),
     ]
     stdin_file = File('stdin.txt', 'contents of stdin / rel hds')
     for rel_conf in accepted_relativity_configurations:
         syntax = InstructionAbsStx(
             StringSourceOfFileAbsStx(
                 rel_conf.path_abs_stx_of_name(stdin_file.name)))
         with self.subTest(option_string=rel_conf.option_argument.as_str):
             CHECKER.check_multi_source__abs_stx(
                 self, syntax,
                 Arrangement(
                     hds_contents=hds_case_dir_contents(
                         DirContents([stdin_file])),
                     symbols=rel_conf.symbols.in_arrangement(),
                 ),
                 MultiSourceExpectation(
                     symbols_after_parse=rel_conf.symbols.
                     usages_expectation(),
                     settings_builder=_stdin_is_present_and_valid(
                         stdin_file.contents,
                         may_depend_on_external_resources=True),
                 ))
Пример #3
0
    def test_validate_should_fail_when_executable_does_not_exist(self):
        existing_file_to_interpret = 'existing-file-to-interpret.src'
        home_dir_contents = fs.DirContents(
            [File.empty(existing_file_to_interpret)])
        for relativity_option_conf in RELATIVITY_OPTIONS:
            argument = '{relativity_option} non-existing-file {interpret_option}' \
                       ' {rel_hds_case_option} {existing_file}'.format(
                relativity_option=relativity_option_conf.option_argument,
                interpret_option=syntax_elements.EXISTING_FILE_OPTION_NAME,
                rel_hds_case_option=REL_HDS_CASE_OPTION,
                existing_file=existing_file_to_interpret,
            )

            expectation = _expect_validation_error_and_symbol_usages_of(
                relativity_option_conf)

            arrangement = Arrangement.phase_agnostic(
                symbols=relativity_option_conf.symbols.in_arrangement(),
                tcds=TcdsArrangement(
                    hds_contents=hds_case_dir_contents(home_dir_contents), ),
            )
            with self.subTest(msg='option=' +
                              relativity_option_conf.test_case_description):
                EXECUTION_CHECKER.check__w_source_variants(
                    self, argument, arrangement, expectation)
 def _do_parse_and_validate_pre_sds(
     self,
     instructions: Sequence[ActPhaseInstruction],
     home_dir_contents: DirContents = empty_dir_contents()):
     with home_directory_structure(
             contents=hds_case_dir_contents(home_dir_contents)) as hds:
         pre_sds_env = InstructionEnvironmentPreSdsBuilder.of_empty_env(
             hds=hds).build
         executor = self.actor.parse(instructions)
         return executor.validate_pre_sds(pre_sds_env)
Пример #5
0
 def test_arrangement_and_expectation_of_hds_dir_contents(self):
     home_dir_contents = DirContents([File.empty('file-name.txt')])
     self._check_source_and_exe_variants(
         PARSER_THAT_GIVES_SUCCESSFUL_INSTRUCTION,
         Arrangement.phase_agnostic(
             tcds=TcdsArrangement(
                 hds_contents=hds_case_dir_contents(home_dir_contents)),
         ),
         MultiSourceExpectation.phase_agnostic(
             side_effects_on_hds=f_asrt.dir_contains_exactly(home_dir_contents)),
     )
Пример #6
0
    def test_that_populator_is_applied(self):
        # ARRANGE #
        expected_dir_contents = fs.DirContents([fs.File('file-name.txt', 'file contents')])
        populator = hds_populators.hds_case_dir_contents(expected_dir_contents)
        expectation = f_asrt.dir_contains_exactly(expected_dir_contents)

        # ACT #
        with home_directory_structure(contents=populator) as hds:
            # ASSERT #
            expectation.apply_with_message(self, hds.case_dir,
                                           'contents of home/case dir')
Пример #7
0
    def test_populate_hds(self):
        # ARRANGE #
        expected_dir_contents = fs.DirContents([fs.File('file-name.txt', 'file contents')])
        populator = sut.hds_case_dir_contents(expected_dir_contents)
        expectation = f_asrt.dir_contains_exactly(expected_dir_contents)

        with home_directory_structure() as hds:
            # ACT #
            populator.populate_hds(hds)
            # ASSERT #
            expectation.apply_with_message(self, hds.case_dir,
                                           'contents of HDS/case dir')
Пример #8
0
    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'),

            )
        )
Пример #9
0
    def test_invalid_executable(self):
        argument = '/not/an/executable/program {} {} {}'.format(args.option(syntax_elements.EXISTING_FILE_OPTION_NAME),
                                                                'exit-with-value-on-command-line.py',
                                                                0)
        self._check_single_line_arguments_with_source_variants(
            argument,
            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(''))]))),
            tcds_test.Expectation(
                acton_raises_hard_error=True,

            ))