Exemplo n.º 1
0
    def pytest_runtest_setup(self, item):
        BaseTarget.pytest_runtest_setup(self, item)

        if OSHelper.is_mac():
            mouse_reset()
        if item.name == 'run' and not core_args.override:
            skip_reason_list = []
            values = item.own_markers[0].kwargs
            is_disabled = 'enabled' in values and not values.get('enabled') and not core_args.override
            is_excluded = 'exclude' in values and OSHelper.get_os() in values.get('exclude')
            incorrect_locale = 'locale' in values and core_args.locale not in values.get('locale')
            incorrect_platform = 'platform' in values and OSHelper.get_os() not in values.get('platform')
            fx_version = self.values.get('fx_version')
            incorrect_fx_version = 'fx_version' in values and not check_version(fx_version, values.get('fx_version'))

            if is_disabled:
                skip_reason_list.append('Test is disabled')

            if is_excluded:
                skip_reason_list.append('Test is excluded for {}'.format(OSHelper.get_os()))

            if 'blocked_by' in values:
                bug_id = ''
                platform = OSHelper.get_os()
                if type(values.get('blocked_by')) is str:
                    bug_id = values.get('blocked_by')
                elif type(values.get('blocked_by')) is dict:
                    try:
                        bug_id = values.get('blocked_by')['id']
                        platform = values.get('blocked_by')['platform']
                    except KeyError as e:
                        logger.debug('Missing key in blocked_by field: %s' % e)
                logger.debug('Looking up bug #%s...' % bug_id)
                blocked_platform = OSHelper.get_os() in platform
                logger.debug('Test has blocking issue: %s' % is_blocked(bug_id))
                logger.debug('Test is blocked on this platform: %s' % blocked_platform)
                if is_blocked(bug_id) and blocked_platform:
                    skip_reason_list.append('Test is blocked by [{}] on this platform.'.format(bug_id))

            if incorrect_locale:
                skip_reason_list.append('Test doesn\'t support locale [{}]'.format(core_args.locale))

            if incorrect_platform:
                skip_reason_list.append('Test doesn\'t support platform [{}]'.format(OSHelper.get_os()))

            if incorrect_fx_version:
                skip_reason_list.append('Test doesn\'t support Firefox version [{}]'.format(fx_version))

            if len(skip_reason_list) > 0:
                logger.info(
                    'Test skipped: - [{}]: {} Reason(s): {}'.format(item.nodeid.split(':')[0],
                                                                    values.get('description'),
                                                                    ', '.join(skip_reason_list)))
                test_instance = (item, 'SKIPPED', None)

                test_result = create_result_object(test_instance, 0, 0)
                self.completed_tests.append(test_result)
                pytest.skip(item)
Exemplo n.º 2
0
def is_update_required(current_version, starting_condition):
    """Check that Firefox update is required.

    :param current_version: Current Firefox version.
    :param starting_condition: Input string. Examples of accepted formats:
    '60', '>60', '<60', '>=60', '<=60', '!=60', '60-63'. A '60' version will automatically be converted into '60.0.0'.
    :return: Call the check_version() method.
    """
    return check_version(current_version, starting_condition)
Exemplo n.º 3
0
    def pytest_runtest_setup(self, item):
        BaseTarget.pytest_runtest_setup(self, item)

        if OSHelper.is_mac():
            mouse_reset()
        if item.name == 'test_run':
            skip_reason_list = []
            values = item.own_markers[0].kwargs
            is_disabled = 'enabled' in values and not values.get(
                'enabled') and not core_args.override
            is_excluded = 'exclude' in values and OSHelper.get_os(
            ) in values.get('exclude')
            incorrect_locale = 'locale' in values and core_args.locale not in values.get(
                'locale')
            incorrect_platform = 'platform' in values and OSHelper.get_os(
            ) not in values.get('platform')
            fx_version = self.values.get('fx_version')
            incorrect_fx_version = 'fx_version' in values and not check_version(
                fx_version, values.get('fx_version'))

            if is_disabled:
                skip_reason_list.append('Test is disabled')

            if is_excluded:
                skip_reason_list.append('Test is excluded for {}'.format(
                    OSHelper.get_os()))

            if 'blocked_by' in values:
                bug_id = values.get('blocked_by')
                if is_blocked(bug_id):
                    skip_reason_list.append(
                        'Test is blocked by [{}]'.format(bug_id))

            if incorrect_locale:
                skip_reason_list.append(
                    'Test doesn\'t support locale [{}]'.format(
                        core_args.locale))

            if incorrect_platform:
                skip_reason_list.append(
                    'Test doesn\'t support platform [{}]'.format(
                        OSHelper.get_os()))

            if incorrect_fx_version:
                skip_reason_list.append(
                    'Test doesn\'t support Firefox version [{}]'.format(
                        fx_version))

            if len(skip_reason_list) > 0:
                logger.info('Test skipped: - [{}]: {} Reason(s): {}'.format(
                    item.nodeid.split(':')[0], values.get('description'),
                    ', '.join(skip_reason_list)))
                test_instance = (item, 'SKIPPED', None)

                test_result = create_result_object(test_instance, 0, 0)
                self.completed_tests.append(test_result)
                pytest.skip(item)
Exemplo n.º 4
0
def get_rule_for_channel(channel, current_version):
    """
    :param channel: Firefox channel.
    :param current_version: Current Firefox version.
    :return: Channel's list of rules.
    """
    rules = get_update_rules()
    if rules is None:
        return None

    result_list = [x for x in rules if x['channel'] == channel and OSHelper.get_os() in x['os'] and
                   check_version(current_version, x['starting_condition'])]
    if len(result_list) == 0:
        return None
    elif len(result_list) > 1:
        logger.warning('Multiple rules for \'{}\' channel'.format(channel))
        return result_list[0]
    return result_list[0]
Exemplo n.º 5
0
    def pytest_runtest_setup(self, item):
        BaseTarget.pytest_runtest_setup(self, item)
        if OSHelper.is_mac():
            mouse_reset()
        if item.name == "run" and not core_args.override:
            skip_reason_list = []
            values = item.own_markers[0].kwargs
            is_disabled = "enabled" in values and not values.get(
                "enabled") and not core_args.override
            is_excluded = "exclude" in values and OSHelper.get_os(
            ) in values.get("exclude")
            incorrect_locale = "locale" in values and core_args.locale not in values.get(
                "locale")
            incorrect_platform = "platform" in values and OSHelper.get_os(
            ) not in values.get("platform")
            fx_version = self.values.get("fx_version")
            incorrect_fx_version = "fx_version" in values and not check_version(
                fx_version, values.get("fx_version"))

            if is_disabled:
                skip_reason_list.append("Test is disabled")

            if is_excluded:
                skip_reason_list.append("Test is excluded for {}".format(
                    OSHelper.get_os()))

            if "blocked_by" in values:
                bug_id = ""
                platform = OSHelper.get_os()
                if type(values.get("blocked_by")) is str:
                    bug_id = values.get("blocked_by")
                elif type(values.get("blocked_by")) is dict:
                    try:
                        bug_id = values.get("blocked_by")["id"]
                        platform = values.get("blocked_by")["platform"]
                    except KeyError as e:
                        logger.debug("Missing key in blocked_by field: %s" % e)
                logger.debug("Looking up bug #%s..." % bug_id)
                blocked_platform = OSHelper.get_os() in platform
                logger.debug("Test has blocking issue: %s" %
                             is_blocked(bug_id))
                logger.debug("Test is blocked on this platform: %s" %
                             blocked_platform)
                if is_blocked(bug_id) and blocked_platform:
                    skip_reason_list.append(
                        "Test is blocked by [{}] on this platform.".format(
                            bug_id))

            if incorrect_locale:
                skip_reason_list.append(
                    "Test doesn't support locale [{}]".format(
                        core_args.locale))

            if incorrect_platform:
                skip_reason_list.append(
                    "Test doesn't support platform [{}]".format(
                        OSHelper.get_os()))

            if incorrect_fx_version:
                skip_reason_list.append(
                    "Test doesn't support Firefox version [{}]".format(
                        fx_version))

            if len(skip_reason_list) > 0:
                logger.info("Test skipped: - [{}]: {} Reason(s): {}".format(
                    item.nodeid.split(":")[0], values.get("description"),
                    ", ".join(skip_reason_list)))
                test_instance = (item, "SKIPPED", None)
                test_result = create_result_object(test_instance, 0, 0)
                self.add_test_result(test_result)
                Target.index += 1
                pytest.skip(item)