def _get_all_yamls(self):
     yamls = Paths.browse(
         self.root,(
             PathFilters.filter_endswith(YAML),
             PathFilters.filter_not(PathFilters.filter_endswith(CONFIG_YAML))
         ))
     return yamls
Exemple #2
0
    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()
Exemple #3
0
class ConfigPool(object):
    """
    Class ConfigPool collects configs from multiple yaml files
    :type configs : dict[str, ConfigBase]
    :type files : dict[str, ConfigBase]
    """

    # match only yaml files not in ref_out or test_results having config.yaml
    #  in the same directory (excluding config.yaml itself)
    yaml_filters = [
        PathFilters.filter_type_is_file(),
        PathFilters.filter_ignore_dirs(
            [yamlc.TEST_RESULTS, yamlc.TEST_RESULTS]),
        PathFilters.filter_not(PathFilters.filter_name('config.yaml')),
        PathFilters.filter_endswith('.yaml'),
        PathFilters.filter_dir_contains_file('config.yaml'),
    ]

    def __init__(self):
        self.configs = dict()
        self.files = dict()

    def add_config(self, yaml_config_file):
        self.configs[yaml_config_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

    def add(self, yaml_file):
        """
        :type yaml_file: str
        """
        if yaml_file.endswith(yamlc.CONFIG_YAML):
            return self.add_config(yaml_file)
        return self.add_case(yaml_file)

    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]

    __iadd__ = add

    def update(self, proc, time_limit, memory_limit, **kwargs):
        for config in list(self.configs.values()):
            config.update(proc, time_limit, memory_limit, **kwargs)

    def filter_tags(self, include, exclude):
        include = set(include) if include else None
        exclude = set(exclude) if exclude else None

        for config in list(self.configs.values()):
            config.filter_tags(include, exclude)
    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()
Exemple #5
0
    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()
Exemple #6
0
 def _get_all_yamls(self):
     yamls = Paths.browse(
         self.root, (PathFilters.filter_endswith(yamlc.YAML),
                     PathFilters.filter_not(
                         PathFilters.filter_endswith(yamlc.CONFIG_YAML))))
     return yamls