Example #1
0
 def _do_test_linkify(self, expected_link, url, memo=None):
     memo = {} if memo is None else memo
     s = 'foo {} bar'.format(url)
     expected = 'foo <a target="_blank" href="{}">{}</a> bar'.format(
         expected_link, url)
     linkified = linkify(self._buildroot, s, memo)
     self.assertEqual(expected, linkified)
Example #2
0
    def start_workunit(self, workunit):
        """Implementation of Reporter callback."""
        # We use these properties of the workunit to decide how to render information about it.
        is_bootstrap = workunit.has_label(WorkUnitLabel.BOOTSTRAP)
        is_tool = workunit.has_label(WorkUnitLabel.TOOL)
        is_multitool = workunit.has_label(WorkUnitLabel.MULTITOOL)
        is_test = workunit.has_label(WorkUnitLabel.TEST)

        # Get useful properties from the workunit.
        workunit_dict = workunit.to_dict()
        if workunit_dict['cmd']:
            workunit_dict['cmd'] = linkify(
                self._buildroot, workunit_dict['cmd'].replace('$', '\\\\$'),
                self._linkify_memo)

        # Create the template arguments.
        args = {
            'indent':
            len(workunit.ancestors()) * 10,
            'html_path_base':
            self._html_path_base,
            'workunit':
            workunit_dict,
            'header_text':
            workunit.name,
            'initially_open':
            is_test or not (is_bootstrap or is_tool or is_multitool),
            'is_tool':
            is_tool,
            'is_multitool':
            is_multitool
        }
        args.update({
            'collapsible':
            lambda x: self._renderer.render_callable('collapsible', x, args)
        })

        # Render the workunit's div.
        s = self._renderer.render_name('workunit_start', args)

        if is_tool:
            # This workunit is a tool invocation, so render the appropriate content.
            # We use the same args, slightly modified.
            del args['initially_open']
            if is_test:
                # Have test framework stdout open by default, but not that of other tools.
                # This is an arbitrary choice, but one that turns out to be useful to users in practice.
                args['stdout_initially_open'] = True
            s += self._renderer.render_name('tool_invocation_start', args)

        # ... and we're done.
        self._emit(s)
Example #3
0
    def start_workunit(self, workunit):
        """Implementation of Reporter callback."""
        # We use these properties of the workunit to decide how to render information about it.
        is_bootstrap = workunit.has_label(WorkUnitLabel.BOOTSTRAP)
        is_tool = workunit.has_label(WorkUnitLabel.TOOL)
        is_multitool = workunit.has_label(WorkUnitLabel.MULTITOOL)
        is_test = workunit.has_label(WorkUnitLabel.TEST)

        initially_open = is_test or not (is_bootstrap or is_tool
                                         or is_multitool)

        # Render the workunit's div.
        s = self._start_workunit_fmt_string.format(
            indent=len(workunit.ancestors()) * 10,
            id=workunit.id,
            parent_id=workunit.parent.id if workunit.parent
            and not self.run_tracker.is_background_root_workunit(workunit) else
            "",
            workunit=workunit,
            icon_caret="down" if initially_open else "right",
            display_class="" if initially_open else "nodisplay",
            icon="cog" if is_tool else "cogs" if is_multitool else "none",
        )
        self._emit(s)

        if is_tool:
            tool_invocation_details = "\n".join([
                self._render_tool_detail(workunit=workunit,
                                         title="cmd",
                                         class_prefix="cmd"),
                # Have test framework stdout open by default, but not that of other tools.
                # This is an arbitrary choice, but one that turns out to be useful to users in practice.
                self._render_tool_detail(workunit=workunit,
                                         title="stdout",
                                         initially_open=is_test),
                self._render_tool_detail(workunit=workunit, title="stderr"),
            ])

            cmd = workunit.cmd or ""
            linkified_cmd = linkify(self._buildroot, cmd.replace("$", "\\\\$"),
                                    self._linkify_memo)

            s = self._start_tool_invocation_fmt_string.format(
                tool_invocation_details=tool_invocation_details,
                html_path_base=self._html_path_base,
                id=workunit.id,
                cmd=linkified_cmd,
            )

            self._emit(s)
Example #4
0
    def start_workunit(self, workunit):
        """Implementation of Reporter callback."""
        # We use these properties of the workunit to decide how to render information about it.
        is_bootstrap = workunit.has_label(WorkUnitLabel.BOOTSTRAP)
        is_tool = workunit.has_label(WorkUnitLabel.TOOL)
        is_multitool = workunit.has_label(WorkUnitLabel.MULTITOOL)
        is_test = workunit.has_label(WorkUnitLabel.TEST)

        initially_open = is_test or not (is_bootstrap or is_tool
                                         or is_multitool)

        # Render the workunit's div.
        s = self._start_workunit_fmt_string.format(
            indent=len(workunit.ancestors()) * 10,
            id=workunit.id,
            parent_id=workunit.parent.id if workunit.parent else '',
            workunit=workunit,
            icon_caret='down' if initially_open else 'right',
            display_class='' if initially_open else 'nodisplay',
            icon='cog' if is_tool else 'cogs' if is_multitool else 'none')
        self._emit(s)

        if is_tool:
            tool_invocation_details = '\n'.join([
                self._render_tool_detail(workunit=workunit,
                                         title='cmd',
                                         class_prefix='cmd'),
                # Have test framework stdout open by default, but not that of other tools.
                # This is an arbitrary choice, but one that turns out to be useful to users in practice.
                self._render_tool_detail(workunit=workunit,
                                         title='stdout',
                                         initially_open=is_test),
                self._render_tool_detail(workunit=workunit, title='stderr'),
            ])

            cmd = workunit.cmd or ''
            linkified_cmd = linkify(self._buildroot, cmd.replace('$', '\\\\$'),
                                    self._linkify_memo)

            s = self._start_tool_invocation_fmt_string.format(
                tool_invocation_details=tool_invocation_details,
                html_path_base=self._html_path_base,
                id=workunit.id,
                cmd=linkified_cmd)

            self._emit(s)
Example #5
0
  def start_workunit(self, workunit):
    """Implementation of Reporter callback."""
    # We use these properties of the workunit to decide how to render information about it.
    is_bootstrap = workunit.has_label(WorkUnitLabel.BOOTSTRAP)
    is_tool = workunit.has_label(WorkUnitLabel.TOOL)
    is_multitool = workunit.has_label(WorkUnitLabel.MULTITOOL)
    is_test = workunit.has_label(WorkUnitLabel.TEST)

    initially_open = is_test or not (is_bootstrap or is_tool or is_multitool)

    # Render the workunit's div.
    s = self._start_workunit_fmt_string.format(
      indent=len(workunit.ancestors()) * 10,
      id=workunit.id,
      parent_id=workunit.parent.id if workunit.parent else '',
      workunit=workunit,
      icon_caret='down' if initially_open else 'right',
      display_class='' if initially_open else 'nodisplay',
      icon='cog' if is_tool else 'cogs' if is_multitool else 'none'
    )
    self._emit(s)

    if is_tool:
      tool_invocation_details = '\n'.join([
        self._render_tool_detail(workunit=workunit, title='cmd', class_prefix='cmd'),
        # Have test framework stdout open by default, but not that of other tools.
        # This is an arbitrary choice, but one that turns out to be useful to users in practice.
        self._render_tool_detail(workunit=workunit, title='stdout', initially_open=is_test),
        self._render_tool_detail(workunit=workunit, title='stderr'),
      ])

      cmd = workunit.cmd or ''
      linkified_cmd = linkify(self._buildroot, cmd.replace('$', '\\\\$'), self._linkify_memo)

      s = self._start_tool_invocation_fmt_string.format(
        tool_invocation_details=tool_invocation_details,
        html_path_base=self._html_path_base,
        id=workunit.id,
        cmd=linkified_cmd
      )

      self._emit(s)
Example #6
0
  def start_workunit(self, workunit):
    """Implementation of Reporter callback."""
    # We use these properties of the workunit to decide how to render information about it.
    is_bootstrap = workunit.has_label(WorkUnit.BOOTSTRAP)
    is_tool = workunit.has_label(WorkUnit.TOOL)
    is_multitool = workunit.has_label(WorkUnit.MULTITOOL)
    is_test = workunit.has_label(WorkUnit.TEST)

    # Get useful properties from the workunit.
    workunit_dict = workunit.to_dict()
    if workunit_dict['cmd']:
      workunit_dict['cmd'] = linkify(self._buildroot, workunit_dict['cmd'].replace('$', '\\\\$'),
                                     self._linkify_memo)

    # Create the template arguments.
    args = { 'indent': len(workunit.ancestors()) * 10,
             'html_path_base': self._html_path_base,
             'workunit': workunit_dict,
             'header_text': workunit.name,
             'initially_open': is_test or not (is_bootstrap or is_tool or is_multitool),
             'is_tool': is_tool,
             'is_multitool': is_multitool }
    args.update({ 'collapsible': lambda x: self._renderer.render_callable('collapsible', x, args) })

    # Render the workunit's div.
    s = self._renderer.render_name('workunit_start', args)

    if is_tool:
      # This workunit is a tool invocation, so render the appropriate content.
      # We use the same args, slightly modified.
      del args['initially_open']
      if is_test:
        # Have test framework stdout open by default, but not that of other tools.
        # This is an arbitrary choice, but one that turns out to be useful to users in practice.
        args['stdout_initially_open'] = True
      s += self._renderer.render_name('tool_invocation_start', args)

    # ... and we're done.
    self._emit(s)
Example #7
0
 def _do_test_not_linkified(self, url, memo=None):
   memo = {} if memo is None else memo
   s = 'foo {} bar'.format(url)
   linkified = linkify(self._buildroot, s, memo)
   self.assertEqual(s, linkified)
Example #8
0
 def _do_test_linkify(self, expected_link, url, memo=None):
   memo = {} if memo is None else memo
   s = f'foo {url} bar'
   expected = f'foo <a target="_blank" href="{expected_link}">{url}</a> bar'
   linkified = linkify(self._buildroot, s, memo)
   self.assertEqual(expected, linkified)
Example #9
0
 def _htmlify_text(self, s):
   """Make text HTML-friendly."""
   colored = self._handle_ansi_color_codes(cgi.escape(s.decode('utf-8')))
   return linkify(self._buildroot, colored, self._linkify_memo).replace('\n', '</br>')
Example #10
0
 def _htmlify_text(self, s):
     """Make text HTML-friendly."""
     colored = self._handle_ansi_color_codes(cgi.escape(s.decode('utf-8')))
     return linkify(self._buildroot, colored,
                    self._linkify_memo).replace('\n', '</br>')
Example #11
0
 def _do_test_linkify(self, expected_link, url):
   s = 'foo %s bar' % url
   expected = 'foo <a target="_blank" href="%s">%s</a> bar' % (expected_link, url)
   linkified = linkify(self._buildroot, s)
   self.assertEqual(expected, linkified)
Example #12
0
 def _do_test_not_linkified(self, url, memo=None):
   memo = {} if memo is None else memo
   s = 'foo {} bar'.format(url)
   linkified = linkify(self._buildroot, s, memo)
   self.assertEqual(s, linkified)
Example #13
0
 def _do_test_linkify(self, expected_link, url, memo=None):
   memo = {} if memo is None else memo
   s = 'foo {} bar'.format(url)
   expected = 'foo <a target="_blank" href="{}">{}</a> bar'.format(expected_link, url)
   linkified = linkify(self._buildroot, s, memo)
   self.assertEqual(expected, linkified)
Example #14
0
 def _htmlify_text(self, s):
     """Make text HTML-friendly."""
     colored = self._handle_ansi_color_codes(html.escape(s))
     return linkify(self._buildroot, colored,
                    self._linkify_memo).replace("\n", "</br>")
Example #15
0
 def _do_test_linkify(self, expected_link, url):
     s = 'foo %s bar' % url
     expected = 'foo <a target="_blank" href="%s">%s</a> bar' % (
         expected_link, url)
     linkified = linkify(self._buildroot, s)
     self.assertEqual(expected, linkified)
Example #16
0
 def _do_test_not_linkified(self, url, memo=None):
     memo = {} if memo is None else memo
     s = f"foo {url} bar"
     linkified = linkify(self._buildroot, s, memo)
     self.assertEqual(s, linkified)