def list_tests(): test_dir = Paths.join(Paths.flow123d_root(), 'tests') tests = Paths.walk(test_dir, [ PathFilters.filter_type_is_file(), PathFilters.filter_endswith('.yaml'), PathFilters.filter_not(PathFilters.filter_name('config.yaml')), ]) result = dict() for r in tests: dirname = Paths.dirname(r) basename = Paths.basename(r) if Paths.dirname(dirname) != test_dir: continue if dirname not in result: result[dirname] = list() result[dirname].append(basename) keys = sorted(result.keys()) for dirname in keys: Printer.all.out(Paths.relpath(dirname, test_dir)) with Printer.all.with_level(1): for basename in result[dirname]: Printer.all.out('{: >4s} {: <40s} {}', '', basename, Paths.relpath(Paths.join(dirname, basename), test_dir)) Printer.all.newline()
def list_tests(): test_dir = Paths.join(Paths.flow123d_root(), 'tests') tests = Paths.walk(test_dir, [ PathFilters.filter_type_is_file(), PathFilters.filter_endswith('.yaml'), PathFilters.filter_not(PathFilters.filter_name('config.yaml')), ]) result = dict() for r in tests: dirname = Paths.dirname(r) basename = Paths.basename(r) if Paths.dirname(dirname) != test_dir: continue if dirname not in result: result[dirname] = list() result[dirname].append(basename) keys = sorted(result.keys()) for dirname in keys: printf.warning(Paths.relpath(dirname, test_dir)) with printf: paths = list() wrap = 2 for basename in result[dirname]: paths.append(basename) for i in range(0, len(paths), wrap): printf.out(' '.join( ['{:<40s}'.format(x) for x in paths[i:i + wrap]])) printf.sep()
def list_tests(): test_dir = Paths.join(Paths.flow123d_root(), 'tests') tests = Paths.walk(test_dir, [ PathFilters.filter_type_is_file(), PathFilters.filter_endswith('.yaml'), PathFilters.filter_not(PathFilters.filter_name('config.yaml')), ]) result = dict() for r in tests: dirname = Paths.dirname(r) basename = Paths.basename(r) if Paths.dirname(dirname) != test_dir: continue if dirname not in result: result[dirname] = list() result[dirname].append(basename) keys = sorted(result.keys()) for dirname in keys: Printer.all.out(Paths.relpath(dirname, test_dir)) with Printer.all.with_level(1): for basename in result[dirname]: Printer.all.out('{: >4s} {: <40s} {}', '', basename, Paths.relpath(Paths.join(dirname, basename), test_dir)) Printer.all.newline()
def parse(self): for k, v in self.configs.items(): self.configs[k] = ConfigBase(k) for k, v in self.files.items(): config = Paths.join(Paths.dirname(k), yamlc.CONFIG_YAML) self.files[k] = self.configs[config]
def parse(self, missing_policy=ConfigBase.MISSING_POLICY_CREATE_DEFAULT): for k, v in list(self.configs.items()): self.configs[k] = ConfigBase(k, missing_policy) for k, v in list(self.files.items()): config = Paths.join(Paths.dirname(k), yamlc.CONFIG_YAML) self.files[k] = self.configs[config]
def __init__(self, yaml_config_file): self.yaml_config_file = yaml_config_file self.root = Paths.dirname(self.yaml_config_file) self.yamls = self._get_all_yamls() self.cases = list() self.common_config = None # create dummy case for every yaml file in folder if not Paths.exists(self.yaml_config_file): self.common_config = deepcopy(DEFAULTS) for y in self.yamls: dummy_case = deepcopy(DEFAULTS) dummy_case['file'] = [y] self.cases.append(dummy_case) else: # setup common config values self.yaml_config = self._read_yaml() self.common_config = self.merge(DEFAULTS, self.yaml_config.get('common_config', {})) # first process files which are specified in test_cases missing = [Paths.basename(y) for y in self.yamls] for case in self.yaml_config.get('test_cases', []): case_config = self.merge(self.common_config, case) self.cases.append(case_config) for f in case_config['file']: if f in missing: missing.remove(f) # process rest (dummy case) for y in missing: dummy_case = deepcopy(self.common_config) dummy_case['file'] = [y] self.cases.append(dummy_case)
def parse(self): for k, v in self.configs.items(): self.configs[k] = ConfigBase(k) for k, v in self.files.items(): config = Paths.join(Paths.dirname(k), yamlc.CONFIG_YAML) self.files[k] = self.configs[config]
def create_comparisons(self): comparisons = ComparisonMultiThread(self.case.fs.ndiff_log) comparisons.thread_name_property = True for check_rule in self.case.check_rules: method = str(check_rule.keys()[0]) module = getattr(file_comparison, 'Compare{}'.format(method.capitalize()), None) comp_data = check_rule[method] if not module: Printer.all.err('Warning! No module for check_rule method "{}"', method) continue pairs = self._get_ref_output_files(comp_data) if pairs: for pair in pairs: command = module.get_command(*pair, **comp_data) pm = PyPy(BinExecutor(command), progress=True) # if we fail, set error to 13 pm.custom_error = 13 pm.start_monitor.deactivate() pm.end_monitor.deactivate() pm.progress_monitor.deactivate() pm.limit_monitor.deactivate() # TODO: maybe some time limit would be useful pm.output_monitor.policy = pm.output_monitor.POLICY_ERROR_ONLY pm.error_monitor.message = 'Comparison using method {} failed!'.format(method) pm.error_monitor.indent = 1 # catch output pm.executor.output = OutputMode.variable_output() pm.full_output = self.case.fs.ndiff_log path = Paths.path_end_until(pair[0], REF_OUTPUT_DIR) test_name = Paths.basename(Paths.dirname(Paths.dirname(self.case.fs.ref_output))) size = Paths.filesize(pair[0], True) pm.name = '{}: {} ({})'.format(test_name, path, size) comparisons.add(pm) return comparisons
def __iter__(self): fileset = formic.FileSet(self.includes, directory=self.source) for filename in fileset: name = Paths.basename(filename) if not self.name else self.name.format( path=self.create_path_dict(filename), name=Paths.basename(filename), ) if self.flat: root = self.target else: rel_path = Paths.relpath(Paths.dirname(filename), Paths.abspath(self.source)) root = Paths.abspath(Paths.join(self.target, rel_path)) yield CopyRule(filename, Paths.join(root, name), self.remove_original)
def generate_status_file(cls, target): """ Will generate status file if target has option turned on :type target: PyPy """ if target.status_file: IO.write(target.status_file, json.dumps(target.status(), indent=4)) output_dir = Paths.dirname(target.status_file) files = Paths.browse( output_dir, [PathFilters.filter_wildcards('*/profiler_info_*.log.json')]) # profiler json is missing? if not files: IO.write( Paths.join(output_dir, 'profiler_info_dummy.log.json'), '{}')
def __init__(self, yaml_config_file, missing_policy=MISSING_POLICY_CREATE_DEFAULT): self.yaml_config_file = yaml_config_file self.root = Paths.dirname(self.yaml_config_file) self.yamls = self._get_all_yamls() self.cases = list() self.common_config = None self.missing_policy = missing_policy # create dummy case for every yaml file in folder if not Paths.exists(self.yaml_config_file): self.common_config = deepcopy(yamlc.DEFAULTS) for y in self.yamls: dummy_case = deepcopy(yamlc.DEFAULTS) dummy_case['files'] = [y] self.cases.append(dummy_case) else: # setup common config values self.yaml_config = self._read_yaml() self.common_config = self.merge( yamlc.DEFAULTS, self.yaml_config.get('common_config', {})) # first process files which are specified in test_cases missing = [Paths.basename(y) for y in self.yamls] for case in self.yaml_config.get(yamlc.TAG_TEST_CASES, []): case_config = self.merge(self.common_config, case) # ensure that value are array case_config[yamlc.TAG_FILES] = ensure_iterable( case_config.get(yamlc.TAG_FILES, [])) # keep correct order self.cases.append(case_config) for f in case_config[yamlc.TAG_FILES]: if f in missing: missing.remove(f) # process rest (dummy case) if missing_policy == self.MISSING_POLICY_CREATE_DEFAULT: for y in missing: dummy_case = deepcopy(self.common_config) dummy_case[yamlc.TAG_FILES] = [y] self.cases.append(dummy_case)
def __init__(self, yaml_config_file): self.yaml_config_file = yaml_config_file self.root = Paths.dirname(self.yaml_config_file) self.yamls = self._get_all_yamls() self.cases = list() self.common_config = None # create dummy case for every yaml file in folder if not Paths.exists(self.yaml_config_file): self.common_config = deepcopy(yamlc.DEFAULTS) for y in self.yamls: dummy_case = deepcopy(yamlc.DEFAULTS) dummy_case['files'] = [y] self.cases.append(dummy_case) else: # setup common config values self.yaml_config = self._read_yaml() self.common_config = self.merge( yamlc.DEFAULTS, self.yaml_config.get('common_config', {})) # first process files which are specified in test_cases missing = [Paths.basename(y) for y in self.yamls] for case in self.yaml_config.get(yamlc.TAG_TEST_CASES, []): case_config = self.merge(self.common_config, case) # ensure that value is array case_config[yamlc.TAG_FILES] = ensure_iterable( case_config.get(yamlc.TAG_FILES, [])) # keep correct order self.cases.append(case_config) for f in case_config[yamlc.TAG_FILES]: if f in missing: missing.remove(f) # process rest (dummy case) for y in missing: dummy_case = deepcopy(self.common_config) dummy_case[yamlc.TAG_FILES] = [y] self.cases.append(dummy_case)
def add_case(self, yaml_case_file): config = Paths.join(Paths.dirname(yaml_case_file), yamlc.CONFIG_YAML) self.configs[config] = None self.files[yaml_case_file] = None return self
def add_case(self, yaml_case_file): config = Paths.join(Paths.dirname(yaml_case_file), yamlc.CONFIG_YAML) self.configs[config] = None self.files[yaml_case_file] = None return self