run_webkit_tests.py failed with AttributeError(''NoneType' object has no attribute...
authordpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Jun 2012 22:25:50 +0000 (22:25 +0000)
committerdpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Jun 2012 22:25:50 +0000 (22:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=89734

Reviewed by Ryosuke Niwa.

Fix a crash in ServerProcess if you called .pid() after it
crashed during a write(). We had a test for this case but the
test wasn't calling pid(), just has_crashed(). Fixed the problem
and the test.

* Scripts/webkitpy/layout_tests/port/server_process.py:
(ServerProcess.__init__):
(ServerProcess.pid):
(ServerProcess._start):
(ServerProcess.stop):
* Scripts/webkitpy/layout_tests/port/server_process_unittest.py:
(FakeServerProcess._start):
(TestServerProcess.test_broken_pipe):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121061 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/layout_tests/port/server_process.py
Tools/Scripts/webkitpy/layout_tests/port/server_process_unittest.py

index 8464c71..0015b27 100644 (file)
@@ -1,3 +1,24 @@
+2012-06-22  Dirk Pranke  <dpranke@chromium.org>
+
+        run_webkit_tests.py failed with AttributeError(''NoneType' object has no attribute 'pid'')
+        https://bugs.webkit.org/show_bug.cgi?id=89734
+
+        Reviewed by Ryosuke Niwa.
+
+        Fix a crash in ServerProcess if you called .pid() after it
+        crashed during a write(). We had a test for this case but the
+        test wasn't calling pid(), just has_crashed(). Fixed the problem
+        and the test.
+
+        * Scripts/webkitpy/layout_tests/port/server_process.py:
+        (ServerProcess.__init__):
+        (ServerProcess.pid):
+        (ServerProcess._start):
+        (ServerProcess.stop):
+        * Scripts/webkitpy/layout_tests/port/server_process_unittest.py:
+        (FakeServerProcess._start):
+        (TestServerProcess.test_broken_pipe):
+
 2012-06-22  Peter Beverloo  <peter@chromium.org>
 
         [Chromium] Disable c++0x compatibility warnings in JavaScriptCore.gyp when building for Android
index 108cc5d..7e467dc 100644 (file)
@@ -67,6 +67,7 @@ class ServerProcess(object):
         self._cmd = cmd
         self._env = env
         self._host = self._port.host
+        self._pid = None
         self._reset()
 
         # See comment in imports for why we need the win32 APIs and can't just use select.
@@ -77,7 +78,7 @@ class ServerProcess(object):
         return self._name
 
     def pid(self):
-        return self._proc.pid
+        return self._pid
 
     def _reset(self):
         self._proc = None
@@ -100,6 +101,7 @@ class ServerProcess(object):
                                       stderr=subprocess.PIPE,
                                       close_fds=close_fds,
                                       env=self._env)
+        self._pid = self._proc.pid
         fd = self._proc.stdout.fileno()
         if not self._use_win32_apis:
             fl = fcntl.fcntl(fd, fcntl.F_GETFL)
@@ -301,7 +303,6 @@ class ServerProcess(object):
         if self.poll() is None:
             self._port.check_for_leaks(self.name(), self.pid())
 
-        pid = self._proc.pid
         self._proc.stdin.close()
         self._proc.stdout.close()
         if self._proc.stderr:
index b5ce053..c0426c1 100644 (file)
@@ -79,6 +79,7 @@ class FakeServerProcess(server_process.ServerProcess):
     def _start(self):
         self._proc = MockProc(self)
         self.stdin = self._proc.stdin
+        self._pid = self._proc.pid
         self.broken_pipes = []
 
 
@@ -119,6 +120,7 @@ class TestServerProcess(unittest.TestCase):
         server_process = FakeServerProcess(port_obj=port_obj, name="test", cmd=["test"])
         server_process.write("should break")
         self.assertTrue(server_process.has_crashed())
+        self.assertNotEquals(server_process.pid(), None)
         self.assertEquals(server_process._proc, None)
         self.assertEquals(server_process.broken_pipes, [server_process.stdin])