2010-11-19 Dirk Pranke <dpranke@chromium.org>
authordpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 20 Nov 2010 01:39:32 +0000 (01:39 +0000)
committerdpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 20 Nov 2010 01:39:32 +0000 (01:39 +0000)
        Reviewed by Ojan Vafai.

        nrwt - config.build_directory() is busted

        Fixes a typo that was causing us to usually return the top level
        directory WebKitBuild instead of WebKitBuild/{Debug,Release}. The
        bug was hidden by test stubs that were too simplistic :(.

        https://bugs.webkit.org/show_bug.cgi?id=49815

        * Scripts/webkitpy/common/system/executive_mock.py:
        * Scripts/webkitpy/layout_tests/port/config.py:
        * Scripts/webkitpy/layout_tests/port/config_unittest.py:

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

WebKitTools/ChangeLog
WebKitTools/Scripts/webkitpy/common/system/executive_mock.py
WebKitTools/Scripts/webkitpy/layout_tests/port/config.py
WebKitTools/Scripts/webkitpy/layout_tests/port/config_unittest.py

index 8ade104eadacf50bfb24c42dbfb9f8050a7e501b..853ee0af202d531cc1fe0b81db5c3b08deec3c18 100644 (file)
@@ -1,3 +1,19 @@
+2010-11-19  Dirk Pranke  <dpranke@chromium.org>
+
+        Reviewed by Ojan Vafai.
+
+        nrwt - config.build_directory() is busted
+
+        Fixes a typo that was causing us to usually return the top level
+        directory WebKitBuild instead of WebKitBuild/{Debug,Release}. The
+        bug was hidden by test stubs that were too simplistic :(.
+
+        https://bugs.webkit.org/show_bug.cgi?id=49815
+
+        * Scripts/webkitpy/common/system/executive_mock.py:
+        * Scripts/webkitpy/layout_tests/port/config.py:
+        * Scripts/webkitpy/layout_tests/port/config_unittest.py:
+
 2010-11-19  Steve Falkenburg  <sfalken@apple.com>
 
         Reviewed by Adam Roben.
index 7347ff90f1ec5bd5311e170c5696e9fc8dbf19cd..c1cf999c6f10bf8a4df60ada761a2fe4e103b135 100644 (file)
 
 
 class MockExecutive2(object):
-    def __init__(self, output='', exit_code=0, exception=None):
+    def __init__(self, output='', exit_code=0, exception=None,
+                 run_command_fn=None):
         self._output = output
         self._exit_code = exit_code
         self._exception = exception
+        self._run_command_fn = run_command_fn
 
     def cpu_count(self):
         return 2
@@ -52,4 +54,6 @@ class MockExecutive2(object):
             raise self._exception
         if return_exit_code:
             return self._exit_code
+        if self._run_command_fn:
+            return self._run_command_fn(arg_list)
         return self._output
index cad5e370027ea244184c132eab079f0f51d4484b..9aec637abdf55336e32e9787229ce0545e7f73f5 100644 (file)
@@ -75,7 +75,6 @@ class Config(object):
         if configuration:
             flags = ["--configuration",
                      self._FLAGS_FROM_CONFIGURATIONS[configuration]]
-            configuration = ""
         else:
             configuration = ""
             flags = ["--top-level"]
index 9bea014420070698efa6805c741d23d0daaa3cf4..2d2369108ea3ae70f9a58d2e1eda20ee27377e02 100644 (file)
@@ -38,13 +38,37 @@ from webkitpy.common.system import outputcapture
 
 import config
 
+
+def mock_run_command(arg_list):
+    # Set this to True to test actual output (where possible).
+    integration_test = False
+    if integration_test:
+        return executive.Executive().run_command(arg_list)
+
+    if 'webkit-build-directory' in arg_list[1]:
+        return mock_webkit_build_directory(arg_list[2:])
+    return 'Error'
+
+
+def mock_webkit_build_directory(arg_list):
+    if arg_list == ['--top-level']:
+        return '/WebKitBuild'
+    elif arg_list == ['--configuration', '--debug']:
+        return '/WebKitBuild/Debug'
+    elif arg_list == ['--configuration', '--release']:
+        return '/WebKitBuild/Release'
+    return 'Error'
+
+
 class ConfigTest(unittest.TestCase):
     def tearDown(self):
         config.clear_cached_configuration()
 
-    def make_config(self, output='', files={}, exit_code=0, exception=None):
+    def make_config(self, output='', files={}, exit_code=0, exception=None,
+                    run_command_fn=None):
         e = executive_mock.MockExecutive2(output=output, exit_code=exit_code,
-                                          exception=exception)
+                                          exception=exception,
+                                          run_command_fn=run_command_fn)
         fs = filesystem_mock.MockFileSystem(files)
         return config.Config(e, fs)
 
@@ -54,23 +78,17 @@ class ConfigTest(unittest.TestCase):
         c = self.make_config('foo', {'foo/Configuration': contents})
         self.assertEqual(c.default_configuration(), expected)
 
-    def test_build_directory_toplevel(self):
-        c = self.make_config('toplevel')
-        self.assertEqual(c.build_directory(None), 'toplevel')
+    def test_build_directory(self):
+        # --top-level
+        c = self.make_config(run_command_fn=mock_run_command)
+        self.assertTrue(c.build_directory(None).endswith('WebKitBuild'))
 
         # Test again to check caching
-        self.assertEqual(c.build_directory(None), 'toplevel')
-
-    def test_build_directory__release(self):
-        c = self.make_config('release')
-        self.assertEqual(c.build_directory('Release'), 'release')
-
-    def test_build_directory__debug(self):
-        c = self.make_config('debug')
-        self.assertEqual(c.build_directory('Debug'), 'debug')
+        self.assertTrue(c.build_directory(None).endswith('WebKitBuild'))
 
-    def test_build_directory__unknown(self):
-        c = self.make_config("unknown")
+        # Test other values
+        self.assertTrue(c.build_directory('Release').endswith('/Release'))
+        self.assertTrue(c.build_directory('Debug').endswith('/Debug'))
         self.assertRaises(KeyError, c.build_directory, 'Unknown')
 
     def test_build_dumprendertree__success(self):