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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_exporter.py

Issue 2579193002: Merge ChromiumWPT functionality into TestExporter, use ChromiumCommits (Closed)
Patch Set: Address CL feedback Created 4 years 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 unified diff | Download patch
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6
6 from webkitpy.w3c.local_wpt import LocalWPT 7 from webkitpy.w3c.local_wpt import LocalWPT
7 from webkitpy.w3c.chromium_wpt import ChromiumWPT
8 from webkitpy.w3c.chromium_commit import ChromiumCommit 8 from webkitpy.w3c.chromium_commit import ChromiumCommit
9 from webkitpy.w3c.deps_updater import DepsUpdater
9 10
10 _log = logging.getLogger(__name__) 11 _log = logging.getLogger(__name__)
11 12
13 CHROMIUM_WPT_DIR = 'third_party/WebKit/LayoutTests/imported/wpt/'
14
12 15
13 class TestExporter(object): 16 class TestExporter(object):
14 17
15 def __init__(self, host, wpt_github, dry_run=False): 18 def __init__(self, host, wpt_github, dry_run=False):
16 self.host = host 19 self.host = host
17 self.wpt_github = wpt_github 20 self.wpt_github = wpt_github
18 self.dry_run = dry_run 21 self.dry_run = dry_run
19 22
20 def run(self): 23 def run(self):
21 # First, poll for an in-flight pull request and merge if exists 24 # First, poll for an in-flight pull request and merge if exists
(...skipping 15 matching lines...) Expand all
37 _log.info('PR merged!') 40 _log.info('PR merged!')
38 elif len(pull_requests) > 1: 41 elif len(pull_requests) > 1:
39 _log.error(pull_requests) 42 _log.error(pull_requests)
40 # TODO(jeffcarp): Print links to PRs 43 # TODO(jeffcarp): Print links to PRs
41 raise Exception('More than two in-flight PRs!') 44 raise Exception('More than two in-flight PRs!')
42 45
43 # Second, look for exportable commits in Chromium 46 # Second, look for exportable commits in Chromium
44 # At this point, no in-flight PRs should exist 47 # At this point, no in-flight PRs should exist
45 # If there was an issue merging, it should have errored out 48 # If there was an issue merging, it should have errored out
46 local_wpt = LocalWPT(self.host, use_github=False) 49 local_wpt = LocalWPT(self.host, use_github=False)
47 chromium_wpt = ChromiumWPT(self.host)
48 50
49 # TODO(jeffcarp): have the script running this fetch Chromium origin/mas ter 51 # TODO(jeffcarp): have the script running this fetch Chromium origin/mas ter
50 # TODO(jeffcarp): move WPT fetch out of its constructor to match planned ChromiumWPT pattern 52 # TODO(jeffcarp): move WPT fetch out of its constructor to match planned ChromiumWPT pattern
51 53
52 wpt_commit, chromium_commit = local_wpt.most_recent_chromium_commit() 54 wpt_commit, chromium_commit = local_wpt.most_recent_chromium_commit()
53 assert chromium_commit, 'No Chromium commit found, this is impossible' 55 assert chromium_commit, 'No Chromium commit found, this is impossible'
54 56
55 wpt_behind_master = local_wpt.commits_behind_master(wpt_commit) 57 wpt_behind_master = local_wpt.commits_behind_master(wpt_commit)
56 58
57 _log.info('\nLast Chromium export commit in web-platform-tests:') 59 _log.info('\nLast Chromium export commit in web-platform-tests:')
58 _log.info('web-platform-tests@%s', wpt_commit) 60 _log.info('web-platform-tests@%s', wpt_commit)
59 _log.info('(%d behind web-platform-tests@origin/master)', wpt_behind_mas ter) 61 _log.info('(%d behind web-platform-tests@origin/master)', wpt_behind_mas ter)
60 62
61 _log.info('\nThe above WPT commit points to the following Chromium commi t:') 63 _log.info('\nThe above WPT commit points to the following Chromium commi t:')
62 _log.info('chromium@%s', chromium_commit.sha) 64 _log.info('chromium@%s', chromium_commit.sha)
63 _log.info('(%d behind chromium@origin/master)', chromium_commit.num_behi nd_master()) 65 _log.info('(%d behind chromium@origin/master)', chromium_commit.num_behi nd_master())
64 66
65 # TODO(jeffcarp): Have this function return ChromiumCommits 67 exportable_commits = self.exportable_commits_since(chromium_commit.sha)
66 exportable_commits = chromium_wpt.exportable_commits_since(chromium_comm it.sha)
67 68
68 if not exportable_commits: 69 if not exportable_commits:
69 _log.info('No exportable commits found in Chromium, stopping.') 70 _log.info('No exportable commits found in Chromium, stopping.')
70 return 71 return
71 72
72 _log.info('Found %d exportable commits in Chromium:', len(exportable_com mits)) 73 _log.info('Found %d exportable commits in Chromium:', len(exportable_com mits))
73 for commit in exportable_commits: 74 for commit in exportable_commits:
74 _log.info('- %s %s', commit, chromium_wpt.subject(commit)) 75 _log.info('- %s %s', commit, commit.subject())
75 76
76 outbound_commit = ChromiumCommit(self.host, sha=exportable_commits[0]) 77 outbound_commit = exportable_commits[0]
77 _log.info('Picking the earliest commit and creating a PR') 78 _log.info('Picking the earliest commit and creating a PR')
78 _log.info('- %s %s', outbound_commit.sha, outbound_commit.subject()) 79 _log.info('- %s %s', outbound_commit.sha, outbound_commit.subject())
79 80
80 patch = outbound_commit.format_patch() 81 patch = outbound_commit.format_patch()
81 message = outbound_commit.message() 82 message = outbound_commit.message()
82 83
83 # TODO: now do a test comparison of patch against local WPT 84 # TODO: now do a test comparison of patch against local WPT
84 85
85 if self.dry_run: 86 if self.dry_run:
86 _log.info('[dry_run] Stopping before creating PR') 87 _log.info('[dry_run] Stopping before creating PR')
87 _log.info('\n\n[dry_run] message:') 88 _log.info('\n\n[dry_run] message:')
88 _log.info(message) 89 _log.info(message)
89 _log.info('\n\n[dry_run] patch:') 90 _log.info('\n\n[dry_run] patch:')
90 _log.info(patch) 91 _log.info(patch)
91 return 92 return
92 93
93 local_branch_name = local_wpt.create_branch_with_patch(message, patch) 94 local_branch_name = local_wpt.create_branch_with_patch(message, patch)
94 95
95 response_data = self.wpt_github.create_pr( 96 response_data = self.wpt_github.create_pr(
96 local_branch_name=local_branch_name, 97 local_branch_name=local_branch_name,
97 desc_title=outbound_commit.subject(), 98 desc_title=outbound_commit.subject(),
98 body=outbound_commit.body()) 99 body=outbound_commit.body())
99 100
100 _log.info('Create PR response: %s', response_data) 101 _log.info('Create PR response: %s', response_data)
102
103 def exportable_commits_since(self, commit):
104 """Returns SHAs of exportable commits since `commit` in chronological or der.
105
106 Args:
107 commit: The SHA of the Chromium commit from which this method will l ook.
108 """
109 repo_root = self.host.executive.run_command([
110 'git', 'rev-parse', '--show-toplevel'
111 ]).strip()
112
113 commits = self.host.executive.run_command([
114 'git', 'rev-list', '{}..HEAD'.format(commit), '--reverse',
115 '--', repo_root + '/' + CHROMIUM_WPT_DIR
116 ]).splitlines()
117
118 chromium_commits = [ChromiumCommit(self.host, sha=c) for c in commits]
119
120 def is_exportable(chromium_commit):
121 message = chromium_commit.message()
122 return (
123 'NOEXPORT=true' not in message
124 and not message.startswith('Import ')
125 # TODO(jeffcarp): change this to allow any commit with
126 # any non-expectation changes to be exportable
127 and not self._has_expectations(chromium_commit)
128 )
129
130 return filter(is_exportable, chromium_commits)
131
132 def _has_expectations(self, chromium_commit):
133 files = self.host.executive.run_command([
134 'git', 'diff-tree', '--no-commit-id',
135 '--name-only', '-r', chromium_commit.sha
136 ]).splitlines()
137
138 return any(DepsUpdater.is_baseline(f) for f in files)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698