Example #1
0
    def pytest_runtest_teardown(self, item):
        BaseTarget.pytest_runtest_teardown(self, item)

        try:
            if not OSHelper.is_windows():
                if item.funcargs['firefox'].runner and item.funcargs[
                        'firefox'].runner.process_handler:
                    quit_firefox()
                    status = item.funcargs[
                        'firefox'].runner.process_handler.wait(10)
                    if status is None:
                        item.funcargs['firefox'].browser.runner.stop()
            else:
                item.funcargs['firefox'].stop()
            if not target_args.save:
                profile_instance = item.funcargs['firefox'].profile
                if os.path.exists(profile_instance.profile):
                    try:
                        shutil.rmtree(profile_instance.profile,
                                      ignore_errors=True)
                    except sqlite3.OperationalError:
                        pass
                else:
                    logger.error('Invalid Path: %s' % profile_instance.profile)

        except (AttributeError, KeyError):
            pass
Example #2
0
    def pytest_sessionstart(self, session):
        global core_args
        core_args = get_core_args()
        global target_args
        BaseTarget.pytest_sessionstart(self, session)
        self.validate_config()
        try:
            port = core_args.port

            logger.info(
                "Starting local web server on port %s for directory %s" %
                (port, self.local_web_root))
            web_server_process = Process(target=LocalWebServer,
                                         args=(self.local_web_root, port))
            self.process_list.append(web_server_process)
            web_server_process.start()

            fx = self.args.firefox
            locale = core_args.locale
            app = FX_Collection.get(fx, locale)

            if not app:
                FX_Collection.add(fx, locale)
                app = FX_Collection.get(fx, locale)
            self.values = {
                "fx_version": app.version,
                "fx_build_id": app.build_id,
                "channel": app.channel
            }
        except IOError:
            logger.critical(
                "Unable to launch local web server, aborting Iris.")
            exit(1)
        logger.info("Loading more test images...")
Example #3
0
    def __init__(self):
        BaseTarget.__init__(self)
        global target_args
        target_args = self.get_target_args()
        self.target_name = "Firefox"
        self.process_list = []
        self.cc_settings = [
            {
                "name":
                "firefox",
                "type":
                "list",
                "label":
                "Firefox",
                "value":
                ["local", "latest", "latest-esr", "latest-beta", "nightly"],
                "default":
                "beta",
            },
            {
                "name": "locale",
                "type": "list",
                "label": "Locale",
                "value": OSHelper.LOCALES,
                "default": "en-US"
            },
            {
                "name": "max_tries",
                "type": "list",
                "label": "Maximum tries per test",
                "value": ["1", "2", "3", "4", "5"],
                "default": "3",
            },
            {
                "name": "highlight",
                "type": "checkbox",
                "label": "Debug using highlighting"
            },
            {
                "name": "override",
                "type": "checkbox",
                "label": "Run disabled tests"
            },
            {
                "name": "email",
                "type": "checkbox",
                "label": "Email results"
            },
            {
                "name": "report",
                "type": "checkbox",
                "label": "Create TestRail report"
            },
        ]

        self.local_web_root = os.path.join(PathManager.get_module_dir(),
                                           "targets", "firefox", "local_web")
        if target_args.treeherder:
            Settings.debug_image = False
Example #4
0
 def pytest_sessionfinish(self, session):
     BaseTarget.pytest_sessionfinish(self, session)
     for process in self.process_list:
         logger.info('Terminating process.')
         process.terminate()
         process.join()
     logger.debug('Finishing Firefox session')
     if target_args.report:
         report_test_results(self)
     if target_args.sendjson:
         self.send_json_report()
     if target_args.treeherder:
         self.create_ci_report()
     if self.clean_run is not True:
         exit(1)
Example #5
0
 def __init__(self):
     BaseTarget.__init__(self)
     global target_args
     target_args = self.get_target_args()
     self.target_name = 'Nightly'
     self.process_list = []
     self.cc_settings = [{
         'name': 'nightly',
         'type': 'list',
         'label': 'Nightly',
         'value': ['local', 'latest', 'nightly'],
         'default': 'nightly'
     }, {
         'name': 'locale',
         'type': 'list',
         'label': 'Locale',
         'value': OSHelper.LOCALES,
         'default': 'en-US'
     }, {
         'name': 'max_tries',
         'type': 'list',
         'label': 'Maximum tries per test',
         'value': ['1', '2', '3', '4', '5'],
         'default': '3'
     }, {
         'name': 'highlight',
         'type': 'checkbox',
         'label': 'Debug using highlighting'
     }, {
         'name': 'override',
         'type': 'checkbox',
         'label': 'Run disabled tests'
     }, {
         'name': 'email',
         'type': 'checkbox',
         'label': 'Email results'
     }, {
         'name': 'report',
         'type': 'checkbox',
         'label': 'Create TestRail report'
     }]
     self.local_web_root = os.path.join(PathManager.get_module_dir(),
                                        'targets', 'firefox', 'local_web')
     if target_args.treeherder:
         Settings.debug_image = False
Example #6
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)
Example #7
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)