def _set_binary(self, build):
        """ Sets the list of binaries to test. """
        self._binary = None

        build = os.path.abspath(build)

        if not os.path.exists(build):
            raise errors.NotFoundException('Path cannot be found', build)

        # Check if it's an installer or an already installed build
        # We have to custom checks via application.is_app_folder as long as
        # mozinstall can't check for an installer (bug 795288)
        if application.is_installer(build, self.options.application) or \
                application.is_app_folder(build):
            self._binary = build
            return

        # Otherwise recursively scan the folder and select the first found build
        for root, dirs, files in os.walk(build):
            # Ensure we select the build by alphabetical order
            files.sort()

            for f in files:
                if not f in [".DS_Store"] and \
                        application.is_installer(f, self.options.application):
                    self._binary = os.path.abspath(os.path.join(root, f))
                    return
Example #2
0
    def _set_binary(self, build):
        """ Sets the list of binaries to test. """
        self._binary = None

        build = os.path.abspath(build)

        if not os.path.exists(build):
            raise errors.NotFoundException('Path cannot be found', build)

        # Check if it's an installer or an already installed build
        # We have to custom checks via application.is_app_folder as long as
        # mozinstall can't check for an installer (bug 795288)
        if application.is_installer(build, self.options.application) or \
                application.is_app_folder(build):
            self._binary = build
            return

        # Otherwise recursivily scan the folder and select the first found build
        for root, dirs, files in os.walk(build):
            # Ensure we select the build by alphabetical order
            files.sort()

            for f in files:
                if not f in [".DS_Store"] and \
                        application.is_installer(f, self.options.application):
                    self._binary = os.path.abspath(os.path.join(root, f))
                    return
    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)
Example #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')

            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)
Example #5
0
    def prepare_binary(self, binary):
        """ Prepare the binary for the test run. """

        if application.is_installer(self.options.application, binary):
            install_path = tempfile.mkdtemp(".binary")
            self._folder = install.Installer().install(binary, install_path)
            self._application = application.get_binary(self.options.application, self._folder)
        else:
            folder = os.path.dirname(binary)
            self._folder = folder if not os.path.isdir(binary) else binary
            self._application = binary
Example #6
0
    def _set_binaries(self, value):
        """ Sets the list of binaries to test. """
        self._binaries = [ ]

        if not value:
            return

        for path in value:
            if not os.path.exists(path):
                raise Exception("Path '%s' cannot be found." % (path))

            # Check if it's an installer or an already installed build
            if application.is_installer(self.options.application, path) or \
               application.is_app_folder(path):
                self._binaries.append(os.path.abspath(path))
                continue
            # Otherwise recursivily scan the folder and add existing files
            for root, dirs, files in os.walk(path):
                for file in files:
                    if not file in [".DS_Store"] and \
                    application.is_installer(self.options.application, file):
                        self._binaries.append(os.path.abspath(os.path.join(root, file)))
Example #7
0
    def prepare_binary(self, binary):
        """ Prepare the binary for the test run. """

        if application.is_installer(self.options.application, binary):
            install_path = tempfile.mkdtemp(".binary")
            self._folder = install.Installer().install(binary, install_path)
            self._application = application.get_binary(self.options.application, self._folder)
        else:
            folder = os.path.dirname(binary)
            self._folder = folder if not os.path.isdir(binary) else binary
            self._application = binary

        # Print application details
        ini = application.ApplicationIni(self._folder)
        print '*** Application: %s %s' % (
            ini.get('App', 'Name'),
            ini.get('App', 'Version'))
Example #8
0
    def prepare_application(self, binary):
        # Prepare the binary for the test run
        if application.is_installer(self.binary, self.options.application):
            install_path = tempfile.mkdtemp(".binary")

            print "*** Installing 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)
    def prepare_application(self, binary):
        # Prepare the binary for the test run
        if application.is_installer(self.binary, self.options.application):
            install_path = tempfile.mkdtemp(".binary")

            print "*** Installing 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)
            if self.options.addons:
                self.prepare_addons()

            path = os.path.join(self.workspace, 'screenshots')
            if not os.path.isdir(path):
                os.makedirs(path)
            self.persisted["screenshotPath"] = path

            self.run_tests()

        except Exception, e:
            self.exception_type, self.exception, self.tb = sys.exc_info()

        finally:
            # Remove the build when it has been installed before
            if application.is_installer(self.binary, self.options.application):
                print "*** Uninstalling build: %s" % self._folder
                mozinstall.uninstall(self._folder)

            self.remove_downloaded_addons()

            # Remove the temporarily cloned repository
            print "*** Removing test repository '%s'" % self.repository.path
            self.repository.remove()

            # If an exception has been thrown, print it here and exit with status 3.
            # Giving that we save reports with failing tests, this one has priority
            if self.exception_type:
                traceback.print_exception(self.exception_type, self.exception, self.tb)
                raise errors.TestrunAbortedException(self)
Example #11
0
            if self.options.screenshot_path:
                path = os.path.abspath(self.options.screenshot_path)
                if not os.path.isdir(path):
                    os.makedirs(path)
                self.persisted["screenshotPath"] = path

            self.run_tests()

        except Exception, e:
            exception_type, exception, tb = sys.exc_info()
            traceback.print_exception(exception_type, exception, tb)

        finally:
            # Remove the build when it has been installed before
            if application.is_installer(self.binary, self.options.application):
                print "*** Uninstalling build: %s" % self._folder
                mozinstall.uninstall(self._folder)

            self.remove_downloaded_addons()

            # Remove the temporarily cloned repository
            print "*** Removing test repository '%s'" % self.repository.path
            self.repository.remove()

            # If a test has been failed ensure that we exit with status 2
            if self.last_failed_tests:
                raise errors.TestFailedException()


class AddonsTestRun(TestRun):
Example #12
0
 def cleanup_binary(self, binary):
     """ Remove the build when it has been installed before. """
     if application.is_installer(self.options.application, binary):
         install.Installer().uninstall(self._folder)