Title: [119030] trunk/Tools
Revision
119030
Author
[email protected]
Date
2012-05-30 20:05:34 -0700 (Wed, 30 May 2012)

Log Message

https://bugs.webkit.org/show_bug.cgi?id=87803
Layout tests often fail trying to stat nonexistent logs

Reviewed by Dirk Pranke.

CrashReporter removes logs using a heuristic to conserve space.  Wrap a
try/catch block around accessing the logs as a precaution.

* Scripts/webkitpy/common/system/crashlogs.py:
(CrashLogs._find_newest_log_darwin):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (119029 => 119030)


--- trunk/Tools/ChangeLog	2012-05-31 03:05:30 UTC (rev 119029)
+++ trunk/Tools/ChangeLog	2012-05-31 03:05:34 UTC (rev 119030)
@@ -1,3 +1,16 @@
+2012-05-30  Stephanie Lewis  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=87803
+        Layout tests often fail trying to stat nonexistent logs 
+
+        Reviewed by Dirk Pranke.
+
+        CrashReporter removes logs using a heuristic to conserve space.  Wrap a 
+        try/catch block around accessing the logs as a precaution.
+
+        * Scripts/webkitpy/common/system/crashlogs.py:
+        (CrashLogs._find_newest_log_darwin):
+
 2012-05-30  Gavin Peters  <[email protected]>
 
         Add a LayoutTest for prerender remove after stop.

Modified: trunk/Tools/Scripts/webkitpy/common/system/crashlogs.py (119029 => 119030)


--- trunk/Tools/Scripts/webkitpy/common/system/crashlogs.py	2012-05-31 03:05:30 UTC (rev 119029)
+++ trunk/Tools/Scripts/webkitpy/common/system/crashlogs.py	2012-05-31 03:05:34 UTC (rev 119030)
@@ -56,15 +56,18 @@
         first_line_regex = re.compile(r'^Process:\s+(?P<process_name>.*) \[(?P<pid>\d+)\]$')
         errors = ''
         for path in reversed(sorted(logs)):
-            if not newer_than or self._host.filesystem.mtime(path) > newer_than:
-                try:
+            try:
+                if not newer_than or self._host.filesystem.mtime(path) > newer_than:
                     f = self._host.filesystem.read_text_file(path)
                     match = first_line_regex.match(f[0:f.find('\n')])
                     if match and match.group('process_name') == process_name and (pid is None or int(match.group('pid')) == pid):
                         return errors + f
-                except IOError, e:
-                    if include_errors:
-                        errors += "ERROR: Failed to read '%s': %s\n" % (path, str(e))
+            except IOError, e:
+                if include_errors:
+                    errors += "ERROR: Failed to read '%s': %s\n" % (path, str(e))
+            except OSError, e:
+                if include_errors:
+                    errors += "ERROR: Failed to read '%s': %s\n" % (path, str(e))
 
         if include_errors and errors:
             return errors

Modified: trunk/Tools/Scripts/webkitpy/common/system/crashlogs_unittest.py (119029 => 119030)


--- trunk/Tools/Scripts/webkitpy/common/system/crashlogs_unittest.py	2012-05-31 03:05:30 UTC (rev 119029)
+++ trunk/Tools/Scripts/webkitpy/common/system/crashlogs_unittest.py	2012-05-31 03:05:34 UTC (rev 119030)
@@ -75,6 +75,7 @@
         else:
             self.assertEqual(a.splitlines(), b.splitlines())
 
+
     def test_find_log_darwin(self):
         if not SystemHost().platform.is_mac():
             return
@@ -105,8 +106,17 @@
         self.assertEqual(log, None)
 
         def bad_read(path):
-            raise IOError('No such file or directory')
+            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.assertTrue('No such file or directory' in log)
+        self.assertTrue('IOError: No such file or directory' in 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.assertTrue('OSError: No such file or directory' in log)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to