[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

dpranke at chromium.org dpranke at chromium.org
Sun Feb 20 23:51:22 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 35fc81417f1a2253be289156ffb112bd5c2c7c13
Author: dpranke at chromium.org <dpranke at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Jan 25 22:52:17 2011 +0000

    2011-01-25  Dirk Pranke  <dpranke at chromium.org>
    
            Reviewed by Tony Chang.
    
            Minor bug fixes and cleanup for filesystem wrappers, port/* test
            classes, test_expectations.py. This change adds "test-win" and
            "test-mac" variants to the test port so that we can better test
            rebaselining, and adds a MockUser() object for reuse in testing.
    
            https://bugs.webkit.org/show_bug.cgi?id=53036
    
            * Scripts/webkitpy/common/system/filesystem.py:
            * Scripts/webkitpy/common/system/filesystem_mock.py:
            * Scripts/webkitpy/layout_tests/layout_package/test_expectations.py:
            * Scripts/webkitpy/layout_tests/port/factory.py:
            * Scripts/webkitpy/layout_tests/port/base.py:
            * Scripts/webkitpy/layout_tests/port/test.py:
            * Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py:
            * Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests_unittest.py:
            * Scripts/webkitpy/tool/mocktool.py:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76642 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index c198116..8486da0 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,24 @@
+2011-01-25  Dirk Pranke  <dpranke at chromium.org>
+
+        Reviewed by Tony Chang.
+
+        Minor bug fixes and cleanup for filesystem wrappers, port/* test
+        classes, test_expectations.py. This change adds "test-win" and
+        "test-mac" variants to the test port so that we can better test
+        rebaselining, and adds a MockUser() object for reuse in testing.
+
+        https://bugs.webkit.org/show_bug.cgi?id=53036
+
+        * Scripts/webkitpy/common/system/filesystem.py:
+        * Scripts/webkitpy/common/system/filesystem_mock.py:
+        * Scripts/webkitpy/layout_tests/layout_package/test_expectations.py:
+        * Scripts/webkitpy/layout_tests/port/factory.py:
+        * Scripts/webkitpy/layout_tests/port/base.py:
+        * Scripts/webkitpy/layout_tests/port/test.py:
+        * Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py:
+        * Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests_unittest.py:
+        * Scripts/webkitpy/tool/mocktool.py:
+
 2011-01-25  Tony Chang  <tony at chromium.org>
 
         Reviewed by Dimitri Glazkov.
diff --git a/Tools/Scripts/webkitpy/common/system/filesystem.py b/Tools/Scripts/webkitpy/common/system/filesystem.py
index 05513a9..b15d4c3 100644
--- a/Tools/Scripts/webkitpy/common/system/filesystem.py
+++ b/Tools/Scripts/webkitpy/common/system/filesystem.py
@@ -165,8 +165,8 @@ class FileSystem(object):
             if e.errno != errno.EEXIST:
                 raise
 
-    def move(self, src, dest):
-        shutil.move(src, dest)
+    def move(self, source, destination):
+        shutil.move(source, destination)
 
     def mtime(self, path):
         return os.stat(path).st_mtime
diff --git a/Tools/Scripts/webkitpy/common/system/filesystem_mock.py b/Tools/Scripts/webkitpy/common/system/filesystem_mock.py
index 0004944..8ec31de 100644
--- a/Tools/Scripts/webkitpy/common/system/filesystem_mock.py
+++ b/Tools/Scripts/webkitpy/common/system/filesystem_mock.py
@@ -69,6 +69,7 @@ class MockFileSystem(object):
             raise IOError(errno.EISDIR, destination, os.strerror(errno.ISDIR))
 
         self.files[destination] = self.files[source]
+        self.written_files[destination] = self.files[source]
 
     def dirname(self, path):
         return self._split(path)[0]
@@ -196,18 +197,20 @@ class MockFileSystem(object):
         # FIXME: Implement such that subsequent calls to isdir() work?
         pass
 
-    def move(self, src, dst):
-        if self.files[src] is None:
-            self._raise_not_found(src)
-        self.files[dst] = self.files[src]
-        self.files[src] = None
+    def move(self, source, destination):
+        if self.files[source] is None:
+            self._raise_not_found(source)
+        self.files[destination] = self.files[source]
+        self.written_files[destination] = self.files[destination]
+        self.files[source] = None
+        self.written_files[source] = None
 
     def normpath(self, path):
         return path
 
-    def open_binary_tempfile(self, suffix):
+    def open_binary_tempfile(self, suffix=''):
         path = self._mktemp(suffix)
-        return WritableFileObject(self, path), path
+        return (WritableFileObject(self, path), path)
 
     def open_text_file_for_writing(self, path, append=False):
         return WritableFileObject(self, path, append)
@@ -225,6 +228,7 @@ class MockFileSystem(object):
         if self.files[path] is None:
             self._raise_not_found(path)
         self.files[path] = None
+        self.written_files[path] = None
 
     def rmtree(self, path):
         if not path.endswith('/'):
diff --git a/Tools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py b/Tools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py
index 806b663..acadcb3 100644
--- a/Tools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py
+++ b/Tools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py
@@ -89,7 +89,7 @@ class TestExpectations:
         """Loads and parses the test expectations given in the string.
         Args:
             port: handle to object containing platform-specific functionality
-            test: list of all of the test files
+            tests: list of all of the test files
             expectations: test expectations as a string
             test_platform_name: name of the platform to match expectations
                 against. Note that this may be different than
diff --git a/Tools/Scripts/webkitpy/layout_tests/port/base.py b/Tools/Scripts/webkitpy/layout_tests/port/base.py
index 6e5fabc..aeebc66 100644
--- a/Tools/Scripts/webkitpy/layout_tests/port/base.py
+++ b/Tools/Scripts/webkitpy/layout_tests/port/base.py
@@ -582,7 +582,7 @@ class Port(object):
 
         Basically this string should contain the equivalent of a
         test_expectations file. See test_expectations.py for more details."""
-        raise NotImplementedError('Port.test_expectations')
+        return self._filesystem.read_text_file(self.path_to_test_expectations_file())
 
     def test_expectations_overrides(self):
         """Returns an optional set of overrides for the test_expectations.
diff --git a/Tools/Scripts/webkitpy/layout_tests/port/factory.py b/Tools/Scripts/webkitpy/layout_tests/port/factory.py
index 6935744..675e0c0 100644
--- a/Tools/Scripts/webkitpy/layout_tests/port/factory.py
+++ b/Tools/Scripts/webkitpy/layout_tests/port/factory.py
@@ -70,7 +70,7 @@ def _get_kwargs(**kwargs):
         raise NotImplementedError('unknown port; sys.platform = "%s"' %
                                   sys.platform)
 
-    if port_to_use == 'test':
+    if port_to_use.startswith('test'):
         import test
         maker = test.TestPort
     elif port_to_use.startswith('dryrun'):
diff --git a/Tools/Scripts/webkitpy/layout_tests/port/test.py b/Tools/Scripts/webkitpy/layout_tests/port/test.py
index 5df5c2d..a9d5884 100644
--- a/Tools/Scripts/webkitpy/layout_tests/port/test.py
+++ b/Tools/Scripts/webkitpy/layout_tests/port/test.py
@@ -33,6 +33,7 @@ from __future__ import with_statement
 import time
 
 from webkitpy.common.system import filesystem_mock
+from webkitpy.tool import mocktool
 
 from webkitpy.layout_tests.layout_package import test_output
 
@@ -192,26 +193,22 @@ WONTFIX SKIP : failures/expected/exception.html = CRASH
 class TestPort(base.Port):
     """Test implementation of the Port interface."""
 
-    def __init__(self, **kwargs):
-        # FIXME: what happens if we're not passed in the test filesystem
-        # and the tests don't match what's in the filesystem?
-        #
-        # We'll leave as is for now to avoid unnecessary dependencies while
-        # converting all of the unit tests over to using
-        # unit_test_filesystem(). If things get out of sync the tests should
-        # fail in fairly obvious ways. Eventually we want to just do:
-        #
-        # assert kwargs['filesystem']._tests
-        # self._tests = kwargs['filesystem']._tests
-
-        if 'filesystem' not in kwargs or kwargs['filesystem'] is None:
-            kwargs['filesystem'] = unit_test_filesystem()
-            self._tests = kwargs['filesystem']._tests
-        else:
-            self._tests = unit_test_list()
-
-        kwargs.setdefault('port_name', 'test')
-        base.Port.__init__(self, **kwargs)
+    def __init__(self, port_name=None, user=None, filesystem=None, **kwargs):
+        if not filesystem:
+            filesystem = unit_test_filesystem()
+
+        assert filesystem._tests
+        self._tests = filesystem._tests
+
+        if not user:
+            user = mocktool.MockUser()
+
+        if not port_name or port_name == 'test':
+            port_name = 'test-mac'
+
+        self._expectations_path = LAYOUT_TEST_DIR + '/platform/test/test_expectations.txt'
+        base.Port.__init__(self, port_name=port_name, filesystem=filesystem, user=user,
+                           **kwargs)
 
     def baseline_path(self):
         return self._filesystem.join(self.layout_tests_dir(), 'platform',
@@ -264,17 +261,23 @@ class TestPort(base.Port):
     def test_base_platform_names(self):
         return ('mac', 'win')
 
-    def test_expectations(self):
-        return self._filesystem.read_text_file(LAYOUT_TEST_DIR + '/platform/test/test_expectations.txt')
+    def path_to_test_expectations_file(self):
+        return self._expectations_path
 
     def test_platform_name(self):
+        if self._name == 'test-win':
+            return 'win'
         return 'mac'
 
     def test_platform_names(self):
         return self.test_base_platform_names()
 
     def test_platform_name_to_name(self, test_platform_name):
-        return test_platform_name
+        name_map = {
+            'mac': 'test-mac',
+            'win': 'test-win',
+        }
+        return name_map[test_platform_name]
 
     def version(self):
         return ''
diff --git a/Tools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests_unittest.py b/Tools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests_unittest.py
index 50c0204..a0f5eeb 100644
--- a/Tools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests_unittest.py
+++ b/Tools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests_unittest.py
@@ -32,7 +32,6 @@
 import unittest
 
 from webkitpy.tool import mocktool
-from webkitpy.common.system import filesystem_mock
 from webkitpy.common.system.executive import Executive, ScriptError
 
 import port
@@ -88,11 +87,11 @@ class TestRebaseliner(unittest.TestCase):
     def make_rebaseliner(self):
         options = mocktool.MockOptions(configuration=None,
                                        html_directory=None)
-        filesystem = filesystem_mock.MockFileSystem()
+        filesystem = port.unit_test_filesystem()
         host_port_obj = port.get('test', options, filesystem=filesystem)
         target_options = options
         target_port_obj = port.get('test', target_options, filesystem=filesystem)
-        platform = 'test'
+        platform = target_port_obj.test_platform_name()
         return rebaseline_chromium_webkit_tests.Rebaseliner(
             host_port_obj, target_port_obj, platform, options)
 
@@ -131,7 +130,7 @@ class TestRebaseliner(unittest.TestCase):
 class TestHtmlGenerator(unittest.TestCase):
     def make_generator(self, files, tests):
         options = mocktool.MockOptions(configuration=None, html_directory='/tmp')
-        host_port = port.get('test', options, filesystem=filesystem_mock.MockFileSystem(files))
+        host_port = port.get('test', options, filesystem=port.unit_test_filesystem(files))
         generator = rebaseline_chromium_webkit_tests.HtmlGenerator(
             host_port,
             target_port=None,
diff --git a/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py b/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py
index 677becd..112e402 100644
--- a/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py
+++ b/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py
@@ -45,7 +45,7 @@ import unittest
 from webkitpy.common import array_stream
 from webkitpy.common.system import outputcapture
 from webkitpy.common.system import filesystem_mock
-from webkitpy.common.system import user
+from webkitpy.tool import mocktool
 from webkitpy.layout_tests import port
 from webkitpy.layout_tests import run_webkit_tests
 from webkitpy.layout_tests.layout_package import dump_render_tree_thread
@@ -56,14 +56,6 @@ from webkitpy.test.skip import skip_if
 from webkitpy.thirdparty.mock import Mock
 
 
-class MockUser():
-    def __init__(self):
-        self.url = None
-
-    def open_url(self, url):
-        self.url = url
-
-
 def parse_args(extra_args=None, record_results=False, tests_included=False,
                print_nothing=True):
     extra_args = extra_args or []
@@ -93,7 +85,7 @@ def passing_run(extra_args=None, port_obj=None, record_results=False,
                                       tests_included)
     if not port_obj:
         port_obj = port.get(port_name=options.platform, options=options,
-                            user=MockUser(), filesystem=filesystem)
+                            user=mocktool.MockUser(), filesystem=filesystem)
     res = run_webkit_tests.run(port_obj, options, parsed_args)
     return res == 0
 
@@ -103,7 +95,7 @@ def logging_run(extra_args=None, port_obj=None, record_results=False, tests_incl
                                       record_results=record_results,
                                       tests_included=tests_included,
                                       print_nothing=False)
-    user = MockUser()
+    user = mocktool.MockUser()
     if not port_obj:
         port_obj = port.get(port_name=options.platform, options=options,
                             user=user, filesystem=filesystem)
@@ -135,7 +127,7 @@ def get_tests_run(extra_args=None, tests_included=False, flatten_batches=False,
         extra_args = ['passes', 'failures'] + extra_args
     options, parsed_args = parse_args(extra_args, tests_included=True)
 
-    user = MockUser()
+    user = mocktool.MockUser()
 
     test_batches = []
 
@@ -216,7 +208,8 @@ class MainTest(unittest.TestCase):
 
     def test_full_results_html(self):
         # FIXME: verify html?
-        self.assertTrue(passing_run(['--full-results-html']))
+        res, out, err, user = logging_run(['--full-results-html'])
+        self.assertEqual(res, 0)
 
     def test_help_printing(self):
         res, out, err, user = logging_run(['--help-printing'])
@@ -256,7 +249,7 @@ class MainTest(unittest.TestCase):
 
     def test_lint_test_files__errors(self):
         options, parsed_args = parse_args(['--lint-test-files'])
-        user = MockUser()
+        user = mocktool.MockUser()
         port_obj = port.get(options.platform, options=options, user=user)
         port_obj.test_expectations = lambda: "# syntax error"
         res, out, err = run_and_capture(port_obj, options, parsed_args)
@@ -352,7 +345,7 @@ class MainTest(unittest.TestCase):
         self.assertEqual(res, 3)
         self.assertFalse(out.empty())
         self.assertFalse(err.empty())
-        self.assertEqual(user.url, '/tmp/layout-test-results/results.html')
+        self.assertEqual(user.opened_urls, ['/tmp/layout-test-results/results.html'])
 
     def test_exit_after_n_failures(self):
         # Unexpected failures should result in tests stopping.
@@ -414,7 +407,7 @@ class MainTest(unittest.TestCase):
         with fs.mkdtemp() as tmpdir:
             res, out, err, user = logging_run(['--results-directory=' + str(tmpdir)],
                                               tests_included=True, filesystem=fs)
-            self.assertEqual(user.url, fs.join(tmpdir, 'results.html'))
+            self.assertEqual(user.opened_urls, [fs.join(tmpdir, 'results.html')])
 
     def test_results_directory_default(self):
         # We run a configuration that should fail, to generate output, then
@@ -422,7 +415,7 @@ class MainTest(unittest.TestCase):
 
         # This is the default location.
         res, out, err, user = logging_run(tests_included=True)
-        self.assertEqual(user.url, '/tmp/layout-test-results/results.html')
+        self.assertEqual(user.opened_urls, ['/tmp/layout-test-results/results.html'])
 
     def test_results_directory_relative(self):
         # We run a configuration that should fail, to generate output, then
@@ -430,7 +423,7 @@ class MainTest(unittest.TestCase):
 
         res, out, err, user = logging_run(['--results-directory=foo'],
                                           tests_included=True)
-        self.assertEqual(user.url, '/tmp/foo/results.html')
+        self.assertEqual(user.opened_urls, ['/tmp/foo/results.html'])
 
     def test_tolerance(self):
         class ImageDiffTestPort(TestPort):
@@ -441,7 +434,7 @@ class MainTest(unittest.TestCase):
 
         def get_port_for_run(args):
             options, parsed_args = run_webkit_tests.parse_args(args)
-            test_port = ImageDiffTestPort(options=options, user=MockUser())
+            test_port = ImageDiffTestPort(options=options, user=mocktool.MockUser())
             passing_run(args, port_obj=test_port, tests_included=True)
             return test_port
 
@@ -511,9 +504,9 @@ class RebaselineTest(unittest.TestCase):
         file_list.remove('/tmp/layout-test-results/tests_run.txt')
         self.assertEqual(len(file_list), 6)
         self.assertBaselines(file_list,
-            "/platform/test/passes/image")
+            "/platform/test-mac/passes/image")
         self.assertBaselines(file_list,
-            "/platform/test/failures/expected/missing_image")
+            "/platform/test-mac/failures/expected/missing_image")
 
 
 class DryrunTest(unittest.TestCase):
diff --git a/Tools/Scripts/webkitpy/tool/mocktool.py b/Tools/Scripts/webkitpy/tool/mocktool.py
index 7db2996..3680d4c 100644
--- a/Tools/Scripts/webkitpy/tool/mocktool.py
+++ b/Tools/Scripts/webkitpy/tool/mocktool.py
@@ -548,6 +548,9 @@ class MockUser(object):
     def prompt_with_list(cls, list_title, list_items, can_choose_multiple=False, raw_input=raw_input):
         pass
 
+    def __init__(self):
+        self.opened_urls = []
+
     def edit(self, files):
         pass
 
@@ -565,6 +568,7 @@ class MockUser(object):
         return True
 
     def open_url(self, url):
+        self.opened_urls.append(url)
         if url.startswith("file://"):
             log("MOCK: user.open_url: file://...")
             return

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list