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

Unified Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/chromium_wpt.py

Issue 2439153002: Script for exporting WPT (Closed)
Patch Set: Fix spacing issues Created 4 years, 1 month 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/w3c/chromium_wpt.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/chromium_wpt.py b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/chromium_wpt.py
new file mode 100644
index 0000000000000000000000000000000000000000..c1c091ab719473b4cbb557fc2e659dd8cee3d02d
--- /dev/null
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/chromium_wpt.py
@@ -0,0 +1,79 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""A utility class for interacting with the Chromium git tree
+for use cases relating to the Web Platform Tests.
+"""
+
+CHROMIUM_WPT_DIR = 'third_party/WebKit/LayoutTests/imported/wpt/'
+
+from webkitpy.common.memoized import memoized
+from webkitpy.common.webkit_finder import WebKitFinder
+
+
+class ChromiumWPT(object):
+
+ def __init__(self, host):
+ """
+ Args:
+ host: A Host object.
+ """
+ self.host = host
+
+ def exportable_commits_since(self, chromium_commit):
+ chromium_commits = self.chromium_commits_since(chromium_commit)
+
+ def is_exportable(chromium_commit):
+ return self.has_changes_in_wpt(chromium_commit) and not self.is_import_commit(chromium_commit)
+
+ return filter(is_exportable, chromium_commits)
+
+ def is_import_commit(self, chromium_commit):
+ return self.subject(chromium_commit).startswith('Import wpt@')
+
+ def has_changes_in_wpt(self, chromium_commit):
+ """Detects if a Chromium revision has modified files in the WPT directory."""
+
+ assert chromium_commit
+ files = self.host.executive.run_command([
+ 'git', 'diff-tree', '--no-commit-id',
+ '--name-only', '-r', chromium_commit
+ ]).splitlines()
+
+ # TODO(jeffcarp): Use DepsUpdater.is_baseline
+ return any(f.startswith(CHROMIUM_WPT_DIR) and '-expected' not in f for f in files)
+
+ def chromium_commits_since(self, chromium_commit):
+ return self.host.executive.run_command([
+ 'git', 'rev-list', '--reverse', '{}..HEAD'.format(chromium_commit)
+ ]).splitlines()
+
+ def subject(self, chromium_commit):
+ return self.host.executive.run_command([
+ 'git', 'show', '--format=%s', '--no-patch', chromium_commit
+ ])
+
+ def commit_position(self, chromium_commit):
+ return self.host.executive.run_command([
+ 'git', 'footers', '--position', chromium_commit
+ ])
+
+ def message(self, chromium_commit):
+ """Returns a string with a commit's subject and body."""
+ return self.host.executive.run_command([
+ 'git', 'show', '--format=%B', '--no-patch', chromium_commit
+ ])
+
+ def format_patch(self, chromium_commit):
+ """Makes a patch with just changes in files in the WPT for a given commit."""
+ # TODO(jeffcarp): do not include expectations files
+ return self.host.executive.run_command([
+ 'git', 'format-patch', '-1', '--stdout',
+ chromium_commit, self.absolute_chromium_wpt_dir()
+ ])
+
+ @memoized
+ def absolute_chromium_wpt_dir(self):
+ finder = WebKitFinder(self.host.filesystem)
+ return finder.path_from_webkit_base('LayoutTests', 'imported', 'wpt')
« no previous file with comments | « third_party/WebKit/Tools/Scripts/sync-wpt ('k') | third_party/WebKit/Tools/Scripts/webkitpy/w3c/chromium_wpt_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698