forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwpt-export
executable file
·68 lines (53 loc) · 2.22 KB
/
wpt-export
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
# Copyright 2017 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.
"""Exports local changes to web-platform-tests in Chromium to upstream repo.
This script checks LayoutTests/external/wpt for changes that can be exported,
then creates a patch, and creates and lands a pull request for the upstream
repository.
"""
import argparse
import json
import logging
from webkitpy.common.host import Host
from webkitpy.w3c.test_exporter import TestExporter
from webkitpy.w3c.wpt_github import WPTGitHub
_log = logging.getLogger(__name__)
def main():
logging.basicConfig(level=logging.INFO, format='%(message)s')
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
'--dry-run', action='store_true',
help='See what would be done without actually creating or merging '
'any pull requests.')
parser.add_argument(
'--gh-user',
help='GitHub user name. Can also be provided using the GH_USER '
'environment variable.')
parser.add_argument(
'--gh-token',
help='GitHub token or password. Can also be provided using the GH_TOKEN '
'environment variable.')
parser.add_argument(
'--github-credentials-json',
help='A JSON file with schema {"GH_USER": "", "GH_TOKEN": ""}. '
'This will override credentials that were passed via command line or env var.')
args = parser.parse_args()
host = Host()
if not args.gh_user:
args.gh_user = host.environ.get('GH_USER')
if not args.gh_token:
args.gh_token = host.environ.get('GH_TOKEN')
if args.github_credentials_json:
with open(args.github_credentials_json, 'r') as f:
contents = json.load(f)
args.gh_user = contents['GH_USER']
args.gh_token = contents['GH_TOKEN']
if not (args.gh_user and args.gh_token):
parser.error('Must provide both gh_user and gh_token for GitHub.')
wpt_github = WPTGitHub(host, args.gh_user, args.gh_token)
test_exporter = TestExporter(host, wpt_github, dry_run=args.dry_run)
test_exporter.run()
if __name__ == '__main__':
main()