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

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

Issue 2439153002: Script for exporting WPT (Closed)
Patch Set: Address most of CL feedback 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..d9bf62a1ea7e1ce32d091b07d091a54057cff55f
--- /dev/null
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/chromium_wpt.py
@@ -0,0 +1,67 @@
+# 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.
+
+CR_WPT_DIR = 'third_party/WebKit/LayoutTests/imported/wpt/'
+
+from webkitpy.common.memoized import memoized
+from webkitpy.common.webkit_finder import WebKitFinder
+
+
+class ChromiumWPT(object):
+ """This is a utility class for interacting with the Chromium git tree
+ for use cases relating to the Web Platform Tests.
+ """
+
+ def __init__(self, host):
+ self.host = host
+
+ def exportable_commits_since(self, sha):
+ cr_commits = self.cr_commits_since(sha)
+ return filter(self.has_changes_in_wpt, cr_commits)
+
+ def has_changes_in_wpt(self, sha):
+ """Returns if a Chromium sha has changed files in
+ LayoutTests/imported/wpt unless they're expectations
+ """
+ assert sha
+
+ files = self.host.executive.run_command([
+ 'git', 'diff-tree', '--no-commit-id',
+ '--name-only', '-r', sha
+ ]).splitlines()
+
+ return any([f.startswith(CR_WPT_DIR) and '-expected' not in f for f in files])
+
+ def cr_commits_since(self, sha):
+ return self.host.executive.run_command([
+ 'git', 'rev-list', '--reverse', '{}..HEAD'.format(sha)
+ ]).splitlines()
+
+ def subject(self, sha):
+ return self.host.executive.run_command([
+ 'git', 'show', '--format=%s', '--no-patch', sha
+ ])
+
+ def commit_position(self, sha):
+ return self.host.executive.run_command([
+ 'git', 'footers', '--position', sha
+ ])
+
+ def message(self, sha):
+ """This returns both the subject and body of a given revision."""
+ return self.host.executive.run_command([
+ 'git', 'show', '--format=%B', '--no-patch', sha
+ ])
+
+ def format_patch(self, sha):
+ """Get patch but only for files in LayoutTests/imported/wpt"""
+ return self.host.executive.run_command([
+ 'git', 'format-patch', '-1', '--stdout',
+ sha, 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')

Powered by Google App Engine
This is Rietveld 408576698