Skip to content

Commit

Permalink
Move WebKit/Tools/Scripts/webkit-patch to blink/tools/blink_tool.py
Browse files Browse the repository at this point in the history
The suffix part of the new name is 'tool' instead of 'patch' because
this command doesn't handle patches so much.

Bug: 829697
Change-Id: I90f34b6260032a7bbaf562d9b58ffc1a55c3922f
Reviewed-on: https://chromium-review.googlesource.com/1018700
Commit-Queue: Kent Tamura <tkent@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Reviewed-by: Quinten Yearsley <qyearsley@chromium.org>
Cr-Commit-Position: refs/heads/master@{#552382}
  • Loading branch information
tkent-google authored and Commit Bot committed Apr 20, 2018
1 parent f468cd0 commit b53757e
Show file tree
Hide file tree
Showing 46 changed files with 126 additions and 125 deletions.
14 changes: 7 additions & 7 deletions docs/testing/layout_test_baseline_fallback.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ document.
## Tooling implementation

This section describes the implications the fallback mechanism has on the
implementation details of tooling, namely `webkit-patch`. If you are not hacking
`webkitpy`, you can stop here.
implementation details of tooling, namely `blink_tool.py`. If you are not
hacking `blinkpy`, you can stop here.

### Optimization

We can remove a baseline if it is the same as its fallback. An extreme example
is that if all platforms have the same result, we can just have a single generic
baseline. Here is the algorithm used by
[`webkit-patch optimize-baselines`](../../third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/baseline_optimizer.py)
[`blink_tool.py optimize-baselines`](../../third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/baseline_optimizer.py)
to optimize the duplication away.

Notice from the previous section that the virtual and non-virtual parts are two
Expand Down Expand Up @@ -123,7 +123,7 @@ not be found for a platform.

### Rebaseline

The fallback mechanism also affects the rebaseline tool (`webkit-patch
The fallback mechanism also affects the rebaseline tool (`blink_tool.py
rebaseline{-cl}`). When asked to rebaseline a test on some platforms, the tool
downloads results from corresponding try bots and put them into the respective
platform directories. This is potentially problematic. Because of the fallback
Expand All @@ -134,8 +134,8 @@ The solution is to copy the current baselines from the to-be-rebaselined
platforms to all the platforms that immediately fall back to them (i.e. down one
level in the fallback tree) before downloading new baselines. This is done in a
hidden internal command
[`webkit-patch copy-existing-baselines`](../../third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/copy_existing_baselines.py),
which is always executed by `webkit-patch rebaseline`.
[`blink_tool.py copy-existing-baselines`](../../third_party/blink/tools/blinkpy/tool/commands/copy_existing_baselines.py),
which is always executed by `blink_tool.py rebaseline`.

Finally, `webkit-patch rebaseline{-cl}` also does optimization in the end by
Finally, `blink_tool.py rebaseline{-cl}` also does optimization in the end by
default.
12 changes: 6 additions & 6 deletions docs/testing/layout_test_expectations.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,17 @@ platforms.

The recommended way to rebaseline for a currently-in-progress CL is to use
results from try jobs, by using the command-tool
`third_party/WebKit/Tools/Scripts/webkit-patch rebaseline-cl`:
`third_party/blink/tools/blink_tool.py rebaseline-cl`:

1. First, upload a CL.
2. Trigger try jobs by running `webkit-patch rebaseline-cl`. This should
2. Trigger try jobs by running `blink_tool.py rebaseline-cl`. This should
trigger jobs on
[tryserver.blink](https://build.chromium.org/p/tryserver.blink/builders).
3. Wait for all try jobs to finish.
4. Run `webkit-patch rebaseline-cl` again to fetch new baselines.
4. Run `blink_tool.py rebaseline-cl` again to fetch new baselines.
By default, this will download new baselines for any failing tests
in the try jobs.
(Run `webkit-patch rebaseline-cl --help` for more specific options.)
(Run `blink_tool.py rebaseline-cl --help` for more specific options.)
5. Commit the new baselines and upload a new patch.

This way, the new baselines can be reviewed along with the changes, which helps
Expand All @@ -118,7 +118,7 @@ is no period of time when the layout test results are ignored.

### Rebaselining with try jobs

The tests which `webkit-patch rebaseline-cl` tries to download new baselines for
The tests which `blink_tool.py rebaseline-cl` tries to download new baselines for
depends on its arguments.

* By default, it tries to download all baselines for tests that failed in the
Expand All @@ -137,7 +137,7 @@ depends on its arguments.
`NeedsManualRebaseline` and comment out the flaky line so that your patch can
land without turning the tree red. If the test is not in TestExpectations,
you can add a `[ Rebaseline ]` line to TestExpectations.
2. Run `third_party/WebKit/Tools/Scripts/webkit-patch rebaseline-expectations`
2. Run `third_party/blink/tools/blink_tool.py rebaseline-expectations`
3. Post the patch created in step 2 for review.

## Kinds of expectations files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@
var url ='http://localhost:9630/';
xmlhttp.open('POST', url, true);
xmlhttp.onerror = function() {
logText.innerHTML = 'Please run the server using "webkit-patch layout-test-server"';
logText.innerHTML = 'Please run the server using "blink_tool.py layout-test-server"';
logText.className = 'test-fail';
alert('Server offline');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def find_checkout_root(self, path):
def read_git_config(cls, key, cwd=None, executive=None):
# FIXME: This should probably use cwd=self.checkout_root.
# Pass --get-all for cases where the config has multiple values
# Pass the cwd if provided so that we can handle the case of running webkit-patch outside of the working directory.
# Pass the cwd if provided so that we can handle the case of running
# blink_tool.py outside of the working directory.
# FIXME: This should use an Executive.
executive = executive or Executive()
return executive.run_command(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@
import math
import time

from webkitpy.common import add_blinkpy # pylint: disable=unused-import
from webkitpy.common import message_pool
from webkitpy.layout_tests.controllers import single_test_runner
from webkitpy.layout_tests.models.test_run_results import TestRunResults
from webkitpy.layout_tests.models import test_expectations
from webkitpy.layout_tests.models import test_failures
from webkitpy.layout_tests.models import test_results
from webkitpy.tool import grammar
from blinkpy.tool import grammar

_log = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
from webkitpy.layout_tests.models import test_failures
from webkitpy.layout_tests.models import test_run_results
from webkitpy.layout_tests.models.test_input import TestInput
from webkitpy.tool import grammar
from blinkpy.tool import grammar
from blinkpy.w3c.wpt_manifest import WPTManifest

_log = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def parse_args(args):
'--add-platform-exceptions',
action='callback',
callback=deprecate,
help=('Deprecated. Use "webkit-patch rebaseline*" instead.')),
help=('Deprecated. Use "blink_tool.py rebaseline*" instead.')),
optparse.make_option(
'--additional-driver-flag',
'--additional-drt-flag',
Expand Down Expand Up @@ -197,7 +197,7 @@ def parse_args(args):
'--new-baseline',
action='callback',
callback=deprecate,
help=('Deprecated. Use "webkit-patch rebaseline*" instead.')),
help=('Deprecated. Use "blink_tool.py rebaseline*" instead.')),
optparse.make_option(
'--new-flag-specific-baseline',
action='callback',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ class RebaselineTest(unittest.TestCase, StreamTestingMixin):
"""Tests for flags which cause new baselines to be written.
When running layout tests, there are several flags which write new
baselines. This is separate from the "webkit-patch rebaseline" commands,
baselines. This is separate from the "blink_tool.py rebaseline" commands,
which fetch new baselines from elsewhere rather than generating them.
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
import logging
import webbrowser

from webkitpy.common import add_blinkpy # pylint: disable=unused-import
from webkitpy.layout_tests.models.test_expectations import CHROMIUM_BUG_PREFIX
from webkitpy.layout_tests.models.test_expectations import TestExpectations
from webkitpy.tool.commands.flaky_tests import FlakyTests
from blinkpy.tool.commands.flaky_tests import FlakyTests

_log = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from collections import OrderedDict

from webkitpy.common import add_blinkpy # pylint: disable=unused-import
from webkitpy.common.host_mock import MockHost
from webkitpy.common.system.filesystem_mock import MockFileSystem
from webkitpy.common.system.log_testing import LoggingTestCase
Expand All @@ -14,7 +15,7 @@
from webkitpy.layout_tests.port.test import LAYOUT_TEST_DIR
from webkitpy.layout_tests.update_flaky_expectations import main
from webkitpy.layout_tests.update_flaky_expectations import RemoveFlakesOMatic
from webkitpy.tool.commands.flaky_tests import FlakyTests
from blinkpy.tool.commands.flaky_tests import FlakyTests


class FakeBotTestExpectations(object):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
import math
import optparse

from webkitpy.common import add_blinkpy # pylint: disable=unused-import
from webkitpy.layout_tests.models import test_expectations
from webkitpy.layout_tests.views.metered_stream import MeteredStream
from webkitpy.tool import grammar
from blinkpy.tool import grammar


NUM_SLOW_TESTS_TO_LOG = 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def self.prettify(string)
str = "#{HEADER}<body>\n"

# Just look at the first line to see if it is an SVN revision number as added
# by webkit-patch for git checkouts.
# by blink_tool.py for git checkouts.
$svn_revision = 0
string.each_line do |line|
match = /^Subversion\ Revision: (\d*)$/.match(line)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
import signal
import sys

import webkitpy.common.version_check

from blinkpy.common import add_webkitpy # pylint: disable=unused-import
from webkitpy.common import version_check # pylint: disable=unused-import
from webkitpy.common.system.log_utils import configure_logging
from webkitpy.tool.webkit_patch import WebKitPatch
from blinkpy.tool.blink_tool import BlinkTool

# A StreamWriter will by default try to encode all objects passed
# to write(), so when passed a raw string already encoded as utf8,
Expand Down Expand Up @@ -76,7 +76,7 @@ def main():
else:
logging_level = logging.INFO
configure_logging(logging_level=logging_level)
WebKitPatch(os.path.abspath(__file__)).main()
BlinkTool(os.path.abspath(__file__)).main()


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

"""Webkit-patch is a tool with multiple sub-commands with different purposes.
Historically, it had commands related to dealing with bugzilla and posting
and committing patches to WebKit. More recently, it has commands for printing
expectations, fetching new test baselines, etc.
"""blink_tool.py is a tool with multiple sub-commands with different purposes.
It has commands for printing expectations, fetching new test baselines, etc.
These commands don't necessarily have anything to do with each other.
"""

Expand All @@ -41,26 +38,26 @@
import sys

from webkitpy.common.host import Host
from webkitpy.tool.commands.analyze_baselines import AnalyzeBaselines
from webkitpy.tool.commands.command import HelpPrintingOptionParser
from webkitpy.tool.commands.copy_existing_baselines import CopyExistingBaselines
from webkitpy.tool.commands.flaky_tests import FlakyTests
from webkitpy.tool.commands.help_command import HelpCommand
from webkitpy.tool.commands.optimize_baselines import OptimizeBaselines
from webkitpy.tool.commands.pretty_diff import PrettyDiff
from webkitpy.tool.commands.queries import CrashLog
from webkitpy.tool.commands.queries import PrintBaselines
from webkitpy.tool.commands.queries import PrintExpectations
from webkitpy.tool.commands.rebaseline import Rebaseline
from webkitpy.tool.commands.rebaseline import RebaselineExpectations
from webkitpy.tool.commands.rebaseline_cl import RebaselineCL
from webkitpy.tool.commands.rebaseline_test import RebaselineTest
from blinkpy.tool.commands.analyze_baselines import AnalyzeBaselines
from blinkpy.tool.commands.command import HelpPrintingOptionParser
from blinkpy.tool.commands.copy_existing_baselines import CopyExistingBaselines
from blinkpy.tool.commands.flaky_tests import FlakyTests
from blinkpy.tool.commands.help_command import HelpCommand
from blinkpy.tool.commands.optimize_baselines import OptimizeBaselines
from blinkpy.tool.commands.pretty_diff import PrettyDiff
from blinkpy.tool.commands.queries import CrashLog
from blinkpy.tool.commands.queries import PrintBaselines
from blinkpy.tool.commands.queries import PrintExpectations
from blinkpy.tool.commands.rebaseline import Rebaseline
from blinkpy.tool.commands.rebaseline import RebaselineExpectations
from blinkpy.tool.commands.rebaseline_cl import RebaselineCL
from blinkpy.tool.commands.rebaseline_test import RebaselineTest


_log = logging.getLogger(__name__)


class WebKitPatch(Host):
class BlinkTool(Host):
# FIXME: It might make more sense if this class had a Host attribute
# instead of being a Host subclass.

Expand All @@ -74,7 +71,7 @@ class WebKitPatch(Host):
]

def __init__(self, path):
super(WebKitPatch, self).__init__()
super(BlinkTool, self).__init__()
self._path = path
self.commands = [
AnalyzeBaselines(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@
import unittest

from webkitpy.common.system.output_capture import OutputCapture
from webkitpy.tool.webkit_patch import WebKitPatch
from blinkpy.tool.blink_tool import BlinkTool


class WebKitPatchTest(unittest.TestCase):
class BlinkToolTest(unittest.TestCase):

def test_split_args_basic(self):
self.assertEqual(
WebKitPatch._split_command_name_from_args(['--global-option', 'command', '--option', 'arg']),
BlinkTool._split_command_name_from_args(['--global-option', 'command', '--option', 'arg']),
('command', ['--global-option', '--option', 'arg']))

def test_split_args_empty(self):
self.assertEqual(
WebKitPatch._split_command_name_from_args([]),
BlinkTool._split_command_name_from_args([]),
(None, []))

def test_split_args_with_no_options(self):
self.assertEqual(
WebKitPatch._split_command_name_from_args(['command', 'arg']),
BlinkTool._split_command_name_from_args(['command', 'arg']),
('command', ['arg']))

def test_command_by_name(self):
tool = WebKitPatch('path')
tool = BlinkTool('path')
self.assertEqual(tool.command_by_name('help').name, 'help')
self.assertIsNone(tool.command_by_name('non-existent'))

def test_help_command(self):
oc = OutputCapture()
oc.capture_output()
tool = WebKitPatch('path')
tool = BlinkTool('path')
tool.main(['tool', 'help'])
out, err, logs = oc.restore_output()
self.assertTrue(out.startswith('Usage: '))
Expand All @@ -43,7 +43,7 @@ def test_help_command(self):
def test_help_argument(self):
oc = OutputCapture()
oc.capture_output()
tool = WebKitPatch('path')
tool = BlinkTool('path')
try:
tool.main(['tool', '--help'])
except SystemExit:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from optparse import make_option
import threading

from webkitpy.tool.commands.command import Command
from blinkpy.tool.commands.command import Command


class AbstractLocalServerCommand(Command):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import optparse

from webkitpy.common.checkout.baseline_optimizer import BaselineOptimizer
from webkitpy.tool.commands.rebaseline import AbstractRebaseliningCommand
from blinkpy.tool.commands.rebaseline import AbstractRebaseliningCommand

_log = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import optparse

from webkitpy.common.checkout.baseline_optimizer import BaselineOptimizer
from webkitpy.tool.commands.analyze_baselines import AnalyzeBaselines
from webkitpy.tool.commands.rebaseline_unittest import BaseTestCase
from blinkpy.tool.commands.analyze_baselines import AnalyzeBaselines
from blinkpy.tool.commands.rebaseline_unittest import BaseTestCase


class _FakeOptimizer(BaselineOptimizer):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import logging
import sys

from webkitpy.tool.grammar import pluralize
from blinkpy.tool.grammar import pluralize

_log = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
import unittest

from webkitpy.common.system.output_capture import OutputCapture
from webkitpy.tool.mock_tool import MockWebKitPatch
from blinkpy.tool.mock_tool import MockBlinkTool


class CommandsTest(unittest.TestCase):

def assert_execute_outputs(
self, command, args=None, expected_stdout='', expected_stderr='',
expected_exception=None, expected_logs=None, options=optparse.Values(), tool=MockWebKitPatch()):
expected_exception=None, expected_logs=None, options=optparse.Values(), tool=MockBlinkTool()):
args = args or []
options.blocks = None
options.cc = 'MOCK cc'
Expand Down
Loading

0 comments on commit b53757e

Please sign in to comment.