Title: [99785] trunk/Tools
Revision
99785
Author
[email protected]
Date
2011-11-09 17:04:21 -0800 (Wed, 09 Nov 2011)

Log Message

Remove more platform-dependent unittests
https://bugs.webkit.org/show_bug.cgi?id=71971

Reviewed by Adam Barth.

Tests which only run on a couple platforms will break.
All tests should run on all platforms where possible.

* Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py:
* Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py:
* Scripts/webkitpy/layout_tests/port/config_unittest.py:
* Scripts/webkitpy/layout_tests/port/factory_unittest.py:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (99784 => 99785)


--- trunk/Tools/ChangeLog	2011-11-10 01:03:06 UTC (rev 99784)
+++ trunk/Tools/ChangeLog	2011-11-10 01:04:21 UTC (rev 99785)
@@ -1,3 +1,18 @@
+2011-11-09  Eric Seidel  <[email protected]>
+
+        Remove more platform-dependent unittests
+        https://bugs.webkit.org/show_bug.cgi?id=71971
+
+        Reviewed by Adam Barth.
+
+        Tests which only run on a couple platforms will break.
+        All tests should run on all platforms where possible.
+
+        * Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py:
+        * Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py:
+        * Scripts/webkitpy/layout_tests/port/config_unittest.py:
+        * Scripts/webkitpy/layout_tests/port/factory_unittest.py:
+
 2011-11-09  Ojan Vafai  <[email protected]>
 
         Merge in results to the test results server even if build numbers conflict

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py (99784 => 99785)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py	2011-11-10 01:03:06 UTC (rev 99784)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py	2011-11-10 01:04:21 UTC (rev 99785)
@@ -36,23 +36,17 @@
 
 class ChromiumGpuTest(unittest.TestCase):
     def integration_test_chromium_gpu_linux(self):
-        if sys.platform not in ('linux2', 'linux3'):
-            return
         self.assert_port_works('chromium-gpu-linux')
         self.assert_port_works('chromium-gpu-linux', 'chromium-gpu', 'linux2')
         self.assert_port_works('chromium-gpu-linux', 'chromium-gpu', 'linux3')
 
     def integration_test_chromium_gpu_mac(self):
-        if sys.platform != 'darwin':
-            return
         self.assert_port_works('chromium-gpu-cg-mac')
         self.assert_port_works('chromium-gpu-mac')
         # For now, chromium-gpu on Mac defaults to the chromium-gpu-cg-mac port.
         self.assert_port_works('chromium-gpu-cg-mac', 'chromium-gpu', 'darwin')
 
     def integration_test_chromium_gpu_win(self):
-        if sys.platform not in ('cygwin', 'win32'):
-            return
         self.assert_port_works('chromium-gpu-win')
         self.assert_port_works('chromium-gpu-win', 'chromium-gpu', 'win32')
         self.assert_port_works('chromium-gpu-win', 'chromium-gpu', 'cygwin')

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py (99784 => 99785)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py	2011-11-10 01:03:06 UTC (rev 99784)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py	2011-11-10 01:04:21 UTC (rev 99785)
@@ -45,13 +45,6 @@
             self.register_cygwin = True
             self.results_directory = '/'
 
-    def setUp(self):
-        self.orig_platform = sys.platform
-
-    def tearDown(self):
-        sys.platform = self.orig_platform
-        self._port = None
-
     port_maker = chromium_win.ChromiumWinPort
 
     def _mock_path_from_chromium_base(self, *comps):

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/config_unittest.py (99784 => 99785)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/config_unittest.py	2011-11-10 01:03:06 UTC (rev 99784)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/config_unittest.py	2011-11-10 01:04:21 UTC (rev 99785)
@@ -30,46 +30,22 @@
 import sys
 import unittest
 
-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
-from webkitpy.common.system import outputcapture
+from webkitpy.common.system.executive import Executive, ScriptError
+from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2
+from webkitpy.common.system.filesystem import FileSystem
+from webkitpy.common.system.filesystem_mock import MockFileSystem
+from webkitpy.common.system.outputcapture 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,
-                    run_command_fn=None):
-        e = executive_mock.MockExecutive2(output=output, exit_code=exit_code,
-                                          exception=exception,
-                                          run_command_fn=run_command_fn)
-        fs = filesystem_mock.MockFileSystem(files)
+    def make_config(self, output='', files=None, exit_code=0, exception=None, run_command_fn=None):
+        e = MockExecutive2(output=output, exit_code=exit_code, exception=exception, run_command_fn=run_command_fn)
+        fs = MockFileSystem(files)
         return config.Config(e, fs)
 
     def assert_configuration(self, contents, expected):
@@ -80,6 +56,20 @@
 
     def test_build_directory(self):
         # --top-level
+        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'
+
+        def mock_run_command(arg_list):
+            if 'webkit-build-directory' in arg_list[1]:
+                return mock_webkit_build_directory(arg_list[2:])
+            return 'Error'
+
         c = self.make_config(run_command_fn=mock_run_command)
         self.assertTrue(c.build_directory(None).endswith('WebKitBuild'))
 
@@ -104,14 +94,13 @@
         self.assert_configuration('Development', 'Debug')
 
     def test_default_configuration__notfound(self):
-        # This tests what happens if the default configuration file
-        # doesn't exist.
+        # This tests what happens if the default configuration file doesn't exist.
         c = self.make_config(output='foo', files={'foo/Configuration': None})
         self.assertEqual(c.default_configuration(), "Release")
 
     def test_default_configuration__unknown(self):
         # Ignore the warning about an unknown configuration value.
-        oc = outputcapture.OutputCapture()
+        oc = OutputCapture()
         oc.capture_output()
         self.assert_configuration('Unknown', 'Unknown')
         oc.restore_output()
@@ -119,18 +108,18 @@
     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
+        # caching / reset bugs. See https://bugs.webkit.org/show_bug.cgi?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()
+        e = Executive()
+        fs = FileSystem()
         c = config.Config(e, fs)
-        script = c.path_from_webkit_base('Tools', 'Scripts',
-            'webkitpy', 'layout_tests', 'port', 'config_standalone.py')
+        script = c.path_from_webkit_base('Tools', 'Scripts', 'webkitpy', 'layout_tests', 'port', 'config_standalone.py')
 
         # Note: don't use 'Release' here, since that's the normal default.
         expected = 'Debug'
 
+        # FIXME: Why are we running a python subprocess here??
         args = [sys.executable, script, '--mock', expected]
         actual = e.run_command(args).rstrip()
         self.assertEqual(actual, expected)
@@ -147,35 +136,35 @@
         # 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())
+        c = self.make_config(exception=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?
-        c = config.Config(executive.Executive(), filesystem.FileSystem())
+        c = config.Config(MockExecutive(), MockFileSystem())
         self.assertTrue(c.path_from_webkit_base('foo'))
 
     def test_webkit_base_dir(self):
-        # FIXME: We use a real filesystem here. Should this move to a
-        # mocked one?
-        c = config.Config(executive.Executive(), filesystem.FileSystem())
+        # FIXME: We use a real filesystem here. Should this move to a mocked one?
+        executive = Executive()
+        filesystem = FileSystem()
+        c = config.Config(executive, filesystem)
         base_dir = c.webkit_base_dir()
         self.assertTrue(base_dir)
         self.assertNotEqual(base_dir[-1], '/')
 
-        orig_cwd = os.getcwd()
+        # FIXME: Once we use a MockFileSystem for this test we don't need to save the orig_cwd.
+        orig_cwd = filesystem.getcwd()
         if sys.platform == 'win32':
-            os.chdir(os.environ['USERPROFILE'])
+            filesystem.chdir(os.environ['USERPROFILE'])
         else:
-            os.chdir(os.environ['HOME'])
-        c = config.Config(executive.Executive(), filesystem.FileSystem())
+            filesystem.chdir(os.environ['HOME'])
+        c = config.Config(executive, filesystem)
         try:
             base_dir_2 = c.webkit_base_dir()
             self.assertEqual(base_dir, base_dir_2)
         finally:
-            os.chdir(orig_cwd)
+            filesystem.chdir(orig_cwd)
 
 
 if __name__ == '__main__':

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/factory_unittest.py (99784 => 99785)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/factory_unittest.py	2011-11-10 01:03:06 UTC (rev 99784)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/factory_unittest.py	2011-11-10 01:04:21 UTC (rev 99785)
@@ -91,6 +91,7 @@
         # FIXME: Hacking sys.platform like this is WRONG.
         orig_platform = sys.platform
         sys.platform = platform
+        # FIXME: We need a better way to mock this.
         self.assertTrue(isinstance(self.make_factory().get(options=options), expected_port))
         sys.platform = orig_platform
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to