Title: [98825] trunk/Tools
Revision
98825
Author
[email protected]
Date
2011-10-30 00:57:04 -0700 (Sun, 30 Oct 2011)

Log Message

new-run-webkit-tests is locale dependent
https://bugs.webkit.org/show_bug.cgi?id=68691

Unreviewed.  I would have preferred to have this reviewed,
but relevant reviewers are asleep and bots are broken.

This was a regression from moving to a clean environment.
ChromiumWin (and possibly other ports), need the "PATH"
environment copied over.  This wasn't caught in my testing
because although we had unittests to cover this, they
weren't being run on anything but windows.  The vast majority
of this change is just fixing the unittests to use our
modern MockFileSystem/MockUser/MockExecutive so they can
be run on any system (and removing the platform checks from
the unittests so they are run everywhere).

The actual fix is the single line "PATH" string added to base.py.
The rest of this change is just fixing the Chromium port unittests
to run on all systems (including changing the Chromium port to
use FileSystem.path_to_module instead of __file__).

* Scripts/webkitpy/layout_tests/port/base.py:
* Scripts/webkitpy/layout_tests/port/chromium.py:
* Scripts/webkitpy/layout_tests/port/chromium_unittest.py:
* Scripts/webkitpy/layout_tests/port/chromium_win.py:
* Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py:
* Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (98824 => 98825)


--- trunk/Tools/ChangeLog	2011-10-30 05:36:14 UTC (rev 98824)
+++ trunk/Tools/ChangeLog	2011-10-30 07:57:04 UTC (rev 98825)
@@ -1,3 +1,33 @@
+2011-10-30  Eric Seidel  <[email protected]>
+
+        new-run-webkit-tests is locale dependent
+        https://bugs.webkit.org/show_bug.cgi?id=68691
+
+        Unreviewed.  I would have preferred to have this reviewed,
+        but relevant reviewers are asleep and bots are broken.
+
+        This was a regression from moving to a clean environment.
+        ChromiumWin (and possibly other ports), need the "PATH"
+        environment copied over.  This wasn't caught in my testing
+        because although we had unittests to cover this, they
+        weren't being run on anything but windows.  The vast majority
+        of this change is just fixing the unittests to use our
+        modern MockFileSystem/MockUser/MockExecutive so they can
+        be run on any system (and removing the platform checks from
+        the unittests so they are run everywhere).
+
+        The actual fix is the single line "PATH" string added to base.py.
+        The rest of this change is just fixing the Chromium port unittests
+        to run on all systems (including changing the Chromium port to
+        use FileSystem.path_to_module instead of __file__).
+
+        * Scripts/webkitpy/layout_tests/port/base.py:
+        * Scripts/webkitpy/layout_tests/port/chromium.py:
+        * Scripts/webkitpy/layout_tests/port/chromium_unittest.py:
+        * Scripts/webkitpy/layout_tests/port/chromium_win.py:
+        * Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py:
+        * Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py:
+
 2011-10-29  Eric Seidel  <[email protected]>
 
         new-run-webkit-tests is locale dependent

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py (98824 => 98825)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py	2011-10-30 05:36:14 UTC (rev 98824)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py	2011-10-30 07:57:04 UTC (rev 98825)
@@ -678,6 +678,9 @@
             'HOMEDRIVE',
             'HOMEPATH',
             '_NT_SYMBOL_PATH',
+
+            # Windows:
+            'PATH',
         ]
         for variable in variables_to_copy:
             self._copy_value_from_environ_if_set(clean_env, variable)

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py (98824 => 98825)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py	2011-10-30 05:36:14 UTC (rev 98824)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py	2011-10-30 07:57:04 UTC (rev 98825)
@@ -221,28 +221,22 @@
         """Returns the full path to path made by joining the top of the
         Chromium source tree and the list of path components in |*comps|."""
         if not self._chromium_base_dir:
-            abspath = self._filesystem.abspath(__file__)
-            offset = abspath.find('third_party')
+            chromium_module_path = self._filesystem.path_to_module(self.__module__)
+            offset = chromium_module_path.find('third_party')
             if offset == -1:
-                self._chromium_base_dir = self._filesystem.join(
-                    abspath[0:abspath.find('Tools')],
-                    'Source', 'WebKit', 'chromium')
+                self._chromium_base_dir = self._filesystem.join(chromium_module_path[0:chromium_module_path.find('Tools')], 'Source', 'WebKit', 'chromium')
             else:
-                self._chromium_base_dir = abspath[0:offset]
+                self._chromium_base_dir = chromium_module_path[0:offset]
         return self._filesystem.join(self._chromium_base_dir, *comps)
 
     def path_to_test_expectations_file(self):
-        return self.path_from_webkit_base('LayoutTests', 'platform',
-            'chromium', 'test_expectations.txt')
+        return self.path_from_webkit_base('LayoutTests', 'platform', 'chromium', 'test_expectations.txt')
 
     def default_results_directory(self):
         try:
-            return self.path_from_chromium_base('webkit',
-                self.get_option('configuration'),
-                'layout-test-results')
+            return self.path_from_chromium_base('webkit', self.get_option('configuration'), 'layout-test-results')
         except AssertionError:
-            return self._build_path(self.get_option('configuration'),
-                                    'layout-test-results')
+            return self._build_path(self.get_option('configuration'), 'layout-test-results')
 
     def setup_test_run(self):
         # Delete the disk cache if any to ensure a clean test run.

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py (98824 => 98825)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py	2011-10-30 05:36:14 UTC (rev 98824)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py	2011-10-30 07:57:04 UTC (rev 98825)
@@ -30,9 +30,9 @@
 import StringIO
 
 from webkitpy.common.system import logtesting
-from webkitpy.common.system import executive_mock
-from webkitpy.common.system import filesystem_mock
-from webkitpy.tool import mocktool
+from webkitpy.common.system.executive_mock import MockExecutive2
+from webkitpy.common.system.filesystem_mock import MockFileSystem
+from webkitpy.tool.mocktool import MockOptions, MockUser, MockExecutive
 from webkitpy.thirdparty.mock import Mock
 
 
@@ -47,7 +47,7 @@
 
 class ChromiumDriverTest(unittest.TestCase):
     def setUp(self):
-        mock_port = Mock()
+        mock_port = Mock()  # FIXME: This should use a tighter mock.
         mock_port.get_option = lambda option_name: ''
         self.driver = chromium.ChromiumDriver(mock_port, worker_number=0)
 
@@ -69,7 +69,7 @@
         self.assertEqual(did_crash, expected_crash)
 
     def test_write_command_and_read_line(self):
-        self.driver._proc = Mock()
+        self.driver._proc = Mock()  # FIXME: This should use a tighter mock.
         # Set up to read 3 lines before we get an IOError
         self.driver._proc.stdout = StringIO.StringIO("first\nsecond\nthird\n")
 
@@ -91,7 +91,7 @@
     def test_stop(self):
         self.pid = None
         self.wait_called = False
-        self.driver._proc = Mock()
+        self.driver._proc = Mock()  # FIXME: This should use a tighter mock.
         self.driver._proc.pid = 1
         self.driver._proc.stdin = StringIO.StringIO()
         self.driver._proc.stdout = StringIO.StringIO()
@@ -183,53 +183,42 @@
         pass
 
     class TestMacPort(chromium_mac.ChromiumMacPort):
-        def __init__(self, options):
-            # FIXME: This should use MockExecutive and MockUser as well.
-            chromium_mac.ChromiumMacPort.__init__(self,
-                                                  options=options,
-                                                  filesystem=filesystem_mock.MockFileSystem())
+        def __init__(self, options=None):
+            options = options or MockOptions()
+            chromium_mac.ChromiumMacPort.__init__(self, options=options,
+                filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())
 
         def default_configuration(self):
             self.default_configuration_called = True
             return 'default'
 
     class TestLinuxPort(chromium_linux.ChromiumLinuxPort):
-        def __init__(self, options):
-            # FIXME: This should use MockExecutive and MockUser as well.
-            chromium_linux.ChromiumLinuxPort.__init__(self,
-                                                      options=options,
-                                                      filesystem=filesystem_mock.MockFileSystem())
+        def __init__(self, options=None):
+            options = options or MockOptions()
+            chromium_linux.ChromiumLinuxPort.__init__(self, options=options,
+                filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())
 
         def default_configuration(self):
             self.default_configuration_called = True
             return 'default'
 
     class TestWinPort(chromium_win.ChromiumWinPort):
-        def __init__(self, options):
-            # FIXME: This should use MockExecutive and MockUser as well.
-            chromium_win.ChromiumWinPort.__init__(self,
-                                                  options=options,
-                                                  filesystem=filesystem_mock.MockFileSystem())
+        def __init__(self, options=None):
+            options = options or MockOptions()
+            chromium_win.ChromiumWinPort.__init__(self, options=options,
+                filesystem=MockFileSystem(), user=MockUser(), executive=MockExecutive())
 
         def default_configuration(self):
             self.default_configuration_called = True
             return 'default'
 
     def test_path_to_image_diff(self):
-        mock_options = mocktool.MockOptions()
-        port = ChromiumPortTest.TestLinuxPort(options=mock_options)
-        self.assertTrue(port._path_to_image_diff().endswith(
-            '/out/default/ImageDiff'))
-        port = ChromiumPortTest.TestMacPort(options=mock_options)
-        self.assertTrue(port._path_to_image_diff().endswith(
-            '/xcodebuild/default/ImageDiff'))
-        port = ChromiumPortTest.TestWinPort(options=mock_options)
-        self.assertTrue(port._path_to_image_diff().endswith(
-            '/default/ImageDiff.exe'))
+        self.assertTrue(ChromiumPortTest.TestLinuxPort()._path_to_image_diff().endswith('/out/default/ImageDiff'))
+        self.assertTrue(ChromiumPortTest.TestMacPort()._path_to_image_diff().endswith('/xcodebuild/default/ImageDiff'))
+        self.assertTrue(ChromiumPortTest.TestWinPort()._path_to_image_diff().endswith('/default/ImageDiff.exe'))
 
     def test_skipped_layout_tests(self):
-        mock_options = mocktool.MockOptions()
-        mock_options.configuration = 'release'
+        mock_options = MockOptions(configuration='release')
         port = ChromiumPortTest.TestLinuxPort(options=mock_options)
 
         fake_test = 'fast/js/not-good.js'
@@ -244,12 +233,12 @@
         self.assertTrue("fast/js/not-good.js" in skipped_tests)
 
     def test_default_configuration(self):
-        mock_options = mocktool.MockOptions()
+        mock_options = MockOptions()
         port = ChromiumPortTest.TestLinuxPort(options=mock_options)
         self.assertEquals(mock_options.configuration, 'default')
         self.assertTrue(port.default_configuration_called)
 
-        mock_options = mocktool.MockOptions(configuration=None)
+        mock_options = MockOptions(configuration=None)
         port = ChromiumPortTest.TestLinuxPort(mock_options)
         self.assertEquals(mock_options.configuration, 'default')
         self.assertTrue(port.default_configuration_called)
@@ -259,9 +248,7 @@
             def _path_to_image_diff(self):
                 return "/path/to/image_diff"
 
-        mock_options = mocktool.MockOptions()
-        port = ChromiumPortTest.TestLinuxPort(mock_options)
-
+        port = ChromiumPortTest.TestLinuxPort()
         mock_image_diff = "MOCK Image Diff"
 
         def mock_run_command(args):
@@ -269,15 +256,15 @@
             return 1
 
         # Images are different.
-        port._executive = executive_mock.MockExecutive2(run_command_fn=mock_run_command)
+        port._executive = MockExecutive2(run_command_fn=mock_run_command)
         self.assertEquals(mock_image_diff, port.diff_image("EXPECTED", "ACTUAL")[0])
 
         # Images are the same.
-        port._executive = executive_mock.MockExecutive2(exit_code=0)
+        port._executive = MockExecutive2(exit_code=0)
         self.assertEquals(None, port.diff_image("EXPECTED", "ACTUAL")[0])
 
         # There was some error running image_diff.
-        port._executive = executive_mock.MockExecutive2(exit_code=2)
+        port._executive = MockExecutive2(exit_code=2)
         exception_raised = False
         try:
             port.diff_image("EXPECTED", "ACTUAL")
@@ -290,7 +277,7 @@
         if not port:
             return
 
-        filesystem = filesystem_mock.MockFileSystem()
+        filesystem = MockFileSystem()
         port._filesystem = filesystem
         port.path_from_chromium_base = lambda *comps: '/' + '/'.join(comps)
 
@@ -310,15 +297,14 @@
 
 class ChromiumPortLoggingTest(logtesting.LoggingTestCase):
     def test_check_sys_deps(self):
-        mock_options = mocktool.MockOptions()
-        port = ChromiumPortTest.TestLinuxPort(options=mock_options)
+        port = ChromiumPortTest.TestLinuxPort()
 
         # Success
-        port._executive = executive_mock.MockExecutive2(exit_code=0)
+        port._executive = MockExecutive2(exit_code=0)
         self.assertTrue(port.check_sys_deps(needs_http=False))
 
         # Failure
-        port._executive = executive_mock.MockExecutive2(exit_code=1,
+        port._executive = MockExecutive2(exit_code=1,
             output='testing output failure')
         self.assertFalse(port.check_sys_deps(needs_http=False))
         self.assertLog([

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win.py (98824 => 98825)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win.py	2011-10-30 05:36:14 UTC (rev 98824)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win.py	2011-10-30 07:57:04 UTC (rev 98825)
@@ -122,13 +122,13 @@
                 _log.debug('Failed to engage svn.bat Windows hack.')
 
     def setup_environ_for_server(self, server_name=None):
-        env = chromium.ChromiumPort.setup_environ_for_server(self)
+        env = chromium.ChromiumPort.setup_environ_for_server(self, server_name)
         # Put the cygwin directory first in the path to find cygwin1.dll.
         env["PATH"] = "%s;%s" % (self.path_from_chromium_base("third_party", "cygwin", "bin"), env["PATH"])
         # Configure the cygwin directory so that pywebsocket finds proper
         # python executable to run cgi program.
         env["CYGWIN_PATH"] = self.path_from_chromium_base("third_party", "cygwin", "bin")
-        if (sys.platform in ("cygwin", "win32") and self.get_option('register_cygwin')):
+        if self.get_option('register_cygwin'):
             setup_mount = self.path_from_chromium_base("third_party", "cygwin", "setup_mount.bat")
             self._executive.run_command([setup_mount])  # Paths are all absolute, so this does not require a cwd.
         return env

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


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py	2011-10-30 05:36:14 UTC (rev 98824)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py	2011-10-30 07:57:04 UTC (rev 98825)
@@ -52,53 +52,40 @@
         self._port = None
 
     def port_maker(self, platform):
-        if platform not in ('cygwin', 'win32'):
-            return None
         return chromium_win.ChromiumWinPort
 
-    def _mock_path_from_chromium_base(self, *comps):
-        return self._port._filesystem.join("/chromium/src", *comps)
-
     def test_uses_apache(self):
-        port = self.make_port()
-        if not port:
-            return
+        self.assertFalse(self.make_port()._uses_apache())
 
-        self.assertFalse(port._uses_apache())
-
     def test_setup_environ_for_server(self):
         port = self.make_port()
-        if not port:
-            return
-
         port._executive = mocktool.MockExecutive(should_log=True)
-        self._port = port
-        port.path_from_chromium_base = self._mock_path_from_chromium_base
         output = outputcapture.OutputCapture()
+        # FIXME: This test should not use the real os.environ
         orig_environ = os.environ.copy()
         env = output.assert_outputs(self, port.setup_environ_for_server)
         self.assertEqual(orig_environ["PATH"], os.environ["PATH"])
         self.assertNotEqual(env["PATH"], os.environ["PATH"])
 
+    def test_setup_environ_for_server_cygpath(self):
+        port = self.make_port()
+        env = port.setup_environ_for_server(port.driver_name())
+        self.assertEquals(env['CYGWIN_PATH'], '/mock-checkout/Source/WebKit/chromium/third_party/cygwin/bin')
+
     def test_setup_environ_for_server_register_cygwin(self):
         port = self.make_port(options=ChromiumWinTest.RegisterCygwinOption())
-        if not port:
-            return
-
         port._executive = mocktool.MockExecutive(should_log=True)
-        port.path_from_chromium_base = self._mock_path_from_chromium_base
-        self._port = port
-        setup_mount = self._mock_path_from_chromium_base("third_party", "cygwin", "setup_mount.bat")
-        expected_stderr = "MOCK run_command: %s, cwd=None\n" % [setup_mount]
+        expected_stderr = "MOCK run_command: ['/mock-checkout/Source/WebKit/chromium/third_party/cygwin/setup_mount.bat'], cwd=None\n"
         output = outputcapture.OutputCapture()
         output.assert_outputs(self, port.setup_environ_for_server, expected_stderr=expected_stderr)
 
     def assert_name(self, port_name, windows_version, expected):
-        port = chromium_win.ChromiumWinPort(port_name=port_name,
-                                            windows_version=windows_version)
+        # FIXME: This should use make_port or pass MockFileSystem/MockUser/MockExecutive directly.
+        port = chromium_win.ChromiumWinPort(port_name=port_name, windows_version=windows_version)
         self.assertEquals(expected, port.name())
 
     def test_versions(self):
+        # FIXME: This should use make_port or pass MockFileSystem/MockUser/MockExecutive directly.
         port = chromium_win.ChromiumWinPort()
         self.assertTrue(port.name() in ('chromium-win-xp', 'chromium-win-vista', 'chromium-win-win7'))
 
@@ -126,6 +113,7 @@
         self.assertRaises(KeyError, self.assert_name, None, (7, 1), 'chromium-win-xp')
 
     def test_baseline_path(self):
+        # FIXME: This should use make_port or pass MockFileSystem/MockUser/MockExecutive directly.
         port = chromium_win.ChromiumWinPort(port_name='chromium-win-xp')
         self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-win-xp'))
 
@@ -136,17 +124,14 @@
         self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-win'))
 
     def test_build_path(self):
-        mock = MockFileSystem(files={
-            '/mock-checkout/Source/WebKit/chromium/build/Release/DumpRenderTree.exe': 'exe'})
+        mock_filesystem = MockFileSystem(files={
+            '/mock-checkout/Source/WebKit/chromium/build/Release/DumpRenderTree.exe': 'exe'
+        })
 
-        port = chromium_win.ChromiumWinPort(filesystem=mock)
+        port = chromium_win.ChromiumWinPort(filesystem=mock_filesystem)
         self.assertEquals(
             '/mock-checkout/Source/WebKit/chromium/build/Release/DumpRenderTree.exe',
             port._path_to_driver('Release'))
         self.assertEquals(
             '/mock-checkout/Source/WebKit/chromium/build/Debug/DumpRenderTree.exe',
             port._path_to_driver('Debug'))
-
-
-if __name__ == '__main__':
-    port_testcase.main()

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py (98824 => 98825)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py	2011-10-30 05:36:14 UTC (rev 98824)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/google_chrome_unittest.py	2011-10-30 07:57:04 UTC (rev 98825)
@@ -45,19 +45,21 @@
         self._verify_baseline_path('google-chrome-win', 'google-chrome-win-vista')
 
     def _verify_baseline_path(self, expected_path, port_name):
-        port = google_chrome.GetGoogleChromePort(port_name=port_name,
-                                                 options=None)
+        # FIXME: This should use a MockFileSystem, MockUser and MockExecutive.
+        port = google_chrome.GetGoogleChromePort(port_name=port_name, options=None)
         path = port.baseline_search_path()[0]
         self.assertEqual(expected_path, port._filesystem.basename(path))
 
     def _verify_expectations_overrides(self, port_name):
-        # FIXME: make this more robust when we have the Tree() abstraction.
+        # FIXME: Make this more robust when we have the Tree() abstraction.
         # we should be able to test for the files existing or not, and
         # be able to control the contents better.
+        # FIXME: What is the Tree() abstraction?
 
-        chromium_port = factory.get("chromium-cg-mac")
+        fs = filesystem_mock.MockFileSystem()
+        chromium_port = factory.get("chromium-cg-mac", filesystem=fs)
         chromium_base = chromium_port.path_from_chromium_base()
-        fs = filesystem_mock.MockFileSystem()
+        # FIXME: This should use a MockFileSystem, MockUser and MockExecutive.
         port = google_chrome.GetGoogleChromePort(port_name=port_name,
                                                  options=None, filesystem=fs)
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to