예제 #1
0
def search(test, text):
    if test == 'A11':
        t = 0
    elif test == 'A09':
        t = 1
    elif test == 'A05':
        t = 2
    elif test == 'A04':
        t = 3
    elif test == 'A03':
        t = 4
    elif test == 'A02':
        t = 5
    elif test == 'pA11':
        t = 6
    elif test == 'pA09':
        t = 7
    elif test == 'pA06':
        t = 8

    if test[0]=='p':
        te = test[1:]
    else:
        te = test

    info = test_info.TestInfo(t)
    l = np.unique(lookup(text, info.all()[t]['POL']))
    return render_template(f'zoom.html', test_info = info.all(), l=l, t=t, test=te)
예제 #2
0
 def find_method_from_example_finder(self, test):
     """Example find method to demonstrate how to register it."""
     if test == 'ExampleFinderTest':
         return test_info.TestInfo(test_name=test,
                                   test_runner=self._TEST_RUNNER,
                                   build_targets=set())
     return None
예제 #3
0
    def find_test_by_path(self, path):
        """Find the first test info matching the given path.

        Strategy:
            path_to_java_file --> Resolve to CLASS
            path_to_module_file -> Resolve to MODULE
            path_to_module_dir -> Resolve to MODULE
            path_to_dir_with_class_files--> Resolve to PACKAGE
            path_to_any_other_dir --> Resolve as MODULE

        Args:
            path: A string of the test's path.

        Returns:
            A populated TestInfo namedtuple if test found, else None
        """
        logging.debug('Finding test by path: %s', path)
        path, methods = test_finder_utils.split_methods(path)
        # TODO: See if this can be generalized and shared with methods above
        # create absolute path from cwd and remove symbolic links
        path = os.path.realpath(path)
        if not os.path.exists(path):
            return None
        dir_path, file_name = test_finder_utils.get_dir_path_and_filename(path)
        # Module/Class
        rel_module_dir = test_finder_utils.find_parent_module_dir(
            self.root_dir, dir_path, self.module_info)
        if not rel_module_dir:
            return None
        module_name = self._get_first_testable_module(rel_module_dir)
        rel_config = os.path.join(rel_module_dir, constants.MODULE_CONFIG)
        data = {
            constants.TI_REL_CONFIG: rel_config,
            constants.TI_FILTER: frozenset()
        }
        # Path is to java file
        if file_name and file_name.endswith(_JAVA_EXT):
            full_class_name = test_finder_utils.get_fully_qualified_class_name(
                path)
            data[constants.TI_FILTER] = frozenset(
                [test_info.TestFilter(full_class_name, methods)])
        # path to non-module dir, treat as package
        elif (not file_name and not self._is_auto_gen_test_config(module_name)
              and rel_module_dir != os.path.relpath(path, self.root_dir)):
            dir_items = [os.path.join(path, f) for f in os.listdir(path)]
            for dir_item in dir_items:
                if dir_item.endswith(_JAVA_EXT):
                    package_name = test_finder_utils.get_package_name(dir_item)
                    if package_name:
                        # methods should be empty frozenset for package.
                        if methods:
                            raise atest_error.MethodWithoutClassError()
                        data[constants.TI_FILTER] = frozenset(
                            [test_info.TestFilter(package_name, methods)])
                        break
        return self._process_test_info(
            test_info.TestInfo(test_name=module_name,
                               test_runner=self._TEST_RUNNER,
                               build_targets=set(),
                               data=data))
예제 #4
0
    def find_int_test_by_path(self, path):
        """Find the first test info matching the given path.

        Strategy:
            path_to_integration_file --> Resolve to INTEGRATION
            # If the path is a dir, we return nothing.
            path_to_dir_with_integration_files --> Return None

        Args:
            path: A string of the test's path.

        Returns:
            A populated TestInfo namedtuple if test found, else None
        """
        path, _ = test_finder_utils.split_methods(path)

        # Make sure we're looking for a config.
        if not path.endswith('.xml'):
            return None

        # TODO: See if this can be generalized and shared with methods above
        # create absolute path from cwd and remove symbolic links
        path = os.path.realpath(path)
        if not os.path.exists(path):
            return None
        dir_path, file_name = test_finder_utils.get_dir_path_and_filename(path)

        int_dir = None
        for possible_dir in self.integration_dirs:
            abs_int_dir = os.path.join(self.root_dir, possible_dir)
            if test_finder_utils.is_equal_or_sub_dir(dir_path, abs_int_dir):
                int_dir = abs_int_dir
                break
        if int_dir:
            if not file_name:
                logging.warn('Found dir (%s) matching input (%s).'
                             ' Referencing an entire Integration/Suite dir'
                             ' is not supported. If you are trying to reference'
                             ' a test by its path, please input the path to'
                             ' the integration/suite config file itself.',
                             int_dir, path)
                return None
            rel_config = os.path.relpath(path, self.root_dir)
            match = _INT_NAME_RE.match(rel_config)
            if not match:
                logging.error('Integration test outside config dir: %s',
                              rel_config)
                return None
            int_name = match.group('int_name')
            return test_info.TestInfo(
                test_name=int_name,
                test_runner=self._TEST_RUNNER,
                build_targets=self._get_build_targets(rel_config),
                data={constants.TI_REL_CONFIG: rel_config,
                      constants.TI_FILTER: frozenset()})
        return None
예제 #5
0
    def find_test_by_class_name(self,
                                class_name,
                                module_name=None,
                                rel_config=None):
        """Find test files given a class name.

        If module_name and rel_config not given it will calculate it determine
        it by looking up the tree from the class file.

        Args:
            class_name: A string of the test's class name.
            module_name: Optional. A string of the module name to use.
            rel_config: Optional. A string of module dir relative to repo root.

        Returns:
            A populated TestInfo namedtuple if test found, else None.
        """
        class_name, methods = test_finder_utils.split_methods(class_name)
        if rel_config:
            search_dir = os.path.join(self.root_dir,
                                      os.path.dirname(rel_config))
        else:
            search_dir = self.root_dir
        test_path = test_finder_utils.find_class_file(search_dir, class_name)
        if not test_path and rel_config:
            logging.info(
                'Did not find class (%s) under module path (%s), '
                'researching from repo root.', class_name, rel_config)
            test_path = test_finder_utils.find_class_file(
                self.root_dir, class_name)
        if not test_path:
            return None
        full_class_name = test_finder_utils.get_fully_qualified_class_name(
            test_path)
        test_filter = frozenset(
            [test_info.TestFilter(full_class_name, methods)])
        if not rel_config:
            test_dir = os.path.dirname(test_path)
            rel_module_dir = test_finder_utils.find_parent_module_dir(
                self.root_dir, test_dir, self.module_info)
            rel_config = os.path.join(rel_module_dir, constants.MODULE_CONFIG)
        if not module_name:
            module_name = self._get_first_testable_module(
                os.path.dirname(rel_config))
        return self._process_test_info(
            test_info.TestInfo(test_name=module_name,
                               test_runner=self._TEST_RUNNER,
                               build_targets=set(),
                               data={
                                   constants.TI_FILTER: test_filter,
                                   constants.TI_REL_CONFIG: rel_config
                               }))
예제 #6
0
    def find_test_by_integration_name(self, name):
        """Find the test info matching the given integration name.

        Args:
            name: A string of integration name as seen in tf's list configs.

        Returns:
            A populated TestInfo namedtuple if test found, else None
        """
        class_name = None
        if ':' in name:
            name, class_name = name.split(':')
        test_file = self._search_integration_dirs(name)
        if test_file is None:
            return None
        # Don't use names that simply match the path,
        # must be the actual name used by TF to run the test.
        match = _INT_NAME_RE.match(test_file)
        if not match:
            logging.error('Integration test outside config dir: %s',
                          test_file)
            return None
        int_name = match.group('int_name')
        if int_name != name:
            logging.warn('Input (%s) not valid integration name, '
                         'did you mean: %s?', name, int_name)
            return None
        rel_config = os.path.relpath(test_file, self.root_dir)

        filters = frozenset()
        if class_name:
            class_name, methods = test_finder_utils.split_methods(class_name)
            if '.' not in class_name:
                logging.warn('Looking up fully qualified class name for: %s.'
                             'Improve speed by using fully qualified names.',
                             class_name)
                path = test_finder_utils.find_class_file(self.root_dir,
                                                         class_name)
                if not path:
                    return None
                class_name = test_finder_utils.get_fully_qualified_class_name(
                    path)
            filters = frozenset([test_info.TestFilter(class_name, methods)])
        return test_info.TestInfo(
            test_name=name,
            test_runner=self._TEST_RUNNER,
            build_targets=self._get_build_targets(rel_config),
            data={constants.TI_REL_CONFIG: rel_config,
                  constants.TI_FILTER: filters})
예제 #7
0
    def find_test_by_package_name(self,
                                  package,
                                  module_name=None,
                                  rel_config=None):
        """Find the test info given a PACKAGE string.

        Args:
            package: A string of the package name.
            module_name: Optional. A string of the module name.
            ref_config: Optional. A string of rel path of config.

        Returns:
            A populated TestInfo namedtuple if found, else None.
        """
        _, methods = test_finder_utils.split_methods(package)
        if methods:
            raise atest_error.MethodWithoutClassError('Method filtering '
                                                      'requires class')
        # Confirm that packages exists and get user input for multiples.
        if rel_config:
            search_dir = os.path.join(self.root_dir,
                                      os.path.dirname(rel_config))
        else:
            search_dir = self.root_dir
        package_path = test_finder_utils.run_find_cmd(
            test_finder_utils.FIND_REFERENCE_TYPE.PACKAGE, search_dir,
            package.replace('.', '/'))
        # package path will be the full path to the dir represented by package
        if not package_path:
            return None
        test_filter = frozenset([test_info.TestFilter(package, frozenset())])
        if not rel_config:
            rel_module_dir = test_finder_utils.find_parent_module_dir(
                self.root_dir, package_path, self.module_info)
            rel_config = os.path.join(rel_module_dir, constants.MODULE_CONFIG)
        if not module_name:
            module_name = self._get_first_testable_module(
                os.path.dirname(rel_config))
        return self._process_test_info(
            test_info.TestInfo(test_name=module_name,
                               test_runner=self._TEST_RUNNER,
                               build_targets=set(),
                               data={
                                   constants.TI_FILTER: test_filter,
                                   constants.TI_REL_CONFIG: rel_config
                               }))
예제 #8
0
def assessments(test):
    if test == 'A11':
        t = 0
    elif test == 'A09':
        t = 1
    elif test == 'A05':
        t = 2
    elif test == 'A04':
        t = 3
    elif test == 'A03':
        t = 4
    elif test == 'A02':
        t = 5
    elif test == 'pA11':
        t = 6
    elif test == 'pA09':
        t = 7
    elif test == 'pA06':
        t = 8
    info = test_info.TestInfo(t)

    # l = lookup('Solubility reactions', test_info[0]['POL'])
    return render_template(f'{test}.html', test_info = info.all())
예제 #9
0
    def find_test_by_module_name(self, module_name):
        """Find test for the given module name.

        Args:
            module_name: A string of the test's module name.

        Returns:
            A populated TestInfo namedtuple if found, else None.
        """
        mod_info = self.module_info.get_module_info(module_name)
        if self._is_testable_module(mod_info):
            # path is a list with only 1 element.
            rel_config = os.path.join(mod_info['path'][0],
                                      constants.MODULE_CONFIG)
            return self._process_test_info(
                test_info.TestInfo(test_name=module_name,
                                   test_runner=self._TEST_RUNNER,
                                   build_targets=set(),
                                   data={
                                       constants.TI_REL_CONFIG: rel_config,
                                       constants.TI_FILTER: frozenset()
                                   }))
        return None
예제 #10
0
# import test_info as test
import test_info

A11 = test_info.TestInfo(0)
A09 = test_info.TestInfo(1)
A05 = test_info.TestInfo(2)

# print(A11.listConcepts(14))
# print(A09.listConcepts(14))
# print(A05.listConcepts(14))

# print(A11.listPol(11))
# print(A09.listPol(11))
# print(A05.listPol(11))

print(A11.all())