<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[194761] trunk/Tools</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/194761">194761</a></dd>
<dt>Author</dt> <dd>youenn.fablet@crf.canon.fr</dd>
<dt>Date</dt> <dd>2016-01-08 00:36:47 -0800 (Fri, 08 Jan 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>webkit-patch build-and-test should have an option to iterate over new tests
https://bugs.webkit.org/show_bug.cgi?id=143093
Reviewed by Michael Catanzaro.
This patch introduces the --iterate-on-new-tests option to webkit-patch build-and-test.
It allows running run-webkit-tests on modified or new paths in LayoutTests.
Computation of new or modified tests is done by LayoutTestFinder.find_touched_tests
It implements the translation of -expected.* paths to their related tests.
It also implements the removal of skipped tests.
* Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py:
(LayoutTestFinder.find_touched_tests):
* Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py: Added.
(MockPort):
(MockPort.__init__):
(MockPort.tests):
(LayoutTestFinderTests):
(LayoutTestFinderTests.touched_files):
(LayoutTestFinderTests.test_touched_test):
(LayoutTestFinderTests.test_expected_touched_test):
(LayoutTestFinderTests.test_platform_expected_touched_test):
(LayoutTestFinderTests.test_platform_duplicate_touched_test):
(LayoutTestFinderTests.test_touched_but_skipped_test):
* Scripts/webkitpy/port/base.py:
(Port.potential_test_names_from_expected_file):
* Scripts/webkitpy/tool/commands/download_unittest.py:
(DownloadCommandsTest._default_options):
* Scripts/webkitpy/tool/steps/options.py:
(Options):
* Scripts/webkitpy/tool/steps/runtests.py:
(RunTests.options):
(RunTests.run):
(RunTests):
(RunTests._new_or_modified_tests):
(RunTests._run_webkit_tests):
* Scripts/webkitpy/tool/steps/runtests_unittest.py:
(RunTestsTest.test_webkit_run_unit_tests):
* Scripts/webkitpy/tool/steps/steps_unittest.py:
(StepsTest._step_options):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptswebkitpylayout_testscontrollerslayout_test_finderpy">trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py</a></li>
<li><a href="#trunkToolsScriptswebkitpyportbasepy">trunk/Tools/Scripts/webkitpy/port/base.py</a></li>
<li><a href="#trunkToolsScriptswebkitpytoolcommandsdownload_unittestpy">trunk/Tools/Scripts/webkitpy/tool/commands/download_unittest.py</a></li>
<li><a href="#trunkToolsScriptswebkitpytoolstepsoptionspy">trunk/Tools/Scripts/webkitpy/tool/steps/options.py</a></li>
<li><a href="#trunkToolsScriptswebkitpytoolstepsruntestspy">trunk/Tools/Scripts/webkitpy/tool/steps/runtests.py</a></li>
<li><a href="#trunkToolsScriptswebkitpytoolstepsruntests_unittestpy">trunk/Tools/Scripts/webkitpy/tool/steps/runtests_unittest.py</a></li>
<li><a href="#trunkToolsScriptswebkitpytoolstepssteps_unittestpy">trunk/Tools/Scripts/webkitpy/tool/steps/steps_unittest.py</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsScriptswebkitpylayout_testscontrollerslayout_test_finder_unittestpy">trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (194760 => 194761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-01-08 06:17:59 UTC (rev 194760)
+++ trunk/Tools/ChangeLog        2016-01-08 08:36:47 UTC (rev 194761)
</span><span class="lines">@@ -1,3 +1,46 @@
</span><ins>+2016-01-08 Youenn Fablet <youenn.fablet@crf.canon.fr>
+
+ webkit-patch build-and-test should have an option to iterate over new tests
+ https://bugs.webkit.org/show_bug.cgi?id=143093
+
+ Reviewed by Michael Catanzaro.
+
+ This patch introduces the --iterate-on-new-tests option to webkit-patch build-and-test.
+ It allows running run-webkit-tests on modified or new paths in LayoutTests.
+ Computation of new or modified tests is done by LayoutTestFinder.find_touched_tests
+ It implements the translation of -expected.* paths to their related tests.
+ It also implements the removal of skipped tests.
+
+ * Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py:
+ (LayoutTestFinder.find_touched_tests):
+ * Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py: Added.
+ (MockPort):
+ (MockPort.__init__):
+ (MockPort.tests):
+ (LayoutTestFinderTests):
+ (LayoutTestFinderTests.touched_files):
+ (LayoutTestFinderTests.test_touched_test):
+ (LayoutTestFinderTests.test_expected_touched_test):
+ (LayoutTestFinderTests.test_platform_expected_touched_test):
+ (LayoutTestFinderTests.test_platform_duplicate_touched_test):
+ (LayoutTestFinderTests.test_touched_but_skipped_test):
+ * Scripts/webkitpy/port/base.py:
+ (Port.potential_test_names_from_expected_file):
+ * Scripts/webkitpy/tool/commands/download_unittest.py:
+ (DownloadCommandsTest._default_options):
+ * Scripts/webkitpy/tool/steps/options.py:
+ (Options):
+ * Scripts/webkitpy/tool/steps/runtests.py:
+ (RunTests.options):
+ (RunTests.run):
+ (RunTests):
+ (RunTests._new_or_modified_tests):
+ (RunTests._run_webkit_tests):
+ * Scripts/webkitpy/tool/steps/runtests_unittest.py:
+ (RunTestsTest.test_webkit_run_unit_tests):
+ * Scripts/webkitpy/tool/steps/steps_unittest.py:
+ (StepsTest._step_options):
+
</ins><span class="cx"> 2016-01-07 Joseph Pecoraro <pecoraro@apple.com>
</span><span class="cx">
</span><span class="cx"> prepare-ChangeLog should include radar number
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpylayout_testscontrollerslayout_test_finderpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py (194760 => 194761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py        2016-01-08 06:17:59 UTC (rev 194760)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py        2016-01-08 08:36:47 UTC (rev 194761)
</span><span class="lines">@@ -50,6 +50,32 @@
</span><span class="cx"> test_files = self._port.tests(paths)
</span><span class="cx"> return (paths, test_files)
</span><span class="cx">
</span><ins>+ def find_touched_tests(self, new_or_modified_paths, apply_skip_expectations=True):
+ potential_test_paths = []
+ for test_file in new_or_modified_paths:
+ if not test_file.startswith(self.LAYOUT_TESTS_DIRECTORY):
+ continue
+
+ test_file = self._strip_test_dir_prefix(test_file)
+ test_paths = self._port.potential_test_names_from_expected_file(test_file)
+ if test_paths:
+ potential_test_paths.extend(test_paths)
+ else:
+ potential_test_paths.append(test_file)
+
+ if not potential_test_paths:
+ return None
+
+ tests = self._port.tests(list(set(potential_test_paths)))
+ if not apply_skip_expectations:
+ return tests
+
+ expectations = test_expectations.TestExpectations(self._port, tests, force_expectations_pass=False)
+ expectations.parse_all_expectations()
+ tests_to_skip = self.skip_tests(potential_test_paths, tests, expectations, None)
+ return [test for test in tests if test not in tests_to_skip]
+
+
</ins><span class="cx"> def _strip_test_dir_prefixes(self, paths):
</span><span class="cx"> return [self._strip_test_dir_prefix(path) for path in paths if path]
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpylayout_testscontrollerslayout_test_finder_unittestpy"></a>
<div class="addfile"><h4>Added: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py (0 => 194761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py         (rev 0)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py        2016-01-08 08:36:47 UTC (rev 194761)
</span><span class="lines">@@ -0,0 +1,95 @@
</span><ins>+# Copyright (c) 2015, Canon Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/gcor other materials provided with the distribution.
+# 3. Neither the name of Canon Inc. nor the names of
+# its contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import optparse
+import unittest
+
+from collections import OrderedDict
+
+from webkitpy.common.host_mock import MockHost
+from webkitpy.common.system.filesystem_mock import MockFileSystem
+from webkitpy.layout_tests.controllers.layout_test_finder import LayoutTestFinder
+from webkitpy.port.test import TestPort
+
+
+class MockPort(TestPort):
+ def __init__(self, host):
+ super(MockPort, self).__init__(host)
+
+ def tests(self, paths):
+ return [path for path in paths if path.endswith('.html')]
+
+
+class LayoutTestFinderTests(unittest.TestCase):
+ def touched_files(self, touched_files, fs=None):
+ host = MockHost()
+ if fs:
+ host.filesystem = fs
+ else:
+ fs = host.filesystem
+ port = MockPort(host)
+ return (fs, LayoutTestFinder(port, optparse.Values({'skipped': 'always', 'skip_failing_tests': False, 'http': True})).find_touched_tests(touched_files))
+
+ def test_touched_test(self):
+ paths = ['LayoutTests/test.html', 'LayoutTests/test', 'test2.html', 'Source/test1.html']
+ fs, touched_tests = self.touched_files(paths)
+ self.assertItemsEqual(touched_tests, ['test.html'])
+
+ def test_expected_touched_test(self):
+ paths = ['LayoutTests/test-expected.txt', 'LayoutTests/no-test-expected.txt']
+ fs = MockFileSystem()
+ fs.write_text_file('/test.checkout/LayoutTests/test.html', 'This is a test')
+ fs, touched_tests = self.touched_files(paths, fs)
+ self.assertItemsEqual(touched_tests, ['test.html'])
+
+ def test_platform_expected_touched_test(self):
+ paths = ['LayoutTests/platform/mock/test-expected.txt', 'LayoutTests/platform/mock/no-test-expected.txt']
+ fs = MockFileSystem()
+ fs.write_text_file('/test.checkout/LayoutTests/test.html', 'This is a test')
+ fs, touched_tests = self.touched_files(paths, fs)
+ self.assertItemsEqual(touched_tests, ['test.html'])
+
+ def test_platform_duplicate_touched_test(self):
+ paths = ['LayoutTests/test1.html', 'LayoutTests/test1.html', 'LayoutTests/platform/mock1/test2-expected.txt', 'LayoutTests/platform/mock2/test2-expected.txt']
+ fs = MockFileSystem()
+ fs.write_text_file('/test.checkout/LayoutTests/test2.html', 'This is a test')
+ fs, touched_tests = self.touched_files(paths, fs)
+ self.assertItemsEqual(touched_tests, ['test1.html', 'test2.html'])
+
+ def test_touched_but_skipped_test(self):
+ host = MockHost()
+ port = MockPort(host)
+
+ expectations_dict = OrderedDict()
+ expectations_dict['expectations'] = 'test1.html [ Skip ]\ntest3.html [ Skip ]\n'
+ port.expectations_dict = lambda: expectations_dict
+ port.test_exists = lambda test: True
+
+ paths = ['LayoutTests/test0.html', 'LayoutTests/test1.html', 'LayoutTests/test2-expected.txt', 'LayoutTests/test3-expected.txt']
+ host.filesystem.write_text_file('/test.checkout/LayoutTests/test2.html', 'This is a test to be runned')
+ host.filesystem.write_text_file('/test.checkout/LayoutTests/test3.html', 'This is a test to be skipped')
+
+ touched_tests = LayoutTestFinder(port, optparse.Values({'skipped': 'always', 'skip_failing_tests': False, 'http': True})).find_touched_tests(paths)
+ self.assertItemsEqual(touched_tests, ['test0.html', 'test2.html'])
</ins></span></pre></div>
<a id="trunkToolsScriptswebkitpyportbasepy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/port/base.py (194760 => 194761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/port/base.py        2016-01-08 06:17:59 UTC (rev 194760)
+++ trunk/Tools/Scripts/webkitpy/port/base.py        2016-01-08 08:36:47 UTC (rev 194761)
</span><span class="lines">@@ -527,6 +527,19 @@
</span><span class="cx">
</span><span class="cx"> return reftest_list.get(self._filesystem.join(self.layout_tests_dir(), test_name), []) # pylint: disable=E1103
</span><span class="cx">
</span><ins>+ def potential_test_names_from_expected_file(self, path):
+ """Return potential test names if any from a potential expected file path, relative to LayoutTests directory."""
+
+ if not '-expected.' in path:
+ return None
+
+ subpath = self.host.filesystem.relpath(path, self.layout_tests_dir())
+ if path.startswith('platform' + self._filesystem.sep):
+ steps = path.split(self._filesystem.sep)
+ path = self._filesystem.join(self._filesystem.sep.join(steps[2:]))
+
+ return [self.host.filesystem.relpath(test, self.layout_tests_dir()) for test in self._filesystem.glob(re.sub('-expected.*', '.*', self._filesystem.join(self.layout_tests_dir(), path))) if self._filesystem.isfile(test)]
+
</ins><span class="cx"> def tests(self, paths):
</span><span class="cx"> """Return the list of tests found. Both generic and platform-specific tests matching paths should be returned."""
</span><span class="cx"> expanded_paths = self._expanded_paths(paths)
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpytoolcommandsdownload_unittestpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/tool/commands/download_unittest.py (194760 => 194761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/tool/commands/download_unittest.py        2016-01-08 06:17:59 UTC (rev 194760)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/download_unittest.py        2016-01-08 08:36:47 UTC (rev 194761)
</span><span class="lines">@@ -88,6 +88,7 @@
</span><span class="cx"> options.test = True
</span><span class="cx"> options.update = True
</span><span class="cx"> options.architecture = 'MOCK ARCH'
</span><ins>+ options.iterate_on_new_tests = 0
</ins><span class="cx"> return options
</span><span class="cx">
</span><span class="cx"> def test_build(self):
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpytoolstepsoptionspy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/tool/steps/options.py (194760 => 194761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/tool/steps/options.py        2016-01-08 06:17:59 UTC (rev 194760)
+++ trunk/Tools/Scripts/webkitpy/tool/steps/options.py        2016-01-08 08:36:47 UTC (rev 194761)
</span><span class="lines">@@ -56,6 +56,7 @@
</span><span class="cx"> reviewer = make_option("-r", "--reviewer", action="store", type="string", dest="reviewer", help="Update ChangeLogs to say Reviewed by REVIEWER.")
</span><span class="cx"> suggest_reviewers = make_option("--suggest-reviewers", action="store_true", default=False, help="Offer to CC appropriate reviewers.")
</span><span class="cx"> test = make_option("--test", action="store_true", dest="test", default=False, help="Run run-webkit-tests before committing.")
</span><ins>+ iterate_on_new_tests = make_option("--iterate-on-new-tests", action="store", type="int", dest="iterate_on_new_tests", default=0, help="Run run-webkit-tests on new tests only before committing, iterating a given number of time.")
</ins><span class="cx"> update = make_option("--no-update", action="store_false", dest="update", default=True, help="Don't update the working directory.")
</span><span class="cx"> update_changelogs = make_option("--update-changelogs", action="store_true", dest="update_changelogs", default=False, help="Update existing ChangeLog entries with new date, bug description, and touched files/functions.")
</span><span class="cx"> changelog_count = make_option("--changelog-count", action="store", type="int", dest="changelog_count", help="Number of changelogs to parse.")
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpytoolstepsruntestspy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/tool/steps/runtests.py (194760 => 194761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/tool/steps/runtests.py        2016-01-08 06:17:59 UTC (rev 194760)
+++ trunk/Tools/Scripts/webkitpy/tool/steps/runtests.py        2016-01-08 08:36:47 UTC (rev 194761)
</span><span class="lines">@@ -27,12 +27,16 @@
</span><span class="cx"> # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx">
</span><span class="cx"> import logging
</span><ins>+import optparse
</ins><span class="cx"> import os
</span><span class="cx"> import platform
</span><ins>+import re
</ins><span class="cx"> import sys
</span><span class="cx"> from webkitpy.tool.steps.abstractstep import AbstractStep
</span><span class="cx"> from webkitpy.tool.steps.options import Options
</span><span class="cx"> from webkitpy.common.system.executive import ScriptError, Executive
</span><ins>+from webkitpy.common.host import Host
+from webkitpy.layout_tests.controllers.layout_test_finder import LayoutTestFinder
</ins><span class="cx">
</span><span class="cx"> _log = logging.getLogger(__name__)
</span><span class="cx">
</span><span class="lines">@@ -45,11 +49,16 @@
</span><span class="cx"> return AbstractStep.options() + [
</span><span class="cx"> Options.build_style,
</span><span class="cx"> Options.test,
</span><ins>+ Options.iterate_on_new_tests,
</ins><span class="cx"> Options.non_interactive,
</span><span class="cx"> Options.quiet,
</span><span class="cx"> ]
</span><span class="cx">
</span><span class="cx"> def run(self, state):
</span><ins>+ if self._options.iterate_on_new_tests:
+ _log.info("Running run-webkit-tests on new tests")
+ self._run_webkit_tests(self._options.iterate_on_new_tests)
+
</ins><span class="cx"> if not self._options.test:
</span><span class="cx"> return
</span><span class="cx">
</span><span class="lines">@@ -90,6 +99,19 @@
</span><span class="cx"> _log.info("Error running run-bindings-tests: %s" % e.message_with_output())
</span><span class="cx">
</span><span class="cx"> _log.info("Running run-webkit-tests")
</span><ins>+ self._run_webkit_tests()
+
+ def _new_or_modified_tests(self):
+ touched_files = self._tool.scm().changed_files()
+ touched_files.extend(self._tool.scm().untracked_files())
+ if not touched_files:
+ return None
+
+ configuration = "Debug" if (self._options.build_style == "debug") else "Release"
+ port = Host().port_factory.get(self._tool.deprecated_port().port_flag_name, optparse.Values({'configuration': configuration}))
+ return LayoutTestFinder(port, optparse.Values({'skipped': 'always', 'skip_failing_tests': False, 'http': True})).find_touched_tests(touched_files)
+
+ def _run_webkit_tests(self, iterate_on_new_tests=0):
</ins><span class="cx"> args = self._tool.deprecated_port().run_webkit_tests_command(build_style=self._options.build_style)
</span><span class="cx"> if self._options.non_interactive:
</span><span class="cx"> args.extend([
</span><span class="lines">@@ -109,5 +131,14 @@
</span><span class="cx"> if self._options.quiet:
</span><span class="cx"> args.append("--quiet")
</span><span class="cx">
</span><ins>+ if iterate_on_new_tests:
+ new_tests = self._new_or_modified_tests()
+ if not new_tests:
+ _log.info("No new or modified tests")
+ return
+ _log.info("Touched tests are: " + str(new_tests))
+ for test in new_tests:
+ args.append(test)
+ args.append("--iterations=%d" % iterate_on_new_tests)
+
</ins><span class="cx"> self._tool.executive.run_and_throw_if_fail(args, cwd=self._tool.scm().checkout_root)
</span><del>-
</del></span></pre></div>
<a id="trunkToolsScriptswebkitpytoolstepsruntests_unittestpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/tool/steps/runtests_unittest.py (194760 => 194761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/tool/steps/runtests_unittest.py        2016-01-08 06:17:59 UTC (rev 194760)
+++ trunk/Tools/Scripts/webkitpy/tool/steps/runtests_unittest.py        2016-01-08 08:36:47 UTC (rev 194761)
</span><span class="lines">@@ -39,7 +39,7 @@
</span><span class="cx"> tool = MockTool(log_executive=True)
</span><span class="cx"> tool._deprecated_port.run_python_unittests_command = lambda: None
</span><span class="cx"> tool._deprecated_port.run_perl_unittests_command = lambda: None
</span><del>- step = RunTests(tool, MockOptions(test=True, non_interactive=True, quiet=False, build_style="release"))
</del><ins>+ step = RunTests(tool, MockOptions(test=True, non_interactive=True, quiet=False, build_style="release", iterate_on_new_tests=0))
</ins><span class="cx">
</span><span class="cx"> if sys.platform != "cygwin":
</span><span class="cx"> expected_logs = """Running bindings generation tests
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpytoolstepssteps_unittestpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/tool/steps/steps_unittest.py (194760 => 194761)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/tool/steps/steps_unittest.py        2016-01-08 06:17:59 UTC (rev 194760)
+++ trunk/Tools/Scripts/webkitpy/tool/steps/steps_unittest.py        2016-01-08 08:36:47 UTC (rev 194761)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> options.port = 'MOCK port'
</span><span class="cx"> options.quiet = True
</span><span class="cx"> options.test = True
</span><ins>+ options.iterate_on_new_tests = 0
</ins><span class="cx"> return options
</span><span class="cx">
</span><span class="cx"> def _run_step(self, step, tool=None, options=None, state=None):
</span></span></pre>
</div>
</div>
</body>
</html>