def test_success(self):
        orig_lint_fn = lint_test_expectations.lint

        # unused args pylint: disable=W0613
        def interrupting_lint(host, options, logging_stream):
            raise KeyboardInterrupt

        def successful_lint(host, options, logging_stream):
            return 0

        def exception_raising_lint(host, options, logging_stream):
            assert False

        stdout = StringIO()
        stderr = StringIO()
        try:
            lint_test_expectations.lint = interrupting_lint
            res = lint_test_expectations.main([], stdout, stderr)
            self.assertEqual(res, lint_test_expectations.INTERRUPTED_EXIT_STATUS)

            lint_test_expectations.lint = successful_lint
            res = lint_test_expectations.main(['--platform', 'test'], stdout, stderr)
            self.assertEqual(res, 0)

            lint_test_expectations.lint = exception_raising_lint
            res = lint_test_expectations.main([], stdout, stderr)
            self.assertEqual(res, lint_test_expectations.EXCEPTIONAL_EXIT_STATUS)
        finally:
            lint_test_expectations.lint = orig_lint_fn
示例#2
0
class _CaptureAndPassThroughStream(object):
    def __init__(self, stream):
        self._buffer = StringIO()
        self._stream = stream

    def write(self, msg):
        self._stream.write(msg)

        # Note that we don't want to capture any output generated by the debugger
        # because that could cause the results of capture_output() to be invalid.
        if not self._message_is_from_pdb():
            self._buffer.write(msg)

    def _message_is_from_pdb(self):
        # We will assume that if the pdb module is in the stack then the output
        # is being generated by the python debugger (or the user calling something
        # from inside the debugger).
        import inspect
        import pdb
        stack = inspect.stack()
        return any(frame[1] == pdb.__file__.replace('.pyc', '.py')
                   for frame in stack)

    def flush(self):
        self._stream.flush()

    def getvalue(self):
        return self._buffer.getvalue()
示例#3
0
    def run_and_throw_if_fail(self,
                              args,
                              quiet=False,
                              decode_output=True,
                              **kwargs):
        # Cache the child's output locally so it can be used for error reports.
        child_out_file = StringIO()
        tee_stdout = sys.stdout
        try:
            if quiet:
                dev_null = open(os.devnull,
                                "w")  # FIXME: Does this need an encoding?
                tee_stdout = dev_null
            child_stdout = Tee(child_out_file, tee_stdout)
            exit_code = self._run_command_with_teed_output(
                args, child_stdout, **kwargs)
        finally:
            if quiet:
                dev_null.close()

        child_output = child_out_file.getvalue()
        child_out_file.close()

        if decode_output:
            child_output = string_utils.decode(
                child_output, encoding=self._child_process_encoding())
        else:
            child_output = string_utils.encode(
                child_output, encoding=self._child_process_encoding())

        if exit_code:
            raise ScriptError(script_args=args,
                              exit_code=exit_code,
                              output=child_output)
        return child_output
示例#4
0
    def test_simple_tee(self):
        file1, file2 = StringIO(), StringIO()
        tee = Tee(file1, file2)
        tee.write("foo bar\n")
        tee.write("baz\n")

        self.assertEqual(file1.getvalue(), "foo bar\nbaz\n")
        self.assertEqual(file2.getvalue(), file1.getvalue())
示例#5
0
 def capture_output(self):
     self._logs = StringIO()
     self._logs_handler = logging.StreamHandler(self._logs)
     self._logs_handler.setLevel(self._log_level)
     self._logger = logging.getLogger()
     self._orig_log_level = self._logger.level
     self._logger.addHandler(self._logs_handler)
     self._logger.setLevel(min(self._log_level, self._orig_log_level))
     return (self._capture_output_with_name("stdout"),
             self._capture_output_with_name("stderr"))
示例#6
0
class SkipTest(unittest.TestCase):
    def setUp(self):
        self.logger = logging.getLogger(__name__)

        self.old_level = self.logger.level
        self.logger.setLevel(logging.INFO)

        self.old_propagate = self.logger.propagate
        self.logger.propagate = False

        self.log_stream = StringIO()
        self.handler = logging.StreamHandler(self.log_stream)
        self.logger.addHandler(self.handler)

        self.foo_was_called = False

    def tearDown(self):
        self.logger.removeHandler(self.handler)
        self.propagate = self.old_propagate
        self.logger.setLevel(self.old_level)

    def create_fixture_class(self):
        class TestSkipFixture(object):
            def __init__(self, callback):
                self.callback = callback

            def test_foo(self):
                self.callback()

        return TestSkipFixture

    def foo_callback(self):
        self.foo_was_called = True

    def test_skip_if_false(self):
        klass = skip_if(self.create_fixture_class(),
                        False,
                        'Should not see this message.',
                        logger=self.logger)
        klass(self.foo_callback).test_foo()
        self.assertEqual(self.log_stream.getvalue(), '')
        self.assertTrue(self.foo_was_called)

    def test_skip_if_true(self):
        klass = skip_if(self.create_fixture_class(),
                        True,
                        'Should see this message.',
                        logger=self.logger)
        klass(self.foo_callback).test_foo()
        self.assertEqual(
            self.log_stream.getvalue(),
            'Skipping webkitpy.test.skip_unittest.TestSkipFixture: Should see this message.\n'
        )
        self.assertFalse(self.foo_was_called)
示例#7
0
 def set_short_description_and_bug_url(self, short_description, bug_url):
     result = StringIO()
     with self._filesystem.open_text_file_for_reading(self.path) as file:
         short_description_placeholder = "Need a short description (OOPS!)."
         bug_url_placeholder = "Need the bug URL (OOPS!)."
         for line in file:
             stripped = line.strip()
             if stripped == short_description_placeholder:
                 line = self._changelog_indent + short_description + "\n"
             if stripped == bug_url_placeholder:
                 line = self._changelog_indent + bug_url + "\n"
             result.write(line)
     self._filesystem.write_text_file(self.path, result.getvalue())
    def test_lint_test_files(self):
        logging_stream = StringIO()
        options = optparse.Values({'platform': 'test-mac-leopard'})
        host = MockHost()

        # pylint appears to complain incorrectly about the method overrides pylint: disable=E0202,C0322
        # FIXME: incorrect complaints about spacing pylint: disable=C0322
        host.port_factory.all_port_names = lambda platform=None: [platform]

        res = lint_test_expectations.lint(host, options, logging_stream)

        self.assertEqual(res, 0)
        self.assertIn('Lint succeeded', logging_stream.getvalue())
示例#9
0
    def setUp(self):
        self.logger = logging.getLogger(__name__)

        self.old_level = self.logger.level
        self.logger.setLevel(logging.INFO)

        self.old_propagate = self.logger.propagate
        self.logger.propagate = False

        self.log_stream = StringIO()
        self.handler = logging.StreamHandler(self.log_stream)
        self.logger.addHandler(self.handler)

        self.foo_was_called = False
示例#10
0
 def delete_entries(self, num_entries):
     date_line_regexp = re.compile(ChangeLogEntry.date_line_regexp)
     rolled_over_regexp = re.compile(ChangeLogEntry.rolled_over_regexp)
     entries = 0
     result = StringIO()
     with self._filesystem.open_text_file_for_reading(self.path) as file:
         for line in file:
             if date_line_regexp.match(line):
                 entries += 1
             elif rolled_over_regexp.match(line):
                 entries = num_entries + 1
             if entries > num_entries:
                 result.write(line)
     self._filesystem.write_text_file(self.path, result.getvalue())
示例#11
0
 def test_latest_entry_parse_single_entry(self):
     changelog_contents = u"%s\n%s" % (self._example_entry,
                                       self._rolled_over_footer)
     changelog_file = StringIO(changelog_contents)
     latest_entry = ChangeLog.parse_latest_entry_from_file(changelog_file)
     self.assertEqual(latest_entry.contents(), self._example_entry)
     self.assertEqual(latest_entry.author_name(), "Peter Kasting")
示例#12
0
    def test_read_checksum(self):
        # Test a file with the comment.
        filehandle = StringIO(
            '''\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x03 \x00\x00\x02X\x08\x02\x00\x00\x00\x15\x14\x15'\x00\x00\x00)tEXtchecksum\x003c4134fe2739880353f91c5b84cadbaaC\xb8?\xec\x00\x00\x16\xfeIDATx\x9c\xed\xdd[\x8cU\xe5\xc1\xff\xf15T\x18\x0ea,)\xa6\x80XZ<\x10\n\xd6H\xc4V\x88}\xb5\xa9\xd6r\xd5\x0bki0\xa6\xb5ih\xd2\xde\x98PHz\xd1\x02=\\q#\x01\x8b\xa5rJ\x8b\x88i\xacM\xc5h\x8cbMk(\x1ez@!\x0c\xd5\xd2\xc2\xb44\x1c\x848\x1dF(\xeb\x7f\xb1\xff\xd9\xef~g\xd6\xde3\xe0o\x10\xec\xe7sa6{\xd6z\xd6\xb3\xd7\xf3\xa8_7\xdbM[Y\x96\x05\x00\x009\xc3\xde\xeb\t\x00\x00\xbc\xdf\x08,\x00\x800\x81\x05\x00\x10&\xb0\x00\x00\xc2\x04\x16\x00@\x98\xc0\x02\x00\x08\x13X\x00\x00a\x02\x0b\x00 L
x01\x00\x84\t,\x00\x800\x81\x05\x00\x10\xd64\xb0\xda\x9a\xdb\xb6m\xdb\xb4i\xd3\xfa\x9fr\xf3\xcd7\x0f\xe5T\x07\xe5\xd4\xa9'''
        )
        checksum = read_checksum_from_png.read_checksum(filehandle)
        self.assertEqual('3c4134fe2739880353f91c5b84cadbaa', checksum)

        # Test a file without the comment.
        filehandle = StringIO(
            '''\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x03 \x00\x00\x02X\x08\x02\x00\x00\x00\x15\x14\x15'\x00\x00\x16\xfeIDATx\x9c\xed\xdd[\x8cU\xe5\xc1\xff\xf15T\x18\x0ea,)\xa6\x80XZ<\x10\n\xd6H\xc4V\x88}\xb5\xa9\xd6r\xd5\x0bki0\xa6\xb5ih\xd2\xde\x98PHz\xd1\x02=\\q#\x01\x8b\xa5rJ\x8b\x88i\xacM\xc5h\x8cbMk(\x1ez@!\x0c\xd5\xd2\xc2\xb44\x1c\x848\x1dF(\xeb\x7f\xb1\xff\xd9\xef~g\xd6\xde3\xe0o\x10\xec\xe7sa6{\xd6z\xd6\xb3\xd7\xf3\xa8_7\xdbM[Y\x96\x05\x00\x009\xc3\xde\xeb\t\x00\x00\xbc\xdf\x08,\x00\x800\x81\x05\x00\x10&\xb0\x00\x00\xc2\x04\x16\x00@\x98\xc0\x02\x00\x08\x13X\x00\x00a\x02\x0b\x00 L
x01\x00\x84\t,\x00\x800\x81\x05\x00\x10\xd64\xb0\xda\x9a\xdb\xb6m\xdb\xb4i\xd3\xfa\x9fr\xf3\xcd7\x0f\xe5T\x07\xe5\xd4\xa9S\x8b\x17/\x1e?~\xfc\xf8\xf1\xe3\xef\xbf\xff\xfe\xf7z:M5\xbb\x87\x17\xcbUZ\x8f|V\xd7\xbd\x10\xb6\xcd{b\x88\xf6j\xb3\x9b?\x14\x9b\xa1>\xe6\xf9\xd9\xcf\x00\x17\x93'''
        )
        checksum = read_checksum_from_png.read_checksum(filehandle)
        self.assertIsNone(checksum)
示例#13
0
 def _latest_entry_for_changelog_at_revision(self, changelog_path, revision):
     changelog_contents = self._scm.contents_at_revision(changelog_path, revision)
     # contents_at_revision returns a byte array (str()), but we know
     # that ChangeLog files are utf-8.  parse_latest_entry_from_file
     # expects a file-like object which vends unicode(), so we decode here.
     # Old revisions of Sources/WebKit/wx/ChangeLog have some invalid utf8 characters.
     changelog_file = StringIO(changelog_contents.decode("utf-8", "ignore"))
     return ChangeLog.parse_latest_entry_from_file(changelog_file)
示例#14
0
    def test_saving(self):
        mapping_a = Contributor.Mapping()
        mapping_a.create('Jonathan Bedard', '*****@*****.**')
        mapping_a.create('Stephanie Lewis', '*****@*****.**')
        mapping_a['JonWBedard'] = mapping_a['*****@*****.**']

        file = StringIO()
        mapping_a.save(file)
        file.seek(0)

        mapping_b = Contributor.Mapping.load(file)
        self.assertEqual(mapping_a['*****@*****.**'],
                         mapping_b['*****@*****.**'])
        self.assertEqual(mapping_a['*****@*****.**'],
                         mapping_b['JonWBedard'])
        self.assertEqual(mapping_a['*****@*****.**'],
                         mapping_b['*****@*****.**'])
示例#15
0
文件: bugzilla.py 项目: visnix/WebKit
    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.open_url(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(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
示例#16
0
 def set_reviewer(self, reviewer):
     latest_entry = self.latest_entry()
     latest_entry_contents = latest_entry.contents()
     reviewer_text = latest_entry.reviewer()
     found_nobody = re.search("NOBODY\s*\(OOPS!\)", latest_entry_contents,
                              re.MULTILINE)
     found_reviewer_or_unreviewed = latest_entry.has_valid_reviewer()
     if not found_nobody and not found_reviewer_or_unreviewed and not reviewer_text:
         bug_url_number_of_items = len(
             re.findall(config_urls.bug_url_long, latest_entry_contents,
                        re.MULTILINE))
         bug_url_number_of_items += len(
             re.findall(config_urls.bug_url_short, latest_entry_contents,
                        re.MULTILINE))
         result = StringIO()
         with self._filesystem.open_text_file_for_reading(
                 self.path) as file:
             for line in file:
                 found_bug_url = re.search(config_urls.bug_url_long, line)
                 if not found_bug_url:
                     found_bug_url = re.search(config_urls.bug_url_short,
                                               line)
                 result.write(line)
                 if found_bug_url:
                     if bug_url_number_of_items == 1:
                         result.write("\n        Reviewed by %s.\n" %
                                      reviewer)
                     bug_url_number_of_items -= 1
         self._filesystem.write_text_file(self.path, result.getvalue())
     else:
         data = self._filesystem.read_text_file(self.path)
         newdata = data.replace("NOBODY (OOPS!)", reviewer)
         self._filesystem.write_text_file(self.path, newdata)
示例#17
0
    def assertTest(self,
                   test_name,
                   pixel_tests,
                   expected_checksum=None,
                   drt_output=None,
                   host=None,
                   expected_text=None):
        port_name = 'test'
        host = host or MockSystemHost()
        test.add_unit_tests_to_mock_filesystem(host.filesystem)
        port = PortFactory(host).get(port_name)
        drt_input, drt_output = self.make_input_output(
            port,
            test_name,
            pixel_tests,
            expected_checksum,
            drt_output,
            drt_input=None,
            expected_text=expected_text)

        args = ['--platform', port_name] + self.extra_args(pixel_tests)
        stdin = StringIO(drt_input)
        stdout = StringIO()
        stderr = StringIO()
        options, args = mock_drt.parse_options(args)

        drt = self.make_drt(options, args, host, stdin, stdout, stderr)
        res = drt.run()

        self.assertEqual(res, 0)

        self.assertEqual(stdout.getvalue(), ''.join(drt_output))
        self.assertEqual(stderr.getvalue(), '#EOF\n')
示例#18
0
    def __init__(self, in1, in2):
        if isinstance(in1, str):
            waveFile1 = wave.open(StringIO(in1), 'r')
        else:
            waveFile1 = wave.open(BytesIO(in1), 'rb')
        if isinstance(in2, str):
            waveFile2 = wave.open(StringIO(in2), 'r')
        else:
            waveFile2 = wave.open(BytesIO(in2), 'rb')

        params1 = waveFile1.getparams()
        params2 = waveFile2.getparams()

        self._diff = []

        self._filesAreIdentical = not sum(map(self._diffParam, params1, params2, self._paramNames))
        self._filesAreIdenticalWithinTolerance = self._filesAreIdentical

        if not self._filesAreIdentical:
            return

        # Metadata is identical, compare the content now.

        channelCount1 = waveFile1.getnchannels()
        frameCount1 = waveFile1.getnframes()
        sampleWidth1 = waveFile1.getsampwidth()
        channelCount2 = waveFile2.getnchannels()
        frameCount2 = waveFile2.getnframes()
        sampleWidth2 = waveFile2.getsampwidth()

        allData1 = self._readSamples(waveFile1, sampleWidth1, frameCount1 * channelCount1)
        allData2 = self._readSamples(waveFile2, sampleWidth2, frameCount2 * channelCount2)
        results = list(map(self._diffSample, allData1, allData2, range(max(frameCount1 * channelCount1, frameCount2 * channelCount2))))

        cumulativeSampleDiff = sum(results)
        differingSampleCount = len(list(filter(bool, results)))
        self._filesAreIdentical = not differingSampleCount
        self._filesAreIdenticalWithinTolerance = not len(list(filter(lambda x: x > self._tolerance, results)))

        if differingSampleCount:
            self._diff.append('')
            self._diff.append('Total differing samples: %d' % differingSampleCount)
            self._diff.append('Percentage of differing samples: %0.3f%%' % (100 * float(differingSampleCount) / max(frameCount1, frameCount2)))
            self._diff.append('Cumulative sample difference: %d' % cumulativeSampleDiff)
            self._diff.append('Average sample difference: %f' % (float(cumulativeSampleDiff) / differingSampleCount))
示例#19
0
    def test_no_tests_found(self):
        tester = Tester()
        errors = StringIO()

        # Here we need to remove any existing log handlers so that they
        # don't log the messages webkitpy.test while we're testing it.
        root_logger = logging.getLogger()
        root_handlers = root_logger.handlers
        root_logger.handlers = []

        tester.printer.stream = errors
        tester.finder.find_names = lambda args, run_all: []
        with OutputCapture(level=logging.INFO) as captured:
            self.assertFalse(tester.run())
        root_logger.handlers = root_handlers

        self.assertIn('No tests to run', errors.getvalue())
        self.assertIn('No tests to run', captured.root.log.getvalue())
    def test_lint_test_files__errors(self):
        options = optparse.Values({'platform': 'test', 'debug_rwt_logging': False})
        host = MockHost()

        # FIXME: incorrect complaints about spacing pylint: disable=C0322
        port = host.port_factory.get(options.platform, options=options)
        port.expectations_dict = lambda: {'foo': '-- syntax error1', 'bar': '-- syntax error2'}

        host.port_factory.get = lambda platform, options=None: port
        host.port_factory.all_port_names = lambda platform=None: [port.name()]

        logging_stream = StringIO()

        res = lint_test_expectations.lint(host, options, logging_stream)

        self.assertEqual(res, -1)
        self.assertIn('Lint failed', logging_stream.getvalue())
        self.assertIn('foo:1', logging_stream.getvalue())
        self.assertIn('bar:1', logging_stream.getvalue())
示例#21
0
 def test_file_object_for_upload(self):
     bugzilla = Bugzilla()
     file_object = StringIO()
     unicode_tor = u"WebKit \u2661 Tor Arne Vestb\u00F8!"
     utf8_tor = unicode_tor.encode("utf-8")
     self.assertEqual(bugzilla._file_object_for_upload(file_object),
                      file_object)
     self.assertEqual(
         bugzilla._file_object_for_upload(utf8_tor).read(), utf8_tor)
     self.assertEqual(
         bugzilla._file_object_for_upload(unicode_tor).read(), utf8_tor)
示例#22
0
 def test_run(self, verbose=0, timing=False, child_processes=1, quiet=False):
     options = MockOptions(verbose=verbose, timing=timing, child_processes=child_processes, quiet=quiet, pass_through=False)
     stream = StringIO()
     loader = FakeLoader(('test1 (Foo)', '.', ''),
                         ('test2 (Foo)', 'F', 'test2\nfailed'),
                         ('test3 (Foo)', 'E', 'test3\nerred'))
     runner = Runner(Printer(stream, options), loader)
     runner.run(['Foo.test1', 'Foo.test2', 'Foo.test3'], 1)
     self.assertEqual(len(runner.tests_run), 3)
     self.assertEqual(len(runner.failures), 1)
     self.assertEqual(len(runner.errors), 1)
示例#23
0
 def test_filename_for_upload(self):
     bugzilla = Bugzilla()
     mock_file = Mock()
     mock_file.name = "foo"
     self.assertEqual(bugzilla._filename_for_upload(mock_file, 1234), 'foo')
     mock_timestamp = lambda: "now"
     filename = bugzilla._filename_for_upload(StringIO(),
                                              1234,
                                              extension="patch",
                                              timestamp=mock_timestamp)
     self.assertEqual(filename, "bug-1234-now.patch")
    def test_all_configurations(self):
        host = MockHost()
        host.ports_parsed = []
        host.port_factory = FakeFactory(host, (FakePort(host, 'a', 'path-to-a'),
                                               FakePort(host, 'b', 'path-to-b'),
                                               FakePort(host, 'b-win', 'path-to-b')))

        logging_stream = StringIO()
        options = optparse.Values({'platform': None})
        res = lint_test_expectations.lint(host, options, logging_stream)
        self.assertEqual(res, 0)
        self.assertEqual(host.ports_parsed, ['a', 'b', 'b-win'])
示例#25
0
 def strip_change_log(cls, diff):
     output = []
     skipping = False
     for line in StringIO(diff).readlines():
         indexline = re.match("^Index: ([^\\n]*/)?([^/\\n]*)$", line)
         if skipping and indexline:
             skipping = False
         if indexline and indexline.group(2) == "ChangeLog":
             skipping = True
         if not skipping:
             output.append(line)
     return "".join(output)
示例#26
0
    def get_printer(self, args=None):
        args = args or []
        printing_options = printing.print_options()
        option_parser = optparse.OptionParser(option_list=printing_options)
        options, args = option_parser.parse_args(args)
        host = MockHost()
        self._port = host.port_factory.get('test', options)
        nproc = 2

        regular_output = StringIO()
        printer = printing.Printer(self._port, options, regular_output)
        return printer, regular_output
示例#27
0
    def test_no_tests_found(self):
        tester = Tester()
        errors = StringIO()

        # Here we need to remove any existing log handlers so that they
        # don't log the messages webkitpy.test while we're testing it.
        root_logger = logging.getLogger()
        root_handlers = root_logger.handlers
        root_logger.handlers = []

        tester.printer.stream = errors
        tester.finder.find_names = lambda args, run_all: []
        oc = OutputCapture()
        try:
            oc.capture_output()
            self.assertFalse(tester.run())
        finally:
            _, _, logs = oc.restore_output()
            root_logger.handlers = root_handlers

        self.assertIn('No tests to run', errors.getvalue())
        self.assertIn('No tests to run', logs)
示例#28
0
 def test_main(self):
     host = MockSystemHost()
     test.add_unit_tests_to_mock_filesystem(host.filesystem)
     stdin = StringIO()
     stdout = StringIO()
     stderr = StringIO()
     res = mock_drt.main(['--platform', 'test'] + self.extra_args(False),
                         host, stdin, stdout, stderr)
     self.assertEqual(res, 0)
     self.assertEqual(stdout.getvalue(), '')
     self.assertEqual(stderr.getvalue(), '')
     self.assertEqual(host.filesystem.written_files, {})
示例#29
0
    def test_parse_log_entries_from_annotated_file(self):
        # Note that there are trailing spaces on some of the lines intentionally.
        changelog_file = StringIO(
            u"100000 [email protected] 2011-11-11  Csaba Osztrogon\u00e1c  <*****@*****.**>\n"
            u"100000 [email protected]\n"
            u"100000 [email protected]         100,000 !!!\n"
            u"100000 [email protected] \n"
            u"100000 [email protected]         Reviewed by Zoltan Herczeg.\n"
            u"100000 [email protected] \n"
            u"100000 [email protected]         * ChangeLog: Point out revision 100,000.\n"
            u"100000 [email protected] \n"
            u"93798 [email protected] 2011-08-25  Alexey Proskuryakov  <*****@*****.**>\n"
            u"93798 [email protected] \n"
            u"93798 [email protected]         Fix build when GCC 4.2 is not installed.\n"
            u"93798 [email protected] \n"
            u"93798 [email protected]         * gtest/xcode/Config/CompilerVersion.xcconfig: Copied from Source/WebCore/Configurations/CompilerVersion.xcconfig.\n"
            u"93798 [email protected]         * gtest/xcode/Config/General.xcconfig:\n"
            u"93798 [email protected]         Use the same compiler version as other projects do.\n"
            u"93798 [email protected]\n"
            u"99491 [email protected] 2011-11-03  Andreas Kling  <*****@*****.**>\n"
            u"99491 [email protected] \n"
            u"99190 [email protected]         Unreviewed build fix, sigh.\n"
            u"99190 [email protected] \n"
            u"99190 [email protected]         * css/CSSFontFaceRule.h:\n"
            u"99190 [email protected]         * css/CSSMutableStyleDeclaration.h:\n"
            u"99190 [email protected]\n"
            u"99190 [email protected] 2011-11-03  Andreas Kling  <*****@*****.**>\n"
            u"99190 [email protected] \n"
            u"99187 [email protected]         Unreviewed build fix, out-of-line StyleSheet::parentStyleSheet()\n"
            u"99187 [email protected]         again since there's a cycle in the includes between CSSRule/StyleSheet.\n"
            u"99187 [email protected] \n"
            u"99187 [email protected]         * css/StyleSheet.cpp:\n"
            u"99187 [email protected]         (WebCore::StyleSheet::parentStyleSheet):\n"
            u"99187 [email protected]         * css/StyleSheet.h:\n"
            u"99187 [email protected] \n")

        parsed_entries = list(
            ChangeLog.parse_entries_from_file(changelog_file))
        self.assertEqual(parsed_entries[0].revision(), 100000)
        self.assertEqual(parsed_entries[0].reviewer_text(), "Zoltan Herczeg")
        self.assertEqual(parsed_entries[0].author_name(),
                         u"Csaba Osztrogon\u00e1c")
        self.assertEqual(parsed_entries[0].author_email(), "*****@*****.**")
        self.assertEqual(parsed_entries[1].revision(), 93798)
        self.assertEqual(parsed_entries[1].author_name(),
                         "Alexey Proskuryakov")
        self.assertEqual(parsed_entries[2].revision(), 99190)
        self.assertEqual(parsed_entries[2].author_name(), "Andreas Kling")
        self.assertEqual(parsed_entries[3].revision(), 99187)
        self.assertEqual(parsed_entries[3].author_name(), "Andreas Kling")
示例#30
0
    def test_git_diff_to_svn_diff(self):
        output = """\
Index: Tools/Scripts/webkitpy/common/checkout/diff_parser.py
===================================================================
--- Tools/Scripts/webkitpy/common/checkout/diff_parser.py
+++ Tools/Scripts/webkitpy/common/checkout/diff_parser.py
@@ -59,6 +59,7 @@ def git_diff_to_svn_diff(line):
 A
 B
 C
+D
 E
 F
"""

        inputfmt = StringIO("""\
diff --git a/Tools/Scripts/webkitpy/common/checkout/diff_parser.py b/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
index 2ed552c4555db72df16b212547f2c125ae301a04..72870482000c0dba64ce4300ed782c03ee79b74f 100644
--- a/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
+++ b/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
@@ -59,6 +59,7 @@ def git_diff_to_svn_diff(line):
 A
 B
 C
+D
 E
 F
""")
        shortfmt = StringIO("""\
diff --git a/Tools/Scripts/webkitpy/common/checkout/diff_parser.py b/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
index b48b162..f300960 100644
--- a/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
+++ b/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
@@ -59,6 +59,7 @@ def git_diff_to_svn_diff(line):
 A
 B
 C
+D
 E
 F
""")

        self.assertMultiLineEqual(
            output, ''.join(
                diff_parser.git_diff_to_svn_diff(x)
                for x in shortfmt.readlines()))
        self.assertMultiLineEqual(
            output, ''.join(
                diff_parser.git_diff_to_svn_diff(x)
                for x in inputfmt.readlines()))