Commit 43a8141e authored by philn@webkit.org's avatar philn@webkit.org
Browse files

2010-09-06 Philippe Normand <pnormand@igalia.com>

        Reviewed by Adam Barth.

        webkit-patch command to find the ports covering a specific layout test
        https://bugs.webkit.org/show_bug.cgi?id=42832

        To use it: webkit-patch skipped-ports some/layout/test.html

        * Scripts/webkitpy/layout_tests/port/base.py:
        * Scripts/webkitpy/layout_tests/port/base_unittest.py:
        * Scripts/webkitpy/layout_tests/port/chromium.py:
        * Scripts/webkitpy/layout_tests/port/chromium_unittest.py:
        * Scripts/webkitpy/layout_tests/port/factory.py:
        * Scripts/webkitpy/layout_tests/port/factory_unittest.py:
        * Scripts/webkitpy/layout_tests/port/test.py:
        * Scripts/webkitpy/layout_tests/port/webkit.py:
        * Scripts/webkitpy/layout_tests/port/webkit_unittest.py:
        * Scripts/webkitpy/tool/commands/queries.py:
        * Scripts/webkitpy/tool/commands/queries_unittest.py:
        * Scripts/webkitpy/tool/main.py:
        * Scripts/webkitpy/tool/mocktool.py:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66872 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0f75af21
2010-09-06 Philippe Normand <pnormand@igalia.com>
Reviewed by Adam Barth.
webkit-patch command to find the ports covering a specific layout test
https://bugs.webkit.org/show_bug.cgi?id=42832
To use it: webkit-patch skipped-ports some/layout/test.html
* Scripts/webkitpy/layout_tests/port/base.py:
* Scripts/webkitpy/layout_tests/port/base_unittest.py:
* Scripts/webkitpy/layout_tests/port/chromium.py:
* Scripts/webkitpy/layout_tests/port/chromium_unittest.py:
* Scripts/webkitpy/layout_tests/port/factory.py:
* Scripts/webkitpy/layout_tests/port/factory_unittest.py:
* Scripts/webkitpy/layout_tests/port/test.py:
* Scripts/webkitpy/layout_tests/port/webkit.py:
* Scripts/webkitpy/layout_tests/port/webkit_unittest.py:
* Scripts/webkitpy/tool/commands/queries.py:
* Scripts/webkitpy/tool/commands/queries_unittest.py:
* Scripts/webkitpy/tool/main.py:
* Scripts/webkitpy/tool/mocktool.py:
2010-09-07 Gabor Rapcsanyi <rgabor@inf.u-szeged.hu>
Reviewed by Eric Seidel.
......
......@@ -305,6 +305,18 @@ class Port(object):
"""Return the absolute path to the top of the LayoutTests directory."""
return self.path_from_webkit_base('LayoutTests')
def skips_layout_test(self, test_name):
"""Figures out if the givent test is being skipped or not.
Test categories are handled as well."""
for test_or_category in self.skipped_layout_tests():
if test_or_category == test_name:
return True
category = os.path.join(self.layout_tests_dir(), test_or_category)
if os.path.isdir(category) and test_name.startswith(test_or_category):
return True
return False
def maybe_make_directory(self, *path):
"""Creates the specified directory if it doesn't already exist."""
try:
......
......@@ -109,6 +109,13 @@ class PortTest(unittest.TestCase):
self.assertFalse(base._wdiff_available)
base._wdiff_available = True
def test_layout_tests_skipping(self):
port = base.Port()
port.skipped_layout_tests = lambda: ['foo/bar.html', 'media']
self.assertTrue(port.skips_layout_test('foo/bar.html'))
self.assertTrue(port.skips_layout_test('media/video-zoom.html'))
self.assertFalse(port.skips_layout_test('foo/foo.html'))
class DriverTest(unittest.TestCase):
......
......@@ -46,6 +46,8 @@ import base
import http_server
from webkitpy.common.system.executive import Executive
from webkitpy.layout_tests.layout_package import test_files
from webkitpy.layout_tests.layout_package import test_expectations
# Chromium DRT on OSX uses WebKitDriver.
if sys.platform == 'darwin':
......@@ -233,6 +235,24 @@ class ChromiumPort(base.Port):
with codecs.open(overrides_path, "r", "utf-8") as file:
return file.read() + drt_overrides
def skipped_layout_tests(self, extra_test_files=None):
expectations_str = self.test_expectations()
overrides_str = self.test_expectations_overrides()
test_platform_name = self.test_platform_name()
is_debug_mode = False
all_test_files = test_files.gather_test_files(self, '*')
if extra_test_files:
all_test_files.update(extra_test_files)
expectations = test_expectations.TestExpectations(
self, all_test_files, expectations_str, test_platform_name,
is_debug_mode, is_lint_mode=True,
tests_are_present=True, overrides=overrides_str)
tests_dir = self.layout_tests_dir()
return [self.relative_test_filename(test)
for test in expectations.get_tests_with_result_type(test_expectations.SKIP)]
def test_platform_names(self):
return self.test_base_platform_names() + ('win-xp',
'win-vista', 'win-7')
......
......@@ -32,6 +32,7 @@ import chromium_mac
import chromium_win
import unittest
import StringIO
import os
from webkitpy.thirdparty.mock import Mock
......@@ -95,3 +96,17 @@ class ChromiumDriverTest(unittest.TestCase):
'/xcodebuild/Release/ImageDiff'))
# FIXME: Figure out how this is going to work on Windows.
#port = chromium_win.ChromiumWinPort('test-port', options=MockOptions())
def test_skipped_layout_tests(self):
class MockOptions:
def __init__(self):
self.use_drt = True
port = chromium_linux.ChromiumLinuxPort('test-port', options=MockOptions())
fake_test = os.path.join(port.layout_tests_dir(), "fast/js/not-good.js")
port.test_expectations = lambda: """BUG_TEST SKIP : fast/js/not-good.js = TEXT
DEFER LINUX WIN : fast/js/very-good.js = TIMEOUT PASS"""
skipped_tests = port.skipped_layout_tests(extra_test_files=[fake_test, ])
self.assertTrue("fast/js/not-good.js" in skipped_tests)
......@@ -32,6 +32,10 @@
import sys
ALL_PORT_NAMES = ['test', 'dryrun', 'mac', 'win', 'gtk', 'qt', 'chromium-mac',
'chromium-linux', 'chromium-win', 'google-chrome-win',
'google-chrome-mac', 'google-chrome-linux32', 'google-chrome-linux64']
def get(port_name=None, options=None):
"""Returns an object implementing the Port interface. If
......@@ -88,3 +92,9 @@ def get(port_name=None, options=None):
return google_chrome.GetGoogleChromePort(port_name, options)
raise NotImplementedError('unsupported port: %s' % port_to_use)
def get_all(options=None):
"""Returns all the objects implementing the Port interface."""
return dict([(port_name, get(port_name, options=options))
for port_name in ALL_PORT_NAMES])
......@@ -69,16 +69,16 @@ class FactoryTest(unittest.TestCase):
def tearDown(self):
sys.platform = self.real_sys_platform
def assert_port(self, port_name, expected_port):
def assert_port(self, port_name, expected_port, port_obj=None):
"""Helper assert for port_name.
Args:
port_name: port name to get port object.
expected_port: class of expected port object.
port_obj: optional port object
"""
self.assertTrue(isinstance(factory.get(port_name=port_name),
expected_port))
port_obj = port_obj or factory.get(port_name=port_name)
self.assertTrue(isinstance(port_obj, expected_port))
def assert_platform_port(self, platform, options, expected_port):
"""Helper assert for platform and options.
......@@ -136,3 +136,21 @@ class FactoryTest(unittest.TestCase):
chromium_win.ChromiumWinPort)
self.assert_platform_port("cygwin", self.chromium_options,
chromium_win.ChromiumWinPort)
def test_get_all_ports(self):
ports = factory.get_all()
for name in factory.ALL_PORT_NAMES:
self.assertTrue(name in ports.keys())
self.assert_port("test", test.TestPort, ports["test"])
self.assert_port("dryrun-test", dryrun.DryRunPort, ports["dryrun"])
self.assert_port("dryrun-mac", dryrun.DryRunPort, ports["dryrun"])
self.assert_port("mac", mac.MacPort, ports["mac"])
self.assert_port("win", win.WinPort, ports["win"])
self.assert_port("gtk", gtk.GtkPort, ports["gtk"])
self.assert_port("qt", qt.QtPort, ports["qt"])
self.assert_port("chromium-mac", chromium_mac.ChromiumMacPort,
ports["chromium-mac"])
self.assert_port("chromium-linux", chromium_linux.ChromiumLinuxPort,
ports["chromium-linux"])
self.assert_port("chromium-win", chromium_win.ChromiumWinPort,
ports["chromium-win"])
......@@ -76,6 +76,9 @@ class TestPort(base.Port):
def options(self):
return self._options
def skipped_layout_tests(self):
return []
def path_to_test_expectations_file(self):
return self.path_from_webkit_base('WebKitTools', 'Scripts',
'webkitpy', 'layout_tests', 'data', 'platform', 'test',
......
......@@ -344,14 +344,17 @@ class WebKitPort(base.Port):
# This routine reads those files and turns contents into the
# format expected by test_expectations.
tests_to_skip = self.skipped_layout_tests()
skip_lines = map(lambda test_path: "BUG_SKIPPED SKIP : %s = FAIL" %
test_path, tests_to_skip)
return "\n".join(skip_lines)
def skipped_layout_tests(self):
# Use a set to allow duplicates
tests_to_skip = set(self._expectations_from_skipped_files())
tests_to_skip.update(self._tests_for_other_platforms())
tests_to_skip.update(self._tests_for_disabled_features())
skip_lines = map(lambda test_path: "BUG_SKIPPED SKIP : %s = FAIL" %
test_path, tests_to_skip)
return "\n".join(skip_lines)
return tests_to_skip
def test_platform_name(self):
return self._name + self.version()
......
......@@ -40,6 +40,14 @@ class TestWebKitPort(WebKitPort):
def _supported_symbol_list(self):
return self.symbol_list
def _tests_for_other_platforms(self):
return ["media", ]
def _tests_for_disabled_features(self):
return ["accessibility", ]
def _skipped_file_paths(self):
return []
class WebKitPortTest(unittest.TestCase):
......@@ -54,3 +62,7 @@ class WebKitPortTest(unittest.TestCase):
expected_directories = set(["animations/3d", "transforms/3d"])
result_directories = set(TestWebKitPort(None, supported_features)._skipped_tests_for_unsupported_features())
self.assertEqual(result_directories, expected_directories)
def test_skipped_layout_tests(self):
self.assertEqual(TestWebKitPort(None, None).skipped_layout_tests(),
set(["media", "accessibility"]))
......@@ -37,6 +37,7 @@ from webkitpy.common.system.user import User
from webkitpy.tool.grammar import pluralize
from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand
from webkitpy.common.system.deprecated_logging import log
from webkitpy.layout_tests import port
class BugsToCommit(AbstractDeclarativeCommand):
......@@ -284,3 +285,28 @@ and displayes the status of each builder."""
for builder in tool.buildbot.builder_statuses():
status_string = "ok" if builder["is_green"] else "FAIL"
print "%s : %s" % (status_string.ljust(4), builder["name"])
class SkippedPorts(AbstractDeclarativeCommand):
name = "skipped-ports"
help_text = "Print the list of ports skipping the given layout test(s)"
long_help = """Scans the the Skipped file of each port and figure
out what ports are skipping the test(s). Categories are taken in account too."""
argument_names = "TEST_NAME"
def execute(self, options, args, tool):
class Options:
# Required for chromium port.
use_drt = True
results = dict([(test_name, []) for test_name in args])
for port_name, port_object in tool.port_factory.get_all(options=Options).iteritems():
for test_name in args:
if port_object.skips_layout_test(test_name):
results[test_name].append(port_name)
for test_name, ports in results.iteritems():
if ports:
print "Ports skipping test %r: %s" % (test_name, ', '.join(ports))
else:
print "Test %r is not skipped by any port." % test_name
......@@ -61,3 +61,13 @@ class QueryCommandsTest(CommandsTest):
def test_tree_status(self):
expected_stdout = "ok : Builder1\nok : Builder2\n"
self.assert_execute_outputs(TreeStatus(), None, expected_stdout)
def test_skipped_ports(self):
expected_stdout = "Ports skipping test 'media/foo/bar.html': test_port1, test_port2\n"
self.assert_execute_outputs(SkippedPorts(), ("media/foo/bar.html",), expected_stdout)
expected_stdout = "Ports skipping test 'foo': test_port1\n"
self.assert_execute_outputs(SkippedPorts(), ("foo",), expected_stdout)
expected_stdout = "Test 'media' is not skipped by any port.\n"
self.assert_execute_outputs(SkippedPorts(), ("media",), expected_stdout)
......@@ -40,6 +40,7 @@ from webkitpy.common.net.rietveld import Rietveld
from webkitpy.common.net.irc.ircproxy import IRCProxy
from webkitpy.common.system.executive import Executive
from webkitpy.common.system.user import User
from webkitpy.layout_tests import port
import webkitpy.tool.commands as commands
# FIXME: Remove these imports once all the commands are in the root of the
# command package.
......@@ -76,6 +77,7 @@ class WebKitPatch(MultiCommandTool):
self._checkout = None
self.status_server = StatusServer()
self.codereview = Rietveld(self.executive)
self.port_factory = port.factory
def scm(self):
# Lazily initialize SCM to not error-out before command line parsing (or when running non-scm commands).
......
......@@ -556,6 +556,24 @@ class MockRietveld():
log("MOCK: Uploading patch to rietveld")
class MockTestPort1():
def skips_layout_test(self, test_name):
return test_name in ["media/foo/bar.html", "foo"]
class MockTestPort2():
def skips_layout_test(self, test_name):
return test_name == "media/foo/bar.html"
class MockPortFactory():
def get_all(self, options=None):
return {"test_port1": MockTestPort1(), "test_port2": MockTestPort2()}
class MockTool():
def __init__(self, log_executive=False):
......@@ -570,6 +588,7 @@ class MockTool():
self.status_server = MockStatusServer()
self.irc_password = "MOCK irc password"
self.codereview = MockRietveld(self.executive)
self.port_factory = MockPortFactory()
def scm(self):
return self._scm
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment