Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 import os | |
| 6 | |
| 7 CR_WPT_DIR = 'third_party/WebKit/LayoutTests/imported/wpt/' | |
| 8 | |
| 9 | |
| 10 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 :)
| |
| 11 | |
| 12 def __init__(self, host): | |
| 13 self.host = host | |
| 14 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
| |
| 15 | |
| 16 def exportable_commits_since(self, sha): | |
| 17 cr_commits = self.cr_commits_since(sha) | |
| 18 return filter(self.has_changes_in_wpt, cr_commits) | |
| 19 | |
| 20 def has_changes_in_wpt(self, sha): | |
| 21 """Returns if a Chromium sha has changed files in | |
| 22 LayoutTests/imported/wpt unless they're expectations | |
|
qyearsley
2016/11/01 22:57:45
This docstring could be clarified. A good docstrin
| |
| 23 """ | |
| 24 assert sha | |
| 25 | |
| 26 diff_files = self.host.executive.run_command([ | |
| 27 'git', 'diff-tree', '--no-commit-id', | |
| 28 '--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
| |
| 29 ]) | |
| 30 | |
| 31 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.
| |
| 32 return any([f.startswith(CR_WPT_DIR) and '-expected' not in f for f in f iles]) | |
|
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?
| |
| 33 | |
| 34 def cr_commits_since(self, sha): | |
| 35 commits = self.host.executive.run_command([ | |
| 36 'git', 'rev-list', '--reverse', '{}..HEAD'.format(sha) | |
| 37 ]) | |
| 38 return filter(bool, commits.split('\n')) | |
|
foolip
2016/11/01 22:07:44
Hopefully just return self....().splitlines() will
| |
| 39 | |
| 40 def subject(self, sha): | |
| 41 return self.host.executive.run_command([ | |
| 42 'git', 'show', sha, '--format=%s', '--no-patch' | |
|
foolip
2016/11/01 22:07:44
Nit: put the sha last consistently, assuming that
| |
| 43 ]) | |
| 44 | |
| 45 def message(self, sha): | |
|
foolip
2016/11/01 22:07:44
Document that this actually includes both subject
| |
| 46 return self.host.executive.run_command([ | |
| 47 'git', 'show', sha, '--format=%B', '--no-patch' | |
| 48 ]) | |
| 49 | |
| 50 def commit_position_str(self, sha): | |
|
foolip
2016/11/01 22:07:44
This is the same as the above, intentional?
| |
| 51 return self.host.executive.run_command([ | |
| 52 'git', 'show', sha, '--format=%B', '--no-patch' | |
| 53 ]) | |
| 54 | |
| 55 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
| |
| 56 """Get patch but only for files in LayoutTests/imported/wpt""" | |
| 57 return self.host.executive.run_command([ | |
| 58 'git', 'format-patch', '-1', '--stdout', | |
| 59 '{}'.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
| |
| 60 ]) | |
| OLD | NEW |