def __init__(self, conf: Configuration, test_case: TestCase, ): self.conf = conf self.exe_conf = conf.exe_conf self.conf_values = conf.conf_phase_values self._test_case = test_case self._setup_settings_handler = conf.mk_setup_settings_handler( functional.map_optional(dict, conf.exe_conf.environ) ) self._source_setup = None self._os_services = conf.exe_conf.os_services self._act_phase_executor = _initial_atc_executor() self._action_to_check = None self._instruction_environment_pre_sds = None self.__sandbox_directory_structure = None self._action_to_check_outcome = None self._phase_tmp_space_factory = None self._act_helper = ActHelper(conf.conf_phase_values.actor.name, test_case.act_phase) self._instruction_settings = InstructionSettings( functional.map_optional(dict, conf.exe_conf.environ), conf.exe_conf.default_environ_getter, conf.exe_conf.timeout_in_seconds, )
def adapt_to_line_num_range( interval: IntIntervalWInversion) -> IntIntervalWInversion: """ :return: All non-None values >= FIRST_LINE_NUMBER. lower > FIRST_LINE_NUMBER (if not None) """ if interval.is_empty: return interval if interval.upper is not None and interval.upper < FIRST_LINE_NUMBER: return intervals.Empty() lower = map_optional(_adapt_limit, interval.lower) if lower == FIRST_LINE_NUMBER: lower = None upper = map_optional(_adapt_limit, interval.upper) if lower is None: if upper is None: return intervals.Unlimited() else: return intervals.UpperLimit(upper) else: if upper is None: return intervals.LowerLimit(lower) else: if lower > upper: return intervals.Empty() else: return intervals.Finite(lower, upper)
def make_ddv( symbols: SymbolTable ) -> FullDepsWithDetailsDescriptionDdv[ ModelConstructor[FilesMatcherModel]]: def get_int_ddv(x: IntegerSdv) -> IntegerDdv: return x.resolve(symbols) return _RecursiveModelConstructorDdv( map_optional(get_int_ddv, min_depth), map_optional(get_int_ddv, max_depth), )
def value_of_any_dependency( self, tcds: TestCaseDs ) -> ApplicationEnvironmentDependentValue[ ModelConstructor[FilesMatcherModel]]: def get_int_value(x: IntegerDdv) -> int: return x.value_of_any_dependency(tcds) return advs.ConstantAdv( _RecursiveModelConstructor( map_optional(get_int_value, self._min_depth), map_optional(get_int_value, self._max_depth)))
def _exe_conf_that_may_be_updated(self) -> ExecutionConfiguration: ec = self._exe_conf return ExecutionConfiguration( ec.default_environ_getter, functional.map_optional(dict, ec.environ), ec.timeout_in_seconds, ec.os_services, ec.sds_root_dir_resolver, ec.mem_buff_size, ec.predefined_symbols.copy(), ec.exe_atc_and_skip_assertions)
def __new__( cls, step_info: StepInfo, environ: Optional[Dict[str, str]], timeout: Optional[int] = None, ): environ_to_record = functional.map_optional(dict, environ) return tuple.__new__(cls, (step_info, environ_to_record, timeout))
def value_of_any_dependency(self, tcds: TestCaseDs) -> FilesConditionAdv: def val_of_any_dep(matcher: FileMatcherDdv) -> FileMatcherAdv: return matcher.value_of_any_dependency(tcds) return _Adv({ path: map_optional(val_of_any_dep, mb_matcher) for path, mb_matcher in self._files.items() })
def primitive(self, environment: ApplicationEnvironment) -> FilesCondition: def resolve_matcher(adv: FileMatcherAdv) -> FileMatcher: return adv.primitive(environment) return _Primitive({ path: map_optional(resolve_matcher, mb_matcher) for path, mb_matcher in self._files.items() })
def _limits(self) -> DetailsRenderer: limits = filter_not_none([ map_optional( lambda d: self._mk_detail( file_or_dir_contents.MIN_DEPTH_OPTION, d), self._min_depth), map_optional( lambda d: self._mk_detail( file_or_dir_contents.MAX_DEPTH_OPTION, d), self._max_depth), ]) num_limits = len(limits) if num_limits == 0: return details.empty() elif num_limits == 1: return details.IndentedRenderer(limits[0]) else: return details.IndentedRenderer(details.SequenceRenderer(limits))
def environ_copy_or_none( environ: Optional[Mapping[str, str]]) -> Optional[Dict[str, str]]: return functional.map_optional(dict, environ)
def as_settings_builder(self) -> SetupSettingsBuilder: return SetupSettingsBuilder( stdin=None, environ=functional.map_optional(dict, self.environ) )
def mb_dict_of(x: Optional[Mapping[str, str]]) -> Optional[Dict[str, str]]: return functional.map_optional(dict, x)
def resolve_entry( file_name: StringSdv, matcher: Optional[FileMatcherSdv] ) -> Tuple[StringDdv, Optional[FileMatcherDdv]]: return file_name.resolve(symbols), map_optional( resolve_matcher, matcher)
def describer(self) -> DetailsRenderer: return _RecursiveStructureRenderer( map_optional(details.String, self._min_depth), map_optional(details.String, self._max_depth), )
def _setup_settings_from_arrangement( self) -> Optional[SetupSettingsBuilder]: return functional.map_optional(SetupSettingsArr.as_settings_builder, self.arrangement.setup_settings)
def _initial_environment_variables_dict( arrangement: Arrangement) -> Dict[str, str]: return functional.map_optional( dict, arrangement.process_execution_settings.environ)
def describer(self) -> DetailsRenderer: return _RecursiveStructureRenderer( map_optional(IntegerDdv.describer, self._min_depth), map_optional(IntegerDdv.describer, self._max_depth))