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

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

Issue 2439153002: Script for exporting WPT (Closed)
Patch Set: Clean up finding Cr-Commit-Pos in WPT with one neat trick 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..c53baff1db2af43dbcd53ce1101bd579db40e7b1
--- /dev/null
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/chromium_wpt.py
@@ -0,0 +1,60 @@
+# 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.
+
+import os
+
+CR_WPT_DIR = 'third_party/WebKit/LayoutTests/imported/wpt/'
+
+
+class ChromiumWPT(object):
foolip 2016/11/01 22:07:44 A sentence or two of documentation describing the
qyearsley 2016/11/01 22:57:45 It'd work without (object), but explicitly making
jeffcarp 2016/11/01 23:21:18 The linter yells at me if classes don't inherit fr
foolip 2016/11/02 13:15:32 OK, I had no idea there was a new style in town :)
+
+ def __init__(self, host):
+ self.host = host
+ self.absolute_chromium_wpt_dir = os.path.abspath(os.path.join('..', '..', 'LayoutTests', 'imported', 'wpt'))
foolip 2016/11/01 22:07:44 Does this assume that the script is being run from
qyearsley 2016/11/01 22:57:45 In general code in this codebase avoids using os d
+
+ 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
qyearsley 2016/11/01 22:57:45 This docstring could be clarified. A good docstrin
+ """
+ assert sha
+
+ diff_files = self.host.executive.run_command([
+ 'git', 'diff-tree', '--no-commit-id',
+ '--name-only', '-r', '{}'.format(sha)
foolip 2016/11/01 22:07:44 If sha is already a string, which I think it is, t
jeffcarp 2016/11/01 23:21:18 I don't think sha could ever be anything other tha
+ ])
+
+ files = [f.strip() for f in filter(bool, diff_files.split('\n'))]
foolip 2016/11/01 22:07:44 Using splitlines() also handled \r\n if it happens
jeffcarp 2016/11/01 23:21:18 Ah thank you, that's much cleaner.
+ return any([f.startswith(CR_WPT_DIR) and '-expected' not in f for f in files])
foolip 2016/11/01 22:07:44 In deps_updater.py there's an is_baseline. Using a
foolip 2016/11/02 13:15:32 Add a TODO for this?
+
+ def cr_commits_since(self, sha):
+ commits = self.host.executive.run_command([
+ 'git', 'rev-list', '--reverse', '{}..HEAD'.format(sha)
+ ])
+ return filter(bool, commits.split('\n'))
foolip 2016/11/01 22:07:44 Hopefully just return self....().splitlines() will
+
+ def subject(self, sha):
+ return self.host.executive.run_command([
+ 'git', 'show', sha, '--format=%s', '--no-patch'
foolip 2016/11/01 22:07:44 Nit: put the sha last consistently, assuming that
+ ])
+
+ def message(self, sha):
foolip 2016/11/01 22:07:44 Document that this actually includes both subject
+ return self.host.executive.run_command([
+ 'git', 'show', sha, '--format=%B', '--no-patch'
+ ])
+
+ def commit_position_str(self, sha):
foolip 2016/11/01 22:07:44 This is the same as the above, intentional?
+ return self.host.executive.run_command([
+ 'git', 'show', sha, '--format=%B', '--no-patch'
+ ])
+
+ def wpt_diff_patch(self, sha):
foolip 2016/11/01 22:07:44 When I saw it at the call site I wasn't sure what
+ """Get patch but only for files in LayoutTests/imported/wpt"""
+ return self.host.executive.run_command([
+ 'git', 'format-patch', '-1', '--stdout',
+ '{}'.format(sha), self.absolute_chromium_wpt_dir
foolip 2016/11/01 22:07:44 I think this will actually need to use some of the
jeffcarp 2016/11/01 23:21:18 Passing self.absolute_chromium_wpt_dir limits the
foolip 2016/11/02 13:15:32 It'll still include changes to expectations files
+ ])

Powered by Google App Engine
This is Rietveld 408576698