⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 99785 in webkit


Ignore:
Timestamp:
Nov 9, 2011, 5:04:21 PM (15 years ago)
Author:
eric@webkit.org
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:
Location:
trunk/Tools
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r99783 r99785  
     12011-11-09  Eric Seidel  <eric@webkit.org>
     2
     3        Remove more platform-dependent unittests
     4        https://bugs.webkit.org/show_bug.cgi?id=71971
     5
     6        Reviewed by Adam Barth.
     7
     8        Tests which only run on a couple platforms will break.
     9        All tests should run on all platforms where possible.
     10
     11        * Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py:
     12        * Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py:
     13        * Scripts/webkitpy/layout_tests/port/config_unittest.py:
     14        * Scripts/webkitpy/layout_tests/port/factory_unittest.py:
     15
    1162011-11-09  Ojan Vafai  <ojan@chromium.org>
    217
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_gpu_unittest.py

    r99773 r99785  
    3737class ChromiumGpuTest(unittest.TestCase):
    3838    def integration_test_chromium_gpu_linux(self):
    39         if sys.platform not in ('linux2', 'linux3'):
    40             return
    4139        self.assert_port_works('chromium-gpu-linux')
    4240        self.assert_port_works('chromium-gpu-linux', 'chromium-gpu', 'linux2')
     
    4442
    4543    def integration_test_chromium_gpu_mac(self):
    46         if sys.platform != 'darwin':
    47             return
    4844        self.assert_port_works('chromium-gpu-cg-mac')
    4945        self.assert_port_works('chromium-gpu-mac')
     
    5248
    5349    def integration_test_chromium_gpu_win(self):
    54         if sys.platform not in ('cygwin', 'win32'):
    55             return
    5650        self.assert_port_works('chromium-gpu-win')
    5751        self.assert_port_works('chromium-gpu-win', 'chromium-gpu', 'win32')
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py

    r99781 r99785  
    4545            self.register_cygwin = True
    4646            self.results_directory = '/'
    47 
    48     def setUp(self):
    49         self.orig_platform = sys.platform
    50 
    51     def tearDown(self):
    52         sys.platform = self.orig_platform
    53         self._port = None
    5447
    5548    port_maker = chromium_win.ChromiumWinPort
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/config_unittest.py

    r89868 r99785  
    3131import unittest
    3232
    33 from webkitpy.common.system import executive
    34 from webkitpy.common.system import executive_mock
    35 from webkitpy.common.system import filesystem
    36 from webkitpy.common.system import filesystem_mock
    37 from webkitpy.common.system import outputcapture
     33from webkitpy.common.system.executive import Executive, ScriptError
     34from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2
     35from webkitpy.common.system.filesystem import FileSystem
     36from webkitpy.common.system.filesystem_mock import MockFileSystem
     37from webkitpy.common.system.outputcapture import OutputCapture
    3838
    3939import config
    40 
    41 
    42 def mock_run_command(arg_list):
    43     # Set this to True to test actual output (where possible).
    44     integration_test = False
    45     if integration_test:
    46         return executive.Executive().run_command(arg_list)
    47 
    48     if 'webkit-build-directory' in arg_list[1]:
    49         return mock_webkit_build_directory(arg_list[2:])
    50     return 'Error'
    51 
    52 
    53 def mock_webkit_build_directory(arg_list):
    54     if arg_list == ['--top-level']:
    55         return '/WebKitBuild'
    56     elif arg_list == ['--configuration', '--debug']:
    57         return '/WebKitBuild/Debug'
    58     elif arg_list == ['--configuration', '--release']:
    59         return '/WebKitBuild/Release'
    60     return 'Error'
    6140
    6241
     
    6544        config.clear_cached_configuration()
    6645
    67     def make_config(self, output='', files={}, exit_code=0, exception=None,
    68                     run_command_fn=None):
    69         e = executive_mock.MockExecutive2(output=output, exit_code=exit_code,
    70                                           exception=exception,
    71                                           run_command_fn=run_command_fn)
    72         fs = filesystem_mock.MockFileSystem(files)
     46    def make_config(self, output='', files=None, exit_code=0, exception=None, run_command_fn=None):
     47        e = MockExecutive2(output=output, exit_code=exit_code, exception=exception, run_command_fn=run_command_fn)
     48        fs = MockFileSystem(files)
    7349        return config.Config(e, fs)
    7450
     
    8157    def test_build_directory(self):
    8258        # --top-level
     59        def mock_webkit_build_directory(arg_list):
     60            if arg_list == ['--top-level']:
     61                return '/WebKitBuild'
     62            elif arg_list == ['--configuration', '--debug']:
     63                return '/WebKitBuild/Debug'
     64            elif arg_list == ['--configuration', '--release']:
     65                return '/WebKitBuild/Release'
     66            return 'Error'
     67
     68        def mock_run_command(arg_list):
     69            if 'webkit-build-directory' in arg_list[1]:
     70                return mock_webkit_build_directory(arg_list[2:])
     71            return 'Error'
     72
    8373        c = self.make_config(run_command_fn=mock_run_command)
    8474        self.assertTrue(c.build_directory(None).endswith('WebKitBuild'))
     
    10595
    10696    def test_default_configuration__notfound(self):
    107         # This tests what happens if the default configuration file
    108         # doesn't exist.
     97        # This tests what happens if the default configuration file doesn't exist.
    10998        c = self.make_config(output='foo', files={'foo/Configuration': None})
    11099        self.assertEqual(c.default_configuration(), "Release")
     
    112101    def test_default_configuration__unknown(self):
    113102        # Ignore the warning about an unknown configuration value.
    114         oc = outputcapture.OutputCapture()
     103        oc = OutputCapture()
    115104        oc.capture_output()
    116105        self.assert_configuration('Unknown', 'Unknown')
     
    120109        # FIXME: This test runs a standalone python script to test
    121110        # reading the default configuration to work around any possible
    122         # caching / reset bugs. See https://bugs.webkit.org/show_bug?id=49360
     111        # caching / reset bugs. See https://bugs.webkit.org/show_bug.cgi?id=49360
    123112        # for the motivation. We can remove this test when we remove the
    124113        # global configuration cache in config.py.
    125         e = executive.Executive()
    126         fs = filesystem.FileSystem()
     114        e = Executive()
     115        fs = FileSystem()
    127116        c = config.Config(e, fs)
    128         script = c.path_from_webkit_base('Tools', 'Scripts',
    129             'webkitpy', 'layout_tests', 'port', 'config_standalone.py')
     117        script = c.path_from_webkit_base('Tools', 'Scripts', 'webkitpy', 'layout_tests', 'port', 'config_standalone.py')
    130118
    131119        # Note: don't use 'Release' here, since that's the normal default.
    132120        expected = 'Debug'
    133121
     122        # FIXME: Why are we running a python subprocess here??
    134123        args = [sys.executable, script, '--mock', expected]
    135124        actual = e.run_command(args).rstrip()
     
    148137        # configuration file is. See what happens if that script fails.
    149138        # (We should get the default value, 'Release').
    150         c = self.make_config(exception=executive.ScriptError())
     139        c = self.make_config(exception=ScriptError())
    151140        actual = c.default_configuration()
    152141        self.assertEqual(actual, 'Release')
    153142
    154143    def test_path_from_webkit_base(self):
    155         # FIXME: We use a real filesystem here. Should this move to a
    156         # mocked one?
    157         c = config.Config(executive.Executive(), filesystem.FileSystem())
     144        c = config.Config(MockExecutive(), MockFileSystem())
    158145        self.assertTrue(c.path_from_webkit_base('foo'))
    159146
    160147    def test_webkit_base_dir(self):
    161         # FIXME: We use a real filesystem here. Should this move to a
    162         # mocked one?
    163         c = config.Config(executive.Executive(), filesystem.FileSystem())
     148        # FIXME: We use a real filesystem here. Should this move to a mocked one?
     149        executive = Executive()
     150        filesystem = FileSystem()
     151        c = config.Config(executive, filesystem)
    164152        base_dir = c.webkit_base_dir()
    165153        self.assertTrue(base_dir)
    166154        self.assertNotEqual(base_dir[-1], '/')
    167155
    168         orig_cwd = os.getcwd()
     156        # FIXME: Once we use a MockFileSystem for this test we don't need to save the orig_cwd.
     157        orig_cwd = filesystem.getcwd()
    169158        if sys.platform == 'win32':
    170             os.chdir(os.environ['USERPROFILE'])
     159            filesystem.chdir(os.environ['USERPROFILE'])
    171160        else:
    172             os.chdir(os.environ['HOME'])
    173         c = config.Config(executive.Executive(), filesystem.FileSystem())
     161            filesystem.chdir(os.environ['HOME'])
     162        c = config.Config(executive, filesystem)
    174163        try:
    175164            base_dir_2 = c.webkit_base_dir()
    176165            self.assertEqual(base_dir, base_dir_2)
    177166        finally:
    178             os.chdir(orig_cwd)
     167            filesystem.chdir(orig_cwd)
    179168
    180169
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/factory_unittest.py

    r99233 r99785  
    9292        orig_platform = sys.platform
    9393        sys.platform = platform
     94        # FIXME: We need a better way to mock this.
    9495        self.assertTrue(isinstance(self.make_factory().get(options=options), expected_port))
    9596        sys.platform = orig_platform
Note: See TracChangeset for help on using the changeset viewer.