[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

dpranke at chromium.org dpranke at chromium.org
Wed Dec 22 15:49:26 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 7869cf27bdf2cab1d170855aa5a4c5d42da0baf0
Author: dpranke at chromium.org <dpranke at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Nov 13 02:00:51 2010 +0000

    2010-11-12  Dirk Pranke  <dpranke at chromium.org>
    
            Reviewed by James Robinson.
    
            Attempt yet again to land the fix for bug 49360 (respecting
            set-webkit-configuration). We need to handle the cases where
            trying to run webkit-build-directory to find out where the
            default configuration might be fails (that shows up on some
            Chromium bots that apparently don't have perl installed).
    
            https://bugs.webkit.org/show_bug.cgi?id=49360
    
            * Scripts/webkitpy/layout_tests/port/config.py:
            * Scripts/webkitpy/layout_tests/port/config_standalone.py: Added.
            * Scripts/webkitpy/layout_tests/port/config_unittest.py:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71960 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index f9e5641..60cb2e6 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,19 @@
+2010-11-12  Dirk Pranke  <dpranke at chromium.org>
+
+        Reviewed by James Robinson.
+
+        Attempt yet again to land the fix for bug 49360 (respecting
+        set-webkit-configuration). We need to handle the cases where
+        trying to run webkit-build-directory to find out where the
+        default configuration might be fails (that shows up on some
+        Chromium bots that apparently don't have perl installed).
+
+        https://bugs.webkit.org/show_bug.cgi?id=49360
+
+        * Scripts/webkitpy/layout_tests/port/config.py:
+        * Scripts/webkitpy/layout_tests/port/config_standalone.py: Added.
+        * Scripts/webkitpy/layout_tests/port/config_unittest.py:
+
 2010-11-12  Mihai Parparita  <mihaip at chromium.org>
 
         Reviewed by Adam Barth.
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/config.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/config.py
index 4a0de96..cad5e37 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/port/config.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/config.py
@@ -35,21 +35,26 @@
 import os
 
 from webkitpy.common.system import logutils
+from webkitpy.common.system import executive
 
 
 _log = logutils.get_logger(__file__)
 
 #
-# This is used to record if we've already hit the filesystem to look
+# FIXME: This is used to record if we've already hit the filesystem to look
 # for a default configuration. We cache this to speed up the unit tests,
-# but this can be reset with clear_cached_configuration().
+# but this can be reset with clear_cached_configuration(). This should be
+# replaced with us consistently using MockConfigs() for tests that don't
+# hit the filesystem at all and provide a reliable value.
 #
-_determined_configuration = None
+_have_determined_configuration = False
+_configuration = "Release"
 
 
 def clear_cached_configuration():
-    global _determined_configuration
-    _determined_configuration = -1
+    global _have_determined_configuration, _configuration
+    _have_determined_configuration = False
+    _configuration = "Release"
 
 
 class Config(object):
@@ -137,8 +142,11 @@ class Config(object):
 
     def _determine_configuration(self):
         # This mirrors the logic in webkitdirs.pm:determineConfiguration().
-        global _determined_configuration
-        if _determined_configuration == -1:
+        #
+        # FIXME: See the comment at the top of the file regarding unit tests
+        # and our use of global mutable static variables.
+        global _have_determined_configuration, _configuration
+        if not _have_determined_configuration:
             contents = self._read_configuration()
             if not contents:
                 contents = "Release"
@@ -146,13 +154,17 @@ class Config(object):
                 contents = "Release"
             if contents == "Development":
                 contents = "Debug"
-            _determined_configuration = contents
-        return _determined_configuration
+            _configuration = contents
+            _have_determined_configuration = True
+        return _configuration
 
     def _read_configuration(self):
-        configuration_path = self._filesystem.join(self.build_directory(None),
-                                                   "Configuration")
-        if not self._filesystem.exists(configuration_path):
+        try:
+            configuration_path = self._filesystem.join(self.build_directory(None),
+                                                       "Configuration")
+            if not self._filesystem.exists(configuration_path):
+                return None
+        except (OSError, executive.ScriptError):
             return None
 
         return self._filesystem.read_text_file(configuration_path).rstrip()
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/config_standalone.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/config_standalone.py
new file mode 100644
index 0000000..3dec3b9
--- /dev/null
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/config_standalone.py
@@ -0,0 +1,70 @@
+# Copyright (C) 2010 Google Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#    * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#    * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#    * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+"""FIXME: This script is used by
+config_unittest.test_default_configuration__standalone() to read the
+default configuration to work around any possible caching / reset bugs. See
+https://bugs.webkit.org/show_bug?id=49360 for the motivation. We can remove
+this test when we remove the global configuration cache in config.py."""
+
+import os
+import unittest
+import sys
+
+
+# Ensure that webkitpy is in PYTHONPATH.
+this_dir = os.path.abspath(sys.path[0])
+up = os.path.dirname
+script_dir = up(up(up(this_dir)))
+if script_dir not in sys.path:
+    sys.path.append(script_dir)
+
+from webkitpy.common.system import executive
+from webkitpy.common.system import executive_mock
+from webkitpy.common.system import filesystem
+from webkitpy.common.system import filesystem_mock
+
+import config
+
+
+def main(argv=None):
+    if not argv:
+        argv = sys.argv
+
+    if len(argv) == 3 and argv[1] == '--mock':
+        e = executive_mock.MockExecutive2(output='foo')
+        fs = filesystem_mock.MockFileSystem({'foo/Configuration': argv[2]})
+    else:
+        e = executive.Executive()
+        fs = filesystem.FileSystem()
+
+    c = config.Config(e, fs)
+    print c.default_configuration()
+
+if __name__ == '__main__':
+    main()
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/config_unittest.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/config_unittest.py
index ed5ab8b..9bea014 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/port/config_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/config_unittest.py
@@ -27,6 +27,7 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 import os
+import sys
 import unittest
 
 from webkitpy.common.system import executive
@@ -41,14 +42,15 @@ class ConfigTest(unittest.TestCase):
     def tearDown(self):
         config.clear_cached_configuration()
 
-    def make_config(self, output='', files={}, exit_code=0):
-        e = executive_mock.MockExecutive2(output=output, exit_code=exit_code)
+    def make_config(self, output='', files={}, exit_code=0, exception=None):
+        e = executive_mock.MockExecutive2(output=output, exit_code=exit_code,
+                                          exception=exception)
         fs = filesystem_mock.MockFileSystem(files)
         return config.Config(e, fs)
 
     def assert_configuration(self, contents, expected):
         # This tests that a configuration file containing
-        # _contents_ endsd up being interpreted as _expected_.
+        # _contents_ ends up being interpreted as _expected_.
         c = self.make_config('foo', {'foo/Configuration': contents})
         self.assertEqual(c.default_configuration(), expected)
 
@@ -119,6 +121,41 @@ class ConfigTest(unittest.TestCase):
         self.assert_configuration('Unknown', 'Unknown')
         oc.restore_output()
 
+    def test_default_configuration__standalone(self):
+        # FIXME: This test runs a standalone python script to test
+        # reading the default configuration to work around any possible
+        # caching / reset bugs. See https://bugs.webkit.org/show_bug?id=49360
+        # for the motivation. We can remove this test when we remove the
+        # global configuration cache in config.py.
+        e = executive.Executive()
+        fs = filesystem.FileSystem()
+        c = config.Config(e, fs)
+        script = c.path_from_webkit_base('WebKitTools', 'Scripts',
+            'webkitpy', 'layout_tests', 'port', 'config_standalone.py')
+
+        # Note: don't use 'Release' here, since that's the normal default.
+        expected = 'Debug'
+
+        args = [sys.executable, script, '--mock', expected]
+        actual = e.run_command(args).rstrip()
+        self.assertEqual(actual, expected)
+
+    def test_default_configuration__no_perl(self):
+        # We need perl to run webkit-build-directory to find out where the
+        # default configuration file is. See what happens if perl isn't
+        # installed. (We should get the default value, 'Release').
+        c = self.make_config(exception=OSError)
+        actual = c.default_configuration()
+        self.assertEqual(actual, 'Release')
+
+    def test_default_configuration__scripterror(self):
+        # We run webkit-build-directory to find out where the default
+        # configuration file is. See what happens if that script fails.
+        # (We should get the default value, 'Release').
+        c = self.make_config(exception=executive.ScriptError())
+        actual = c.default_configuration()
+        self.assertEqual(actual, 'Release')
+
     def test_path_from_webkit_base(self):
         # FIXME: We use a real filesystem here. Should this move to a
         # mocked one?

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list