Example #1
0
 def _get_include_suites(self, path, datadir, incl_suites):
     if not isinstance(incl_suites, SuiteNamePatterns):
         incl_suites = SuiteNamePatterns(incl_suites)
     # If a directory is included, also all its children should be included.
     if self._is_in_included_suites(os.path.basename(path), datadir.parent,
                                    incl_suites):
         return SuiteNamePatterns()
     return incl_suites
Example #2
0
 def _get_include_suites(self, path, incl_suites):
     if not isinstance(incl_suites, SuiteNamePatterns):
         incl_suites = SuiteNamePatterns(incl_suites)
     if not incl_suites:
         return incl_suites
     # If a directory is included, also all its children should be included.
     if self._directory_is_included(path, incl_suites):
         return SuiteNamePatterns()
     return incl_suites
 def _get_include_suites(self, path, incl_suites):
     if not isinstance(incl_suites, SuiteNamePatterns):
         # Use only the last part of names given like '--suite parent.child'
         incl_suites = SuiteNamePatterns(i.split('.')[-1] for i in incl_suites)
     if not incl_suites:
         return incl_suites
     # If a directory is included, also all its children should be included.
     if self._directory_is_included(path, incl_suites):
         return SuiteNamePatterns()
     return incl_suites
Example #4
0
    def discover(self, url, which_tests=loader.DiscoverMode.DEFAULT):
        avocado_suite = []
        subtests_filter = None

        if url is None:
            return []

        if ':' in url:
            url, _subtests_filter = url.split(':', 1)
            subtests_filter = re.compile(_subtests_filter)
        try:
            test_data = TestData(parent=None,
                                 source=url,
                                 include_suites=SuiteNamePatterns())
            robot_suite = self._find_tests(test_data, test_suite={})
        except Exception as data:
            if which_tests == loader.DiscoverMode.ALL:
                return [(NotRobotTest, {"name": "%s: %s" % (url, data)})]
            return []

        for item in robot_suite:
            for robot_test in robot_suite[item]:
                test_name = "%s:%s.%s" % (robot_test['test_source'], item,
                                          robot_test['test_name'])
                if subtests_filter and not subtests_filter.search(test_name):
                    continue
                avocado_suite.append((RobotTest, {
                    'name': test_name,
                    'executable': test_name
                }))
        if which_tests == loader.DiscoverMode.ALL and not avocado_suite:
            return [(NotRobotTest, {
                "name": "%s: No robot-like tests found" % url
            })]
        return avocado_suite
Example #5
0
    def discover(self, url, which_tests=False):
        avocado_suite = []
        subtests_filter = None

        if url is None:
            return []

        if ':' in url:
            url, _subtests_filter = url.split(':', 1)
            subtests_filter = re.compile(_subtests_filter)
        try:
            test_data = TestData(parent=None,
                                 source=url,
                                 include_suites=SuiteNamePatterns())
            robot_suite = self._find_tests(test_data, test_suite={})
        except DataError:
            return []

        for item in robot_suite:
            for robot_test in robot_suite[item]:
                test_name = "%s:%s.%s" % (robot_test['test_source'], item,
                                          robot_test['test_name'])
                if subtests_filter and not subtests_filter.search(test_name):
                    continue
                avocado_suite.append((RobotTest, {'name': test_name}))
        return avocado_suite
Example #6
0
 def _get_include_suites(self, path, incl_suites):
     if not incl_suites:
         return None
     if not isinstance(incl_suites, SuiteNamePatterns):
         incl_suites = SuiteNamePatterns(
             self._create_included_suites(incl_suites))
     # If a directory is included, also all its children should be included.
     if self._is_in_included_suites(os.path.basename(path), incl_suites):
         return None
     return incl_suites
Example #7
0
def find_tests(reference, test_suite):
    data = TestData(parent=None,
                    source=reference,
                    include_suites=SuiteNamePatterns())
    test_suite[data.name] = []
    for test_case in data.testcase_table:
        test_suite[data.name].append({'test_name': test_case.name,
                                      'test_source': test_case.source})
    for child_data in data.children:
        find_tests(child_data, test_suite)
    return test_suite