示例#1
0
    def test_set_short_description_and_bug_url(self):
        fs = MockFileSystem()

        changelog_contents = u"%s\n%s" % (
            self._new_entry_boilerplate_with_bugurl, self._example_changelog)
        fs.write_text_file(self._changelog_path, changelog_contents)
        short_description = "A short description"
        bug_url = "http://example.com/b/2344"
        ChangeLog(self._changelog_path, fs).set_short_description_and_bug_url(
            short_description, bug_url)
        actual_contents = fs.read_text_file(self._changelog_path)
        expected_contents = changelog_contents.replace(
            "Need a short description (OOPS!).", short_description)
        self.assertEqual(actual_contents.splitlines(),
                         expected_contents.splitlines())

        changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate,
                                          self._example_changelog)
        fs.write_text_file(self._changelog_path, changelog_contents)
        short_description = "A short description 2"
        bug_url = "http://example.com/b/2345"
        ChangeLog(self._changelog_path, fs).set_short_description_and_bug_url(
            short_description, bug_url)
        actual_contents = fs.read_text_file(self._changelog_path)
        expected_message = "%s\n        %s" % (short_description, bug_url)
        expected_contents = changelog_contents.replace(
            "Need a short description (OOPS!).\n        Need the bug URL (OOPS!).",
            expected_message)
        self.assertEqual(actual_contents.splitlines(),
                         expected_contents.splitlines())
示例#2
0
    def test_delete_entries(self):
        fs = MockFileSystem()
        fs.write_text_file(self._changelog_path, self._example_changelog)
        ChangeLog(self._changelog_path, fs).delete_entries(8)
        actual_contents = fs.read_text_file(self._changelog_path)
        expected_contents = """2011-10-11  Antti Koivisto  <*****@*****.**>

       Resolve regular and visited link style in a single pass
       https://bugs.webkit.org/show_bug.cgi?id=69838

       Reviewed by Darin Adler

       We can simplify and speed up selector matching by removing the recursive matching done
       to generate the style for the :visited pseudo selector. Both regular and visited link style
       can be generated in a single pass through the style selector.

== Rolled over to ChangeLog-2009-06-16 ==
"""
        self.assertEqual(actual_contents.splitlines(),
                         expected_contents.splitlines())

        ChangeLog(self._changelog_path, fs).delete_entries(2)
        actual_contents = fs.read_text_file(self._changelog_path)
        expected_contents = "== Rolled over to ChangeLog-2009-06-16 ==\n"
        self.assertEqual(actual_contents.splitlines(),
                         expected_contents.splitlines())
示例#3
0
    def test_set_reviewer(self):
        fs = MockFileSystem()

        changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate_with_bugurl, self._example_changelog)
        reviewer_name = 'Test Reviewer'
        fs.write_text_file(self._changelog_path, changelog_contents)
        ChangeLog(self._changelog_path, fs).set_reviewer(reviewer_name)
        actual_contents = fs.read_text_file(self._changelog_path)
        expected_contents = changelog_contents.replace('NOBODY (OOPS!)', reviewer_name)
        self.assertEqual(actual_contents.splitlines(), expected_contents.splitlines())

        changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate_with_unreviewed, self._example_changelog)
        fs.write_text_file(self._changelog_path, changelog_contents)
        ChangeLog(self._changelog_path, fs).set_reviewer(reviewer_name)
        actual_contents = fs.read_text_file(self._changelog_path)
        self.assertEqual(actual_contents.splitlines(), changelog_contents.splitlines())

        changelog_contents_without_reviewer_line = u"%s\n%s" % (self._new_entry_boilerplate_without_reviewer_line, self._example_changelog)
        fs.write_text_file(self._changelog_path, changelog_contents_without_reviewer_line)
        ChangeLog(self._changelog_path, fs).set_reviewer(reviewer_name)
        actual_contents = fs.read_text_file(self._changelog_path)
        self.assertEqual(actual_contents.splitlines(), expected_contents.splitlines())

        changelog_contents_without_reviewer_line = u"%s\n%s" % (self._new_entry_boilerplate_without_reviewer_multiple_bugurl, self._example_changelog)
        fs.write_text_file(self._changelog_path, changelog_contents_without_reviewer_line)
        ChangeLog(self._changelog_path, fs).set_reviewer(reviewer_name)
        actual_contents = fs.read_text_file(self._changelog_path)
        changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate_with_multiple_bugurl, self._example_changelog)
        expected_contents = changelog_contents.replace('NOBODY (OOPS!)', reviewer_name)
        self.assertEqual(actual_contents.splitlines(), expected_contents.splitlines())
示例#4
0
    def test_set_reviewer(self):
        fs = MockFileSystem()

        changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate_with_bugurl, self._example_changelog)
        reviewer_name = 'Test Reviewer'
        fs.write_text_file(self._changelog_path, changelog_contents)
        ChangeLog(self._changelog_path, fs).set_reviewer(reviewer_name)
        actual_contents = fs.read_text_file(self._changelog_path)
        expected_contents = changelog_contents.replace('NOBODY (OOPS!)', reviewer_name)
        self.assertEqual(actual_contents.splitlines(), expected_contents.splitlines())

        changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate_with_unreviewed, self._example_changelog)
        fs.write_text_file(self._changelog_path, changelog_contents)
        ChangeLog(self._changelog_path, fs).set_reviewer(reviewer_name)
        actual_contents = fs.read_text_file(self._changelog_path)
        self.assertEqual(actual_contents.splitlines(), changelog_contents.splitlines())

        changelog_contents_without_reviewer_line = u"%s\n%s" % (self._new_entry_boilerplate_without_reviewer_line, self._example_changelog)
        fs.write_text_file(self._changelog_path, changelog_contents_without_reviewer_line)
        ChangeLog(self._changelog_path, fs).set_reviewer(reviewer_name)
        actual_contents = fs.read_text_file(self._changelog_path)
        self.assertEqual(actual_contents.splitlines(), expected_contents.splitlines())

        changelog_contents_without_reviewer_line = u"%s\n%s" % (self._new_entry_boilerplate_without_reviewer_multiple_bugurl, self._example_changelog)
        fs.write_text_file(self._changelog_path, changelog_contents_without_reviewer_line)
        ChangeLog(self._changelog_path, fs).set_reviewer(reviewer_name)
        actual_contents = fs.read_text_file(self._changelog_path)
        changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate_with_multiple_bugurl, self._example_changelog)
        expected_contents = changelog_contents.replace('NOBODY (OOPS!)', reviewer_name)
        self.assertEqual(actual_contents.splitlines(), expected_contents.splitlines())
示例#5
0
 def test_prepend_text(self):
     fs = MockFileSystem()
     fs.write_text_file(self._changelog_path, self._example_changelog)
     ChangeLog(self._changelog_path, fs).prepend_text(self._example_entry + "\n")
     actual_contents = fs.read_text_file(self._changelog_path)
     expected_contents = self._example_entry + "\n" + self._example_changelog
     self.assertEqual(actual_contents.splitlines(), expected_contents.splitlines())
示例#6
0
    def test_find_log_darwin(self):
        if not SystemHost().platform.is_mac():
            return

        older_mock_crash_report = make_mock_crash_report_darwin(
            'DumpRenderTree', 28528)
        mock_crash_report = make_mock_crash_report_darwin(
            'DumpRenderTree', 28530)
        newer_mock_crash_report = make_mock_crash_report_darwin(
            'DumpRenderTree', 28529)
        other_process_mock_crash_report = make_mock_crash_report_darwin(
            'FooProcess', 28527)
        misformatted_mock_crash_report = 'Junk that should not appear in a crash report' + \
            make_mock_crash_report_darwin('DumpRenderTree', 28526)[200:]
        files = {
            '/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150718_quadzen.crash':
            older_mock_crash_report,
            '/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150719_quadzen.crash':
            mock_crash_report,
            '/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150720_quadzen.crash':
            newer_mock_crash_report,
            '/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150721_quadzen.crash':
            None,
            '/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150722_quadzen.crash':
            other_process_mock_crash_report,
            '/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150723_quadzen.crash':
            misformatted_mock_crash_report,
        }
        filesystem = MockFileSystem(files)
        crash_logs = CrashLogs(MockSystemHost(filesystem=filesystem))
        log = crash_logs.find_newest_log("DumpRenderTree")
        self.assertMultiLineEqual(log, newer_mock_crash_report)
        log = crash_logs.find_newest_log("DumpRenderTree", 28529)
        self.assertMultiLineEqual(log, newer_mock_crash_report)
        log = crash_logs.find_newest_log("DumpRenderTree", 28530)
        self.assertMultiLineEqual(log, mock_crash_report)
        log = crash_logs.find_newest_log("DumpRenderTree", 28531)
        self.assertIsNone(log)
        log = crash_logs.find_newest_log("DumpRenderTree", newer_than=1.0)
        self.assertIsNone(log)

        def bad_read(path):
            raise IOError('IOError: No such file or directory')

        def bad_mtime(path):
            raise OSError('OSError: No such file or directory')

        filesystem.read_text_file = bad_read
        log = crash_logs.find_newest_log("DumpRenderTree",
                                         28531,
                                         include_errors=True)
        self.assertIn('IOError: No such file or directory', log)

        filesystem = MockFileSystem(files)
        crash_logs = CrashLogs(MockSystemHost(filesystem=filesystem))
        filesystem.mtime = bad_mtime
        log = crash_logs.find_newest_log("DumpRenderTree",
                                         newer_than=1.0,
                                         include_errors=True)
        self.assertIn('OSError: No such file or directory', log)
 def test_prepend_text(self):
     fs = MockFileSystem()
     fs.write_text_file(self._changelog_path, self._example_changelog)
     ChangeLog(self._changelog_path, fs).prepend_text(self._example_entry + "\n")
     actual_contents = fs.read_text_file(self._changelog_path)
     expected_contents = self._example_entry + "\n" + self._example_changelog
     self.assertEqual(actual_contents.splitlines(), expected_contents.splitlines())
示例#8
0
    def test_find_log_darwin(self):
        if not SystemHost().platform.is_mac():
            return

        older_mock_crash_report = make_mock_crash_report_darwin('DumpRenderTree', 28528)
        mock_crash_report = make_mock_crash_report_darwin('DumpRenderTree', 28530)
        newer_mock_crash_report = make_mock_crash_report_darwin('DumpRenderTree', 28529)
        other_process_mock_crash_report = make_mock_crash_report_darwin('FooProcess', 28527)
        misformatted_mock_crash_report = 'Junk that should not appear in a crash report' + make_mock_crash_report_darwin('DumpRenderTree', 28526)[200:]
        files = {}
        files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150718_quadzen.crash'] = older_mock_crash_report
        files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150719_quadzen.crash'] = mock_crash_report
        files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150720_quadzen.crash'] = newer_mock_crash_report
        files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150721_quadzen.crash'] = None
        files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150722_quadzen.crash'] = other_process_mock_crash_report
        files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150723_quadzen.crash'] = misformatted_mock_crash_report
        filesystem = MockFileSystem(files)
        crash_logs = CrashLogs(MockSystemHost(filesystem=filesystem))
        log = crash_logs.find_newest_log("DumpRenderTree")
        self.assertLinesEqual(log, newer_mock_crash_report)
        log = crash_logs.find_newest_log("DumpRenderTree", 28529)
        self.assertLinesEqual(log, newer_mock_crash_report)
        log = crash_logs.find_newest_log("DumpRenderTree", 28530)
        self.assertLinesEqual(log, mock_crash_report)
        log = crash_logs.find_newest_log("DumpRenderTree", 28531)
        self.assertEqual(log, None)
        log = crash_logs.find_newest_log("DumpRenderTree", newer_than=1.0)
        self.assertEqual(log, None)

        def bad_read(path):
            raise IOError('No such file or directory')

        filesystem.read_text_file = bad_read
        log = crash_logs.find_newest_log("DumpRenderTree", 28531, include_errors=True)
        self.assertTrue('No such file or directory' in log)
示例#9
0
    def test_find_log_darwin(self):
        if sys.platform != "darwin":
            return

        older_mock_crash_report = make_mock_crash_report_darwin('DumpRenderTree', 28528)
        mock_crash_report = make_mock_crash_report_darwin('DumpRenderTree', 28530)
        newer_mock_crash_report = make_mock_crash_report_darwin('DumpRenderTree', 28529)
        other_process_mock_crash_report = make_mock_crash_report_darwin('FooProcess', 28527)
        misformatted_mock_crash_report = 'Junk that should not appear in a crash report' + make_mock_crash_report_darwin('DumpRenderTree', 28526)[200:]
        files = {}
        files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150718_quadzen.crash'] = older_mock_crash_report
        files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150719_quadzen.crash'] = mock_crash_report
        files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150720_quadzen.crash'] = newer_mock_crash_report
        files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150721_quadzen.crash'] = None
        files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150722_quadzen.crash'] = other_process_mock_crash_report
        files['/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150723_quadzen.crash'] = misformatted_mock_crash_report
        filesystem = MockFileSystem(files)
        crash_logs = CrashLogs(filesystem)
        log = crash_logs.find_newest_log("DumpRenderTree")
        self.assertLinesEqual(log, newer_mock_crash_report)
        log = crash_logs.find_newest_log("DumpRenderTree", 28529)
        self.assertLinesEqual(log, newer_mock_crash_report)
        log = crash_logs.find_newest_log("DumpRenderTree", 28530)
        self.assertLinesEqual(log, mock_crash_report)
        log = crash_logs.find_newest_log("DumpRenderTree", 28531)
        self.assertEqual(log, None)
        log = crash_logs.find_newest_log("DumpRenderTree", newer_than=1.0)
        self.assertEqual(log, None)

        def bad_read(path):
            raise IOError('No such file or directory')

        filesystem.read_text_file = bad_read
        log = crash_logs.find_newest_log("DumpRenderTree", 28531, include_errors=True)
        self.assertTrue('No such file or directory' in log)
class DirectoryFileSetTest(unittest.TestCase):
    def setUp(self):
        files = {}
        files['/test/some-file'] = 'contents'
        files['/test/some-other-file'] = 'other contents'
        files['/test/b/c'] = 'c'
        self._filesystem = MockFileSystem(files)
        self._fileset = DirectoryFileSet('/test', self._filesystem)

    def test_files_in_namelist(self):
        self.assertTrue('some-file' in self._fileset.namelist())
        self.assertTrue('some-other-file' in self._fileset.namelist())
        self.assertTrue('b/c' in self._fileset.namelist())

    def test_read(self):
        self.assertEquals('contents', self._fileset.read('some-file'))

    def test_open(self):
        file = self._fileset.open('some-file')
        self.assertEquals('some-file', file.name())
        self.assertEquals('contents', file.contents())

    def test_extract(self):
        self._fileset.extract('some-file', '/test-directory')
        contents = self._filesystem.read_text_file('/test-directory/some-file')
        self.assertEquals('contents', contents)

    def test_extract_deep_file(self):
        self._fileset.extract('b/c', '/test-directory')
        self.assertTrue(self._filesystem.exists('/test-directory/b/c'))

    def test_delete(self):
        self.assertTrue(self._filesystem.exists('/test/some-file'))
        self._fileset.delete('some-file')
        self.assertFalse(self._filesystem.exists('/test/some-file'))
    def test_set_short_description_and_bug_url(self):
        fs = MockFileSystem()

        changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate_with_bugurl, self._example_changelog)
        fs.write_text_file(self._changelog_path, changelog_contents)
        short_description = "A short description"
        bug_url = "http://example.com/b/2344"
        ChangeLog(self._changelog_path, fs).set_short_description_and_bug_url(short_description, bug_url)
        actual_contents = fs.read_text_file(self._changelog_path)
        expected_message = "%s\n        %s" % (short_description, bug_url)
        expected_contents = changelog_contents.replace("Need a short description (OOPS!).", expected_message)
        self.assertEqual(actual_contents.splitlines(), expected_contents.splitlines())

        changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate, self._example_changelog)
        fs.write_text_file(self._changelog_path, changelog_contents)
        short_description = "A short description 2"
        bug_url = "http://example.com/b/2345"
        ChangeLog(self._changelog_path, fs).set_short_description_and_bug_url(short_description, bug_url)
        actual_contents = fs.read_text_file(self._changelog_path)
        expected_message = "%s\n        %s" % (short_description, bug_url)
        expected_contents = changelog_contents.replace("Need a short description (OOPS!).\n        Need the bug URL (OOPS!).", expected_message)
        self.assertEqual(actual_contents.splitlines(), expected_contents.splitlines())
    def test_delete_entries(self):
        fs = MockFileSystem()
        fs.write_text_file(self._changelog_path, self._example_changelog)
        ChangeLog(self._changelog_path, fs).delete_entries(8)
        actual_contents = fs.read_text_file(self._changelog_path)
        expected_contents = """2011-10-11  Antti Koivisto  <*****@*****.**>

       Resolve regular and visited link style in a single pass
       https://bugs.webkit.org/show_bug.cgi?id=69838

       Reviewed by Darin Adler

       We can simplify and speed up selector matching by removing the recursive matching done
       to generate the style for the :visited pseudo selector. Both regular and visited link style
       can be generated in a single pass through the style selector.

== Rolled over to ChangeLog-2009-06-16 ==
"""
        self.assertEqual(actual_contents.splitlines(), expected_contents.splitlines())

        ChangeLog(self._changelog_path, fs).delete_entries(2)
        actual_contents = fs.read_text_file(self._changelog_path)
        expected_contents = "== Rolled over to ChangeLog-2009-06-16 ==\n"
        self.assertEqual(actual_contents.splitlines(), expected_contents.splitlines())
示例#13
0
    def test_find_log_darwin(self):
        if not SystemHost().platform.is_mac():
            return

        older_mock_crash_report = make_mock_crash_report_darwin("DumpRenderTree", 28528)
        mock_crash_report = make_mock_crash_report_darwin("DumpRenderTree", 28530)
        newer_mock_crash_report = make_mock_crash_report_darwin("DumpRenderTree", 28529)
        other_process_mock_crash_report = make_mock_crash_report_darwin("FooProcess", 28527)
        misformatted_mock_crash_report = (
            "Junk that should not appear in a crash report"
            + make_mock_crash_report_darwin("DumpRenderTree", 28526)[200:]
        )
        files = {
            "/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150718_quadzen.crash": older_mock_crash_report,
            "/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150719_quadzen.crash": mock_crash_report,
            "/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150720_quadzen.crash": newer_mock_crash_report,
            "/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150721_quadzen.crash": None,
            "/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150722_quadzen.crash": other_process_mock_crash_report,
            "/Users/mock/Library/Logs/DiagnosticReports/DumpRenderTree_2011-06-13-150723_quadzen.crash": misformatted_mock_crash_report,
        }
        filesystem = MockFileSystem(files)
        crash_logs = CrashLogs(MockSystemHost(filesystem=filesystem))
        log = crash_logs.find_newest_log("DumpRenderTree")
        self.assertMultiLineEqual(log, newer_mock_crash_report)
        log = crash_logs.find_newest_log("DumpRenderTree", 28529)
        self.assertMultiLineEqual(log, newer_mock_crash_report)
        log = crash_logs.find_newest_log("DumpRenderTree", 28530)
        self.assertMultiLineEqual(log, mock_crash_report)
        log = crash_logs.find_newest_log("DumpRenderTree", 28531)
        self.assertIsNone(log)
        log = crash_logs.find_newest_log("DumpRenderTree", newer_than=1.0)
        self.assertIsNone(log)

        def bad_read(path):
            raise IOError("IOError: No such file or directory")

        def bad_mtime(path):
            raise OSError("OSError: No such file or directory")

        filesystem.read_text_file = bad_read
        log = crash_logs.find_newest_log("DumpRenderTree", 28531, include_errors=True)
        self.assertIn("IOError: No such file or directory", log)

        filesystem = MockFileSystem(files)
        crash_logs = CrashLogs(MockSystemHost(filesystem=filesystem))
        filesystem.mtime = bad_mtime
        log = crash_logs.find_newest_log("DumpRenderTree", newer_than=1.0, include_errors=True)
        self.assertIn("OSError: No such file or directory", log)
示例#14
0
    def test_find_log_win(self):
        if not SystemHost().platform.is_win():
            return

        older_mock_crash_report = make_mock_crash_report_win(
            'DumpRenderTree', 28528)
        mock_crash_report = make_mock_crash_report_win('DumpRenderTree', 28530)
        newer_mock_crash_report = make_mock_crash_report_win(
            'DumpRenderTree', 28529)
        other_process_mock_crash_report = make_mock_crash_report_win(
            'FooProcess', 28527)
        misformatted_mock_crash_report = 'Junk that should not appear in a crash report' + make_mock_crash_report_win(
            'DumpRenderTree', 28526)[200:]
        files = {}
        files[
            '~/CrashLog_1d58_2013-06-03_12-21-20-110.txt'] = older_mock_crash_report
        files[
            '~/CrashLog_abcd_2013-06-03_12-22-19-129.txt'] = mock_crash_report
        files[
            '~/CrashLog_2eff_2013-06-03_12-23-20-150.txt'] = newer_mock_crash_report
        files['~/CrashLog_31a0_2013-06-03_12-24-22-119.txt'] = None
        files[
            '~/CrashLog_01a3_2013-06-03_12-25-23-120.txt'] = other_process_mock_crash_report
        files[
            '~/CrashLog_aadd_2013-06-03_12-26-24-121.txt'] = misformatted_mock_crash_report
        filesystem = MockFileSystem(files)
        mock_host = MockSystemHost(os_name='win', filesystem=filesystem)
        crash_logs = CrashLogs(mock_host, "~")

        log = crash_logs.find_newest_log("DumpRenderTree", 28529)
        self.assertMultiLineEqual(log, newer_mock_crash_report)
        log = crash_logs.find_newest_log("DumpRenderTree", 28530)
        self.assertMultiLineEqual(log, mock_crash_report)
        log = crash_logs.find_newest_log("DumpRenderTree", 28531)
        self.assertIsNone(log)
        log = crash_logs.find_newest_log("DumpRenderTree", newer_than=1.0)
        self.assertIsNone(log)

        def bad_read(path):
            raise IOError('IOError: No such file or directory')

        filesystem.read_text_file = bad_read
        filesystem.read_binary_file = bad_read
        log = crash_logs.find_newest_log("DumpRenderTree",
                                         28531,
                                         include_errors=True)
        self.assertIn('IOError: No such file or directory', log)
    def test_find_log_win(self):
        if not SystemHost().platform.is_win():
            return

        older_mock_crash_report = make_mock_crash_report_win('DumpRenderTree', 28528)
        mock_crash_report = make_mock_crash_report_win('DumpRenderTree', 28530)
        newer_mock_crash_report = make_mock_crash_report_win('DumpRenderTree', 28529)
        other_process_mock_crash_report = make_mock_crash_report_win('FooProcess', 28527)
        misformatted_mock_crash_report = 'Junk that should not appear in a crash report' + make_mock_crash_report_win('DumpRenderTree', 28526)[200:]
        files = {}
        files['~/CrashLog_1d58_2013-06-03_12-21-20-110.txt'] = older_mock_crash_report
        files['~/CrashLog_abcd_2013-06-03_12-22-19-129.txt'] = mock_crash_report
        files['~/CrashLog_2eff_2013-06-03_12-23-20-150.txt'] = newer_mock_crash_report
        files['~/CrashLog_31a0_2013-06-03_12-24-22-119.txt'] = None
        files['~/CrashLog_01a3_2013-06-03_12-25-23-120.txt'] = other_process_mock_crash_report
        files['~/CrashLog_aadd_2013-06-03_12-26-24-121.txt'] = misformatted_mock_crash_report
        filesystem = MockFileSystem(files)
        mock_host = MockSystemHost(os_name='win', filesystem=filesystem)
        crash_logs = CrashLogs(mock_host, "~")

        log = crash_logs.find_newest_log("DumpRenderTree", 28529)
        self.assertMultiLineEqual(log, newer_mock_crash_report)
        log = crash_logs.find_newest_log("DumpRenderTree", 28530)
        self.assertMultiLineEqual(log, mock_crash_report)
        log = crash_logs.find_newest_log("DumpRenderTree", 28531)
        self.assertIsNone(log)
        log = crash_logs.find_newest_log("DumpRenderTree", newer_than=1.0)
        self.assertIsNone(log)

        def bad_read(path):
            raise IOError('IOError: No such file or directory')

        filesystem.read_text_file = bad_read
        filesystem.read_binary_file = bad_read
        log = crash_logs.find_newest_log("DumpRenderTree", 28531, include_errors=True)
        self.assertIn('IOError: No such file or directory', log)