Ejemplo n.º 1
0
 def _builder_to_analyze(self):
     statuses = self._tool.buildbot.builder_statuses()
     choices = [status["name"] for status in statuses]
     chosen_name = User.prompt_with_list("Which builder to analyze:", choices)
     for status in statuses:
         if status["name"] == chosen_name:
             return (self._tool.buildbot.builder_with_name(chosen_name), status["built_revision"])
Ejemplo n.º 2
0
    def create_bug(
        self,
        bug_title,
        bug_description,
        component=None,
        diff=None,
        patch_description=None,
        cc=None,
        blocked=None,
        assignee=None,
        mark_for_review=False,
        mark_for_commit_queue=False,
    ):
        self.authenticate()

        _log.info('Creating bug with title "%s"' % bug_title)
        self.browser.open(config_urls.bug_server_url + "enter_bug.cgi?product=WebKit")
        self.browser.select_form(name="Create")
        component_items = self.browser.find_control("component").items
        component_names = map(lambda item: item.name, component_items)
        if not component:
            component = "New Bugs"
        if component not in component_names:
            component = User.prompt_with_list("Please pick a component:", component_names)
        self.browser["component"] = [component]
        if cc:
            self.browser["cc"] = cc
        if blocked:
            self.browser["blocked"] = unicode(blocked)
        if not assignee:
            assignee = self.username
        if assignee and not self.browser.find_control("assigned_to").disabled:
            self.browser["assigned_to"] = assignee
        self.browser["short_desc"] = bug_title
        self.browser["comment"] = bug_description

        if diff:
            # _fill_attachment_form expects a file-like object
            # Patch files are already binary, so no encoding needed.
            assert isinstance(diff, str)
            patch_file_object = StringIO.StringIO(diff)
            commit_flag = CommitQueueFlag.mark_for_nothing
            if mark_for_commit_queue:
                commit_flag = CommitQueueFlag.mark_for_commit_queue

            self._fill_attachment_form(
                patch_description,
                patch_file_object,
                mark_for_review=mark_for_review,
                commit_flag=commit_flag,
                is_patch=True,
            )

        response = self.browser.submit()

        bug_id = self._check_create_bug_response(response.read())
        _log.info("Bug %s created." % bug_id)
        _log.info("%sshow_bug.cgi?id=%s" % (config_urls.bug_server_url, bug_id))
        return bug_id
Ejemplo n.º 3
0
    def create_bug(self,
                   bug_title,
                   bug_description,
                   component=None,
                   diff=None,
                   patch_description=None,
                   cc=None,
                   blocked=None,
                   assignee=None,
                   mark_for_review=False,
                   mark_for_commit_queue=False):
        self.authenticate()

        log('Creating bug with title "%s"' % bug_title)
        if self.dryrun:
            log(bug_description)
            # FIXME: This will make some paths fail, as they assume this returns an id.
            return

        self.browser.open(config_urls.bug_server_url +
                          "enter_bug.cgi?product=WebKit")
        self.browser.select_form(name="Create")
        component_items = self.browser.find_control('component').items
        component_names = map(lambda item: item.name, component_items)
        if not component:
            component = "New Bugs"
        if component not in component_names:
            component = User.prompt_with_list("Please pick a component:",
                                              component_names)
        self.browser["component"] = [component]
        if cc:
            self.browser["cc"] = cc
        if blocked:
            self.browser["blocked"] = unicode(blocked)
        if not assignee:
            assignee = self.username
        if assignee and not self.browser.find_control("assigned_to").disabled:
            self.browser["assigned_to"] = assignee
        self.browser["short_desc"] = bug_title
        self.browser["comment"] = bug_description

        if diff:
            # _fill_attachment_form expects a file-like object
            # Patch files are already binary, so no encoding needed.
            assert (isinstance(diff, str))
            patch_file_object = StringIO.StringIO(diff)
            self._fill_attachment_form(
                patch_description,
                patch_file_object,
                mark_for_review=mark_for_review,
                mark_for_commit_queue=mark_for_commit_queue,
                is_patch=True)

        response = self.browser.submit()

        bug_id = self._check_create_bug_response(response.read())
        log("Bug %s created." % bug_id)
        log("%sshow_bug.cgi?id=%s" % (config_urls.bug_server_url, bug_id))
        return bug_id
Ejemplo n.º 4
0
 def _builder_to_explain(self):
     builder_statuses = self.tool.buildbot.builder_statuses()
     red_statuses = [status for status in builder_statuses if not status["is_green"]]
     print "%s failing" % (pluralize("builder", len(red_statuses)))
     builder_choices = [status["name"] for status in red_statuses]
     # We could offer an "All" choice here.
     chosen_name = User.prompt_with_list("Which builder to diagnose:", builder_choices)
     # FIXME: prompt_with_list should really take a set of objects and a set of names and then return the object.
     for status in red_statuses:
         if status["name"] == chosen_name:
             return (self.tool.buildbot.builder_with_name(chosen_name), status["built_revision"])
Ejemplo n.º 5
0
    def create_bug(self,
                   bug_title,
                   bug_description,
                   component=None,
                   diff=None,
                   patch_description=None,
                   cc=None,
                   blocked=None,
                   mark_for_review=False,
                   mark_for_commit_queue=False):
        self.authenticate()

        log('Creating bug with title "%s"' % bug_title)
        if self.dryrun:
            log(bug_description)
            return

        self.browser.open(self.bug_server_url + "enter_bug.cgi?product=WebKit")
        self.browser.select_form(name="Create")
        component_items = self.browser.find_control('component').items
        component_names = map(lambda item: item.name, component_items)
        if not component:
            component = "New Bugs"
        if component not in component_names:
            component = User.prompt_with_list("Please pick a component:", component_names)
        self.browser["component"] = [component]
        if cc:
            self.browser["cc"] = cc
        if blocked:
            self.browser["blocked"] = unicode(blocked)
        self.browser["short_desc"] = bug_title
        self.browser["comment"] = bug_description

        if diff:
            # _fill_attachment_form expects a file-like object
            # Patch files are already binary, so no encoding needed.
            assert(isinstance(diff, str))
            patch_file_object = StringIO.StringIO(diff)
            self._fill_attachment_form(
                    patch_description,
                    patch_file_object,
                    mark_for_review=mark_for_review,
                    mark_for_commit_queue=mark_for_commit_queue)

        response = self.browser.submit()

        bug_id = self._check_create_bug_response(response.read())
        log("Bug %s created." % bug_id)
        log("%sshow_bug.cgi?id=%s" % (self.bug_server_url, bug_id))
        return bug_id
Ejemplo n.º 6
0
        def run_prompt_test(inputs,
                            expected_result,
                            can_choose_multiple=False):
            def mock_raw_input(message):
                return inputs.pop(0)

            with OutputCapture() as captured:
                actual_result = User.prompt_with_list(
                    'title', ['foo', 'bar'],
                    can_choose_multiple=can_choose_multiple,
                    raw_input=mock_raw_input)
            self.assertEqual(captured.stdout.getvalue(),
                             'title\n 1. foo\n 2. bar\n')
            self.assertEqual(actual_result, expected_result)
            self.assertEqual(len(inputs), 0)