Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1181)

Unified Diff: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/layout_tests_mover.py

Issue 1806393002: Run yapf on files in webkit/layout_tests/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/layout_tests_mover.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/layout_tests_mover.py b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/layout_tests_mover.py
index 1cfd7e32bc85470b423a1680420524a8e7cdfe06..2f9cbf2079efe7a2dfae72f3098aba905a79f791 100644
--- a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/layout_tests_mover.py
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/layout_tests_mover.py
@@ -25,7 +25,6 @@
# 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.
-
"""Moves a directory of LayoutTests.
Given a path to a directory of LayoutTests, moves that directory, including all recursive children,
@@ -56,15 +55,14 @@ from webkitpy.common.system.filesystem import FileSystem
from webkitpy.layout_tests.port.base import Port
from webkitpy.layout_tests.models.test_expectations import TestExpectations
-
logging.basicConfig()
_log = logging.getLogger(__name__)
_log.setLevel(logging.INFO)
PLATFORM_DIRECTORY = 'platform'
-class LayoutTestsMover(object):
+class LayoutTestsMover(object):
def __init__(self, port=None):
self._port = port
if not self._port:
@@ -109,8 +107,9 @@ class LayoutTestsMover(object):
if self._filesystem.isdir(self._absolute_destination):
for file_path in self._filesystem.listdir(self._absolute_origin):
if self._filesystem.exists(self._filesystem.join(self._absolute_destination, file_path)):
- raise Exception('Origin path %s clashes with existing destination path %s' %
- (self._filesystem.join(self._origin, file_path), self._filesystem.join(self._destination, file_path)))
+ raise Exception(
+ 'Origin path %s clashes with existing destination path %s' %
+ (self._filesystem.join(self._origin, file_path), self._filesystem.join(self._destination, file_path)))
def _get_expectations_for_test(self, model, test_path):
"""Given a TestExpectationsModel object, finds all expectations that match the specified
@@ -134,9 +133,12 @@ class LayoutTestsMover(object):
specified relative path.
"""
expectations = set()
- for test in self._filesystem.files_under(self._filesystem.join(self._layout_tests_root, path), dirs_to_skip=['script-tests', 'resources'],
- file_filter=Port.is_test_file):
- expectations = expectations.union(self._get_expectations_for_test(model, self._filesystem.relpath(test, self._layout_tests_root)))
+ for test in self._filesystem.files_under(
+ self._filesystem.join(self._layout_tests_root, path),
+ dirs_to_skip=['script-tests', 'resources'],
+ file_filter=Port.is_test_file):
+ expectations = expectations.union(self._get_expectations_for_test(model, self._filesystem.relpath(
+ test, self._layout_tests_root)))
return expectations
@staticmethod
@@ -178,7 +180,8 @@ class LayoutTestsMover(object):
expectations_file = self._port.path_to_generic_test_expectations_file()
self._filesystem.write_text_file(expectations_file,
- TestExpectations.list_to_string(test_expectations._expectations, reconstitute_only_these=[]))
+ TestExpectations.list_to_string(test_expectations._expectations,
+ reconstitute_only_these=[]))
self._scm.add(self._filesystem.relpath(expectations_file, self._scm.checkout_root))
def _find_references(self, input_files):
@@ -211,7 +214,7 @@ class LayoutTestsMover(object):
# bar/ is moved to baz/, because the reference is always normalized to 'script.js'.
absolute_reference = self._filesystem.normpath(self._filesystem.join(root, reference))
if self._is_child_path(self._absolute_origin, root) == self._is_child_path(self._absolute_origin, absolute_reference):
- return None;
+ return None
new_root = self._move_path(root, self._absolute_origin, self._absolute_destination)
new_absolute_reference = self._move_path(absolute_reference, self._absolute_origin, self._absolute_destination)
@@ -253,7 +256,8 @@ class LayoutTestsMover(object):
def is_test_source_file(filesystem, dirname, basename):
pass_regex = re.compile(r'\.(css|js)$')
fail_regex = re.compile(r'-expected\.')
- return (Port.is_test_file(filesystem, dirname, basename) or pass_regex.search(basename)) and not fail_regex.search(basename)
+ return (Port.is_test_file(filesystem, dirname, basename) or
+ pass_regex.search(basename)) and not fail_regex.search(basename)
test_source_files = self._filesystem.files_under(self._layout_tests_root, file_filter=is_test_source_file)
_log.info('Considering %s test source files for references' % len(test_source_files))
@@ -290,8 +294,9 @@ class LayoutTestsMover(object):
"""
self._move_directory(self._origin, self._destination)
for directory in self._filesystem.listdir(self._filesystem.join(self._layout_tests_root, PLATFORM_DIRECTORY)):
- self._move_directory(self._filesystem.join(PLATFORM_DIRECTORY, directory, self._origin),
- self._filesystem.join(PLATFORM_DIRECTORY, directory, self._destination))
+ self._move_directory(
+ self._filesystem.join(PLATFORM_DIRECTORY, directory, self._origin),
+ self._filesystem.join(PLATFORM_DIRECTORY, directory, self._destination))
def _commit_changes(self):
if not self._scm.supports_local_commits():
@@ -313,10 +318,10 @@ class LayoutTestsMover(object):
# FIXME: Handle virtual test suites.
self._commit_changes()
+
def main(argv):
parser = optparse.OptionParser(description=__doc__)
- parser.add_option('--origin',
- help=('The directory of tests to move, as a relative path from the LayoutTests directory.'))
+ parser.add_option('--origin', help=('The directory of tests to move, as a relative path from the LayoutTests directory.'))
parser.add_option('--destination',
help=('The new path for the directory of tests, as a relative path from the LayoutTests directory.'))
options, _ = parser.parse_args()

Powered by Google App Engine
This is Rietveld 408576698