Пример #1
0
    def test_get_binary(self):
        """ Test mozinstall's get_binary method """

        if mozinfo.isLinux:
            installdir = mozinstall.install(self.bz2, self.tempdir)
            binary = os.path.join(installdir, 'firefox')
            self.assertEqual(binary,
                             mozinstall.get_binary(installdir, 'firefox'))

        elif mozinfo.isWin:
            installdir_exe = mozinstall.install(
                self.exe, os.path.join(self.tempdir, 'exe'))
            binary_exe = os.path.join(installdir_exe, 'core', 'firefox.exe')
            self.assertEqual(binary_exe,
                             mozinstall.get_binary(installdir_exe, 'firefox'))

            installdir_zip = mozinstall.install(
                self.zipfile, os.path.join(self.tempdir, 'zip'))
            binary_zip = os.path.join(installdir_zip, 'firefox.exe')
            self.assertEqual(binary_zip,
                             mozinstall.get_binary(installdir_zip, 'firefox'))

        elif mozinfo.isMac:
            installdir = mozinstall.install(self.dmg, self.tempdir)
            binary = os.path.join(installdir, 'Contents', 'MacOS', 'firefox')
            self.assertEqual(binary,
                             mozinstall.get_binary(installdir, 'firefox'))
Пример #2
0
    def prepare_application(self, binary):
        # Prepare the binary for the test run
        if application.is_installer(self.binary, self.options.application):
            install_path = os.path.join(self.workspace, 'binary')

            self.mozlogger.info('Installing build: %s' % self.binary)
            self._folder = mozinstall.install(self.binary, install_path)

            binary_name = APPLICATION_BINARY_NAMES[self.options.application]
            self._application = mozinstall.get_binary(self._folder,
                                                      binary_name)
        else:
            if os.path.isdir(self.binary):
                self._folder = self.binary
            else:
                if mozinfo.isMac:
                    # Ensure that self._folder is the app bundle on OS X
                    p = re.compile('.*\.app/')
                    self._folder = p.search(self.binary).group()
                else:
                    self._folder = os.path.dirname(self.binary)

            binary_name = APPLICATION_BINARY_NAMES[self.options.application]
            self._application = mozinstall.get_binary(self._folder,
                                                      binary_name)
Пример #3
0
    def test_get_binary(self):
        """ Test mozinstall's get_binary method """

        if mozinfo.isLinux:
            installdir = mozinstall.install(self.bz2, self.tempdir)
            binary = os.path.join(installdir, 'firefox')
            self.assertEqual(binary, mozinstall.get_binary(installdir, 'firefox'))

        elif mozinfo.isWin:
            installdir_exe = mozinstall.install(self.exe,
                                                os.path.join(self.tempdir, 'exe'))
            binary_exe = os.path.join(installdir_exe, 'firefox', 'firefox',
                                      'firefox.exe')
            self.assertEqual(binary_exe, mozinstall.get_binary(installdir_exe,
                             'firefox'))

            installdir_zip = mozinstall.install(self.zipfile,
                                                os.path.join(self.tempdir, 'zip'))
            binary_zip = os.path.join(installdir_zip, 'firefox.exe')
            self.assertEqual(binary_zip, mozinstall.get_binary(installdir_zip,
                             'firefox'))

        elif mozinfo.isMac:
            installdir = mozinstall.install(self.dmg, self.tempdir)
            binary = os.path.join(installdir, 'Contents', 'MacOS', 'firefox')
            self.assertEqual(binary, mozinstall.get_binary(installdir, 'firefox'))
Пример #4
0
    def prepare_application(self, binary):
        # Prepare the binary for the test run
        if application.is_installer(self.binary, self.options.application):
            install_path = os.path.join(self.workspace, 'binary')

            print "*** Installing build: %s" % self.binary
            self._folder = mozinstall.install(self.binary, install_path)

            binary_name = APPLICATION_BINARY_NAMES[self.options.application]
            self._application = mozinstall.get_binary(self._folder,
                                                      binary_name)
        else:
            if os.path.isdir(self.binary):
                self._folder = self.binary
            else:
                if mozinfo.isMac:
                    # Ensure that self._folder is the app bundle on OS X
                    p = re.compile('.*\.app/')
                    self._folder = p.search(self.binary).group()
                else:
                    self._folder = os.path.dirname(self.binary)

            binary_name = APPLICATION_BINARY_NAMES[self.options.application]
            self._application = mozinstall.get_binary(self._folder,
                                                      binary_name)
Пример #5
0
    def _get_test_candidate(version: str, locale: str) -> str or None:
        """Download and extract a build candidate.

        Build may either refer to a Firefox release identifier, package, or build directory.
        :param: build: str with firefox build
        :return: Installation path for the Firefox App
        """
        logger.debug("Getting build, version %s, locale %s" % (version, locale))
        if version == "local":
            candidate = PathManager.get_local_firefox_path()
            if candidate is None:
                logger.critical("Firefox not found. Please download if from https://www.mozilla.org/en-US/firefox/new/")
            return candidate
        elif os.path.isfile(version):
            return version
        else:
            try:
                s_t, s_d = _get_scraper_details(
                    version, CHANNELS, os.path.join(PathManager.get_working_dir(), "cache"), locale
                )

                scraper = FactoryScraper(s_t, **s_d)
                firefox_dmg = scraper.download()

                install_dir = install(
                    src=firefox_dmg,
                    dest=os.path.join(
                        PathManager.get_temp_dir(), "firefox{}{}".format(normalize_str(version), normalize_str(locale))
                    ),
                )

                return get_binary(install_dir, "Firefox")
            except errors.NotFoundError:
                logger.critical("Specified build {} has not been found. Closing Iris ...".format(version))
        return None
Пример #6
0
def get_test_candidate():
    """Download and extract a build candidate.

    Build may either refer to a Firefox release identifier, package, or build directory.
    :param: build: str with firefox build
    :return: Installation path for the Firefox App
    """

    if parse_args().firefox == 'local':
        candidate = get_local_firefox_path()
        if candidate is None:
            logger.critical(
                'Firefox not found. Please download if from https://www.mozilla.org/en-US/firefox/new/'
            )
    else:
        try:
            locale = 'ja-JP-mac' if parse_args(
            ).locale == 'ja' and Settings.is_mac() else parse_args().locale
            type, scraper_details = get_scraper_details(
                parse_args().firefox, Settings.CHANNELS,
                os.path.join(IrisCore.get_working_dir(), 'cache'), locale)
            scraper = FactoryScraper(type, **scraper_details)

            firefox_dmg = scraper.download()
            install_folder = install(src=firefox_dmg,
                                     dest=IrisCore.get_current_run_dir())

            return get_binary(install_folder, 'Firefox')
        except errors.NotFoundError:
            logger.critical(
                'Specified build (%s) has not been found. Closing Iris ...' %
                parse_args().firefox)
    return None
Пример #7
0
 def install(self):
     if not self.name:
         raise NotImplementedError("Can't invoke abstract base class")
     self.remove_tempdir()
     self.tempdir = tempfile.mkdtemp()
     self.binary = mozinstall.get_binary(mozinstall.install(src=self.dest, dest=self.tempdir), self.name)
     return True
Пример #8
0
    def find_binary_path(self,path=None, channel="nightly"):
        """Looks for the firefox binary in the virtual environment"""

        platform = {
            "Linux": "linux",
            "Windows": "win",
            "Darwin": "mac"
        }.get(uname[0])

        application_name = {
            "stable": "Firefox.app",
            "beta": "Firefox.app",
            "nightly": "Firefox Nightly.app"
        }.get(channel)

        if path is None:
            #os.getcwd() doesn't include the venv path
            path = os.path.join(os.getcwd(), "_venv", "browsers", channel)

        binary = None

        if platform == "linux":
            binary = find_executable("firefox", os.path.join(path, "firefox"))
        elif platform == "win":
            import mozinstall
            binary = mozinstall.get_binary(path, "firefox")
        elif platform == "mac":
            binary = find_executable("firefox", os.path.join(path, application_name,
                                                             "Contents", "MacOS"))

        return binary
Пример #9
0
def startTestRunner(runner_class, options, tests):
    install_folder = None

    try:
        # If the specified binary is an installer it needs to be installed
        if options.installer:
            installer = os.path.realpath(options.installer)

            dest_folder = tempfile.mkdtemp()
            options.logger.info('Installing application "%s" to "%s"' %
                                (installer, dest_folder))
            install_folder = mozinstall.install(installer, dest_folder)
            options.binary = mozinstall.get_binary(install_folder, 'firefox')

        runner = runner_class(**vars(options))
        runner.run_tests(tests)

    finally:
        # Ensure to uninstall the binary if it has been installed before
        if install_folder and os.path.exists(install_folder):
            options.logger.info('Uninstalling application at "%s"' %
                                install_folder)
            mozinstall.uninstall(install_folder)

    return runner
Пример #10
0
    def find_binary_path(self, path=None, channel="nightly"):
        """Looks for the firefox binary in the virtual environment"""

        if path is None:
            # os.getcwd() doesn't include the venv path
            path = os.path.join(os.getcwd(), "_venv", "browsers", channel)

        binary = None

        if self.platform == "linux":
            binary = find_executable("firefox", os.path.join(path, "firefox"))
        elif self.platform == "win":
            import mozinstall
            try:
                binary = mozinstall.get_binary(path, "firefox")
            except mozinstall.InvalidBinary:
                # ignore the case where we fail to get a binary
                pass
        elif self.platform == "macos":
            binary = find_executable(
                "firefox",
                os.path.join(
                    path,
                    self.application_name.get(channel, "Firefox Nightly.app"),
                    "Contents", "MacOS"))

        return binary
Пример #11
0
        def _run_tests(tags):
            application_folder = None

            try:
                # Backup current tags
                test_tags = self.test_tags

                application_folder = self.duplicate_application(source_folder)
                self.bin = mozinstall.get_binary(application_folder, 'Firefox')

                self.test_tags = tags
                super(UpdateTestRunner, self).run_tests(tests)

            except Exception:
                self.exc_info = sys.exc_info()
                self.logger.error('Failure during execution of the update test.',
                                  exc_info=self.exc_info)

            finally:
                self.test_tags = test_tags

                self.logger.info('Removing copy of the application at "%s"' % application_folder)
                try:
                    mozfile.remove(application_folder)
                except IOError as e:
                    self.logger.error('Cannot remove copy of application: "%s"' % str(e))
Пример #12
0
 def install(self):
     if not self.name:
         raise NotImplementedError("Can't invoke abstract base class")
     self.remove_tempdir()
     self.tempdir = tempfile.mkdtemp()
     self.binary = mozinstall.get_binary(mozinstall.install(src=self.dest, dest=self.tempdir), self.name)
     return True
Пример #13
0
def startTestRunner(runner_class, options, tests):
    install_folder = None

    try:
        # Prepare the workspace path so that all temporary data can be stored inside it.
        if options.workspace_path:
            path = os.path.expanduser(options.workspace_path)
            options.workspace = os.path.abspath(path)

            if not os.path.exists(options.workspace):
                os.makedirs(options.workspace)
        else:
            options.workspace = tempfile.mkdtemp(".{}".format(os.path.basename(sys.argv[0])))

        options.logger.info('Using workspace for temporary data: "{}"'.format(options.workspace))

        # If the specified binary is an installer it needs to be installed
        if options.installer:
            installer = os.path.realpath(options.installer)

            dest_folder = os.path.join(options.workspace, "binary")
            options.logger.info('Installing application "%s" to "%s"' % (installer, dest_folder))
            install_folder = mozinstall.install(installer, dest_folder)
            options.binary = mozinstall.get_binary(install_folder, "firefox")

        runner = runner_class(**vars(options))
        runner.run_tests(tests)

    finally:
        # Ensure to uninstall the binary if it has been installed before
        if install_folder and os.path.exists(install_folder):
            options.logger.info('Uninstalling application at "%s"' % install_folder)
            mozinstall.uninstall(install_folder)

    return runner
Пример #14
0
    def find_binary_path(self, path=None):
        """Looks for the firefox binary in the virtual environment"""

        platform = {
            "Linux": "linux",
            "Windows": "win",
            "Darwin": "mac"
        }.get(uname[0])

        if path is None:
            #os.getcwd() doesn't include the venv path
            path = os.path.join(os.getcwd(), "_venv", "browsers")

        binary = None

        if platform == "linux":
            binary = find_executable("firefox", os.path.join(path, "firefox"))
        elif platform == "win":
            import mozinstall
            binary = mozinstall.get_binary(path, "firefox")
        elif platform == "mac":
            binary = find_executable(
                "firefox",
                os.path.join(path, "Firefox Nightly.app", "Contents", "MacOS"))

        return binary
Пример #15
0
 def _install(self, dest):
     self.tempdir = safe_mkdtemp()
     try:
         self.binary = mozinstall.get_binary(
             mozinstall.install(src=dest, dest=self.tempdir), self.app_name)
     except Exception:
         rmtree(self.tempdir)
         raise
Пример #16
0
def binary():
    try:
        return build.get_binary_path()
    except:
        pass

    app = 'firefox'
    bindir = os.path.join(os.environ['PYTHON_TEST_TMP'], app)
    if os.path.isdir(bindir):
        try:
            return mozinstall.get_binary(bindir, app_name=app)
        except:
            pass

    if 'GECKO_INSTALLER_URL' in os.environ:
        bindir = mozinstall.install(os.environ['GECKO_INSTALLER_URL'],
                                    os.environ['PYTHON_TEST_TMP'])
        return mozinstall.get_binary(bindir, app_name='firefox')
Пример #17
0
 def _install(self, dest):
     self.tempdir = tempfile.mkdtemp()
     try:
         self.binary = mozinstall.get_binary(
             mozinstall.install(src=dest, dest=self.tempdir),
             self.app_name
         )
     except:
         rmtree(self.tempdir)
         raise
Пример #18
0
def binary():
    """Return a Firefox binary"""
    try:
        return build.get_binary_path()
    except Exception:
        pass

    app = 'firefox'
    bindir = os.path.join(os.environ['PYTHON_TEST_TMP'], app)
    if os.path.isdir(bindir):
        try:
            return mozinstall.get_binary(bindir, app_name=app)
        except Exception:
            pass

    if 'GECKO_INSTALLER_URL' in os.environ:
        bindir = mozinstall.install(
            os.environ['GECKO_INSTALLER_URL'], os.environ['PYTHON_TEST_TMP'])
        return mozinstall.get_binary(bindir, app_name='firefox')
Пример #19
0
    def prepare_application(self, binary):
        # Prepare the binary for the test run
        if mozinstall.is_installer(self.binary):
            install_path = tempfile.mkdtemp(".binary")

            print "Install build: %s" % self.binary
            self._folder = mozinstall.install(self.binary, install_path)
            self._application = mozinstall.get_binary(self._folder, self.options.application)
        else:
            if os.path.isdir(self.binary):
                self._folder = self.binary
            else:
                if sys.platform == "darwin":
                    # Ensure that self._folder is the app bundle on OS X
                    p = re.compile(".*\.app/")
                    self._folder = p.search(self.binary).group()
                else:
                    self._folder = os.path.dirname(self.binary)

            self._application = mozinstall.get_binary(self._folder, self.options.application)
Пример #20
0
    def test_get_binary(self):
        """ Test mozinstall's get_binary method """

        if mozinfo.isLinux:
            installdir = mozinstall.install(self.bz2, self.tempdir)
            binary = os.path.join(installdir, "firefox")
            self.assertEqual(binary, mozinstall.get_binary(installdir, "firefox"))

        elif mozinfo.isWin:
            installdir_exe = mozinstall.install(self.exe, os.path.join(self.tempdir, "exe"))
            binary_exe = os.path.join(installdir_exe, "firefox", "firefox", "firefox.exe")
            self.assertEqual(binary_exe, mozinstall.get_binary(installdir_exe, "firefox"))

            installdir_zip = mozinstall.install(self.zipfile, os.path.join(self.tempdir, "zip"))
            binary_zip = os.path.join(installdir_zip, "firefox.exe")
            self.assertEqual(binary_zip, mozinstall.get_binary(installdir_zip, "firefox"))

        elif mozinfo.isMac:
            installdir = mozinstall.install(self.dmg, self.tempdir)
            binary = os.path.join(installdir, "Contents", "MacOS", "firefox")
            self.assertEqual(binary, mozinstall.get_binary(installdir, "firefox"))
Пример #21
0
    def prepare_application(self, binary):
        # Prepare the binary for the test run
        if mozinstall.is_installer(self.binary):
            install_path = tempfile.mkdtemp(".binary")

            print "Install build: %s" % self.binary
            self._folder = mozinstall.install(self.binary, install_path)
            self._application = mozinstall.get_binary(self._folder,
                                                      self.options.application)
        else:
            if os.path.isdir(self.binary):
                self._folder = self.binary
            else:
                if sys.platform == "darwin":
                    # Ensure that self._folder is the app bundle on OS X
                    p = re.compile('.*\.app/')
                    self._folder = p.search(self.binary).group()
                else:
                    self._folder = os.path.dirname(self.binary)

            self._application = mozinstall.get_binary(self._folder,
                                                      self.options.application)
Пример #22
0
def firefox(pytestconfig, tmpdir_factory):
    binary = pytestconfig.getoption('firefox')
    if binary is None:
        cache_dir = str(pytestconfig.cache.makedir('firefox'))
        scraper = FactoryScraper('daily', destination=cache_dir)
        build_path = scraper.download()
        install_path = str(tmpdir_factory.mktemp('firefox'))
        install_dir = mozinstall.install(src=build_path, dest=install_path)
        binary = mozinstall.get_binary(install_dir, 'firefox')
    version = mozversion.get_version(binary)
    if hasattr(pytestconfig, '_metadata'):
        pytestconfig._metadata.update(version)
    return binary
Пример #23
0
def firefox(pytestconfig, tmpdir_factory):
    binary = os.getenv('MOZREGRESSION_BINARY',
                       pytestconfig.getoption('firefox'))
    if binary is None:
        cache_dir = str(pytestconfig.cache.makedir('firefox'))
        scraper = FactoryScraper('daily', destination=cache_dir)
        build_path = scraper.download()
        install_path = str(tmpdir_factory.mktemp('firefox'))
        install_dir = mozinstall.install(src=build_path, dest=install_path)
        binary = mozinstall.get_binary(install_dir, 'firefox')
    version = mozversion.get_version(binary)
    if hasattr(pytestconfig, '_metadata'):
        pytestconfig._metadata.update(version)
    return binary
Пример #24
0
def fixture_binary():
    """Return a Firefox binary"""
    try:
        return build.get_binary_path()
    except Exception:
        print(str(Exception))

    app = "firefox"
    bindir = os.path.join(os.environ["PYTHON_TEST_TMP"], app)
    if os.path.isdir(bindir):
        try:
            return mozinstall.get_binary(bindir, app_name=app)
        except Exception:
            print(str(Exception))

    if "GECKO_BINARY_PATH" in os.environ:
        return os.environ["GECKO_BINARY_PATH"]
Пример #25
0
def binary():
    """Return a Firefox binary"""
    try:
        return build.get_binary_path()
    except Exception:
        pass

    app = 'firefox'
    bindir = os.path.join(os.environ['PYTHON_TEST_TMP'], app)
    if os.path.isdir(bindir):
        try:
            return mozinstall.get_binary(bindir, app_name=app)
        except Exception:
            pass

    if 'GECKO_BINARY_PATH' in os.environ:
        return os.environ['GECKO_BINARY_PATH']
Пример #26
0
    def find_binary_path(self,path=None, channel="nightly"):
        """Looks for the firefox binary in the virtual environment"""

        if path is None:
            #os.getcwd() doesn't include the venv path
            path = os.path.join(os.getcwd(), "_venv", "browsers", channel)

        binary = None

        if self.platform == "linux":
            binary = find_executable("firefox", os.path.join(path, "firefox"))
        elif self.platform == "win":
            import mozinstall
            binary = mozinstall.get_binary(path, "firefox")
        elif self.platform == "macos":
            binary = find_executable("firefox", os.path.join(path, self.application_name.get(channel, "Firefox Nightly.app"),
                                                             "Contents", "MacOS"))

        return binary
Пример #27
0
        def _run_tests(manifest):
            target_folder = None

            try:
                target_folder = self.duplicate_application(source_folder)
                self.bin = mozinstall.get_binary(target_folder, 'Firefox')

                FirefoxUITestRunner.run_tests(self, [manifest])

            except Exception:
                self.exc_info = sys.exc_info()
                self.logger.error('Failure during execution of the update test.',
                                  exc_info=self.exc_info)

            finally:
                self.logger.info('Removing copy of the application at "%s"' % target_folder)
                try:
                    mozfile.remove(target_folder)
                except IOError as e:
                    self.logger.error('Cannot remove copy of application: "%s"' % str(e))
Пример #28
0
        def _run_tests(manifest):
            target_folder = None

            try:
                target_folder = self.duplicate_application(source_folder)
                self.bin = mozinstall.get_binary(target_folder, 'Firefox')

                FirefoxUITestRunner.run_tests(self, [manifest])

            except Exception:
                self.exc_info = sys.exc_info()
                self.logger.error('Failure during execution of the update test.',
                                  exc_info=self.exc_info)

            finally:
                self.logger.info('Removing copy of the application at "%s"' % target_folder)
                try:
                    mozfile.remove(target_folder)
                except IOError as e:
                    self.logger.error('Cannot remove copy of application: "%s"' % str(e))
Пример #29
0
    def setup_env(self):
        # Download the build and tests package
        self.build = self.download(url=self.build_url)
        self.packaged_tests = self.download(url=self.tests_url)

        # Unzip the packaged tests
        with zipfile.ZipFile(self.packaged_tests) as zip:
            zip.extractall('tests')

        # Create the virtual environment
        current_location = os.getcwd()
        create_venv_script = os.path.abspath(os.path.join('tests', 'tps',
                                                          'create_venv.py'))
        tps_env = os.path.abspath('tps-env')

        # Bug 1030768, setup.py has to be called from it's own location
        os.chdir(os.path.abspath(os.path.join('tests', 'tps')))

        subprocess.check_call(['python', create_venv_script,
                               '--username', self.username,
                               '--password', self.password, tps_env])
        os.chdir(current_location)

        dir = 'Scripts' if sys.platform == 'win32' else 'bin'
        env_activate_file = os.path.join(tps_env, dir, 'activate_this.py')

        # Activate the environment and set the VIRTUAL_ENV os variable
        execfile(env_activate_file, dict(__file__=env_activate_file))
        os.environ['VIRTUAL_ENV'] = tps_env

        # Install the fxa-python-client
        subprocess.check_call(['pip', 'install', 'fxa-python-client'])

        # After activating the environment we import the mozinstall module
        import mozinstall

        # Install Firefox and get the binary
        self.build_path = mozinstall.install(self.build,
                                             os.path.join(current_location,
                                                          'binary'))
        self.binary = mozinstall.get_binary(self.build_path, 'firefox')
Пример #30
0
def find_firefox(context):
    """Try to automagically find the firefox binary."""
    import mozinstall
    search_paths = []

    # Check for a mozharness setup
    config = context.mozharness_config
    if config and 'binary_path' in config:
        return config['binary_path']
    elif config:
        search_paths.append(os.path.join(context.mozharness_workdir, 'application'))

    # Check for test-stage setup
    dist_bin = os.path.join(os.path.dirname(context.package_root), 'bin')
    if os.path.isdir(dist_bin):
        search_paths.append(dist_bin)

    for path in search_paths:
        try:
            return mozinstall.get_binary(path, 'firefox')
        except mozinstall.InvalidBinary:
            continue
Пример #31
0
def startTestRunner(runner_class, options, tests):
    install_folder = None

    try:
        # Prepare the workspace path so that all temporary data can be stored inside it.
        if options.workspace_path:
            path = os.path.expanduser(options.workspace_path)
            options.workspace = os.path.abspath(path)

            if not os.path.exists(options.workspace):
                os.makedirs(options.workspace)
        else:
            options.workspace = tempfile.mkdtemp('.{}'.format(
                os.path.basename(sys.argv[0])))

        options.logger.info('Using workspace for temporary data: "{}"'.format(
            options.workspace))

        # If the specified binary is an installer it needs to be installed
        if options.installer:
            installer = os.path.realpath(options.installer)

            dest_folder = os.path.join(options.workspace, 'binary')
            options.logger.info('Installing application "%s" to "%s"' %
                                (installer, dest_folder))
            install_folder = mozinstall.install(installer, dest_folder)
            options.binary = mozinstall.get_binary(install_folder, 'firefox')

        runner = runner_class(**vars(options))
        runner.run_tests(tests)

    finally:
        # Ensure to uninstall the binary if it has been installed before
        if install_folder and os.path.exists(install_folder):
            options.logger.info('Uninstalling application at "%s"' %
                                install_folder)
            mozinstall.uninstall(install_folder)

    return runner
Пример #32
0
def find_firefox(context):
    """Try to automagically find the firefox binary."""
    import mozinstall
    search_paths = []

    # Check for a mozharness setup
    if context.mozharness_config:
        with open(context.mozharness_config, 'r') as f:
            config = json.load(f)
        workdir = os.path.join(config['base_work_dir'], config['work_dir'])
        search_paths.append(os.path.join(workdir, 'application'))

    # Check for test-stage setup
    dist_bin = os.path.join(os.path.dirname(context.package_root), 'bin')
    if os.path.isdir(dist_bin):
        search_paths.append(dist_bin)

    for path in search_paths:
        try:
            return mozinstall.get_binary(path, 'firefox')
        except mozinstall.InvalidBinary:
            continue
Пример #33
0
def find_firefox(context):
    """Try to automagically find the firefox binary."""
    import mozinstall
    search_paths = []

    # Check for a mozharness setup
    config = context.mozharness_config
    if config and 'binary_path' in config:
        return config['binary_path']
    elif config:
        search_paths.append(os.path.join(context.mozharness_workdir, 'application'))

    # Check for test-stage setup
    dist_bin = os.path.join(os.path.dirname(context.package_root), 'bin')
    if os.path.isdir(dist_bin):
        search_paths.append(dist_bin)

    for path in search_paths:
        try:
            return mozinstall.get_binary(path, 'firefox')
        except mozinstall.InvalidBinary:
            continue
Пример #34
0
def startTestRunner(runner_class, options, tests):
    install_folder = None

    try:
        # If the specified binary is an installer it needs to be installed
        if options.installer:
            installer = os.path.realpath(options.installer)

            dest_folder = tempfile.mkdtemp()
            options.logger.info('Installing application "%s" to "%s"' % (installer,
                                                                         dest_folder))
            install_folder = mozinstall.install(installer, dest_folder)
            options.binary = mozinstall.get_binary(install_folder, 'firefox')

        runner = runner_class(**vars(options))
        runner.run_tests(tests)

    finally:
        # Ensure to uninstall the binary if it has been installed before
        if install_folder and os.path.exists(install_folder):
            options.logger.info('Uninstalling application at "%s"' % install_folder)
            mozinstall.uninstall(install_folder)

    return runner
Пример #35
0
            self._repository.clone()
        except Exception, e:
            raise Exception("Failure in setting up the mozmill-tests repository. " +
                            e.message)

        if self.options.addons:
            self.prepare_addons()

        try:
            # Prepare the binary for the test run
            if mozinstall.is_installer(self.binary):
                install_path = tempfile.mkdtemp(".binary")
    
                print "Install build: %s" % self.binary
                self._folder = mozinstall.install(self.binary, install_path)
                self._application = mozinstall.get_binary(self._folder,
                                                          self.options.application)
            else:
                # TODO: Ensure that self._folder is the same as from mozinstall
                folder = os.path.dirname(self.binary)
                self._folder = folder if not os.path.isdir(self.binary) else self.binary
                self._application = self.binary

            # Prepare the repository
            ini = application.ApplicationIni(self._application)
            repository_url = ini.get('App', 'SourceRepository')
    
            # Update the mozmill-test repository to match the Gecko branch
            branch_name = self._repository.identify_branch(repository_url)
            self._repository.update(branch_name)

            # instantiate handlers
#!/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import os

from mozdownload import FactoryScraper
import mozinstall

scraper = FactoryScraper('daily',
                         branch=os.environ['MOZ_BRANCH'],
                         locale=os.environ['LOCALE'])
installer_path = scraper.download()

install_path = mozinstall.install(installer_path, 'application')
binary_path = mozinstall.get_binary(install_path, 'firefox')

with open('binary.txt', 'w') as f:
    f.write(binary_path)
Пример #37
0
 def _install(self, dest):
     self.tempdir = tempfile.mkdtemp()
     self.binary = mozinstall.get_binary(
         mozinstall.install(src=dest, dest=self.tempdir),
         self.app_name)
Пример #38
0
import mozinstall
import os
import sys
import tempfile

tempdir = tempfile.mkdtemp()
firefox_exe = sys.argv[1]

install_folder = mozinstall.install(src=firefox_exe, dest=tempdir)
binary = mozinstall.get_binary(install_folder, 'Firefox')

if not os.path.exists("build"):
    os.makedirs("build")

f = open("build/fflocation.bat", "w")
f.write("set FIREFOX_BINARY=%s" % binary)
f.close()
f = open("build/fflocation.txt", "w")
f.write(binary)
f.close()
f = open("build/templocation.txt", "w")
f.write(tempdir)
f.close()
Пример #39
0
    def get_test_candidate(self):
        """Download and extract a build candidate.

        Build may either refer to a Firefox release identifier, package, or build directory.
        :param:
            build: str with firefox build
        :return:
            Installation path for the Firefox App
        """

        location = ''
        candidate_app = ''

        if self.args.firefox == 'local':
            if Settings.is_mac():
                location = '/Applications/Firefox.app/Contents/'
                candidate_app = os.path.join(location, 'MacOS', 'firefox')
            elif Settings.is_windows():
                location = 'C:\\Program Files (x86)\\Mozilla Firefox'
                if not os.path.exists(location):
                    location = 'C:\\Program Files\\Mozilla Firefox'
                    candidate_app = os.path.join(location, 'firefox.exe')
            elif Settings.is_linux():
                location = '/usr/lib/firefox'
                candidate_app = os.path.join(location, 'firefox')
            else:
                logger.critical('Platform not supported')
                self.finish(code=5)

            if not os.path.isdir(location):
                logger.critical(
                    'Firefox not found. Please download if from https://www.mozilla.org/en-US/firefox/new/'
                )
                self.finish(code=5)

            return candidate_app

        else:
            try:
                locale = 'ja-JP-mac' if self.args.locale == 'ja' and Settings.is_mac(
                ) else self.args.locale
                type, scraper_details = get_scraper_details(
                    self.args.firefox, Settings.CHANNELS,
                    os.path.join(IrisCore.get_working_dir(), 'cache'), locale)
                scraper = FactoryScraper(type, **scraper_details)

                firefox_dmg = scraper.download()
                install_folder = install(src=firefox_dmg,
                                         dest=IrisCore.get_current_run_dir())

                binary = get_binary(install_folder, 'Firefox')

                channel = get_firefox_channel(binary)
                latest_type, latest_scraper_details = get_latest_scraper_details(
                    channel)
                latest_path = FactoryScraper(latest_type,
                                             **latest_scraper_details).filename

                self.latest_version = get_version_from_path(latest_path)
                logger.info('Latest available version for %s channel is: %s' %
                            (channel, self.latest_version))

                return binary
            except errors.NotFoundError:
                logger.critical(
                    'Specified build (%s) has not been found. Closing Iris ...'
                    % self.args.firefox)
                self.finish(5)
Пример #40
0
 def _install(self, dest):
     self.tempdir = tempfile.mkdtemp()
     self.binary = mozinstall.get_binary(
         mozinstall.install(src=dest, dest=self.tempdir), self.app_name)