Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame^] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | # Copyright 2019 The Chromium Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | """ |
| 7 | Integrate into Chromium and run webtests. |
| 8 | """ |
| 9 | |
| 10 | import argparse |
| 11 | import os |
| 12 | import shutil |
| 13 | import subprocess |
| 14 | import sys |
| 15 | |
| 16 | |
| 17 | def parse_options(cli_args): |
| 18 | parser = argparse.ArgumentParser(description='Integrate into Chromium and run webtests.') |
| 19 | parser.add_argument('chromium_dir', help='Chromium directory') |
| 20 | parser.add_argument('devtools_dir', help='DevTools directory') |
| 21 | parser.add_argument('--nopatch', help='skip patching', action='store_true') |
| 22 | parser.add_argument('--nobuild', help='skip building', action='store_true') |
| 23 | return parser.parse_args(cli_args) |
| 24 | |
| 25 | |
| 26 | def patch(options): |
| 27 | subprocess.check_call(['git', 'fetch', 'origin'], cwd=options.chromium_dir) |
| 28 | subprocess.check_call(['git', 'checkout', 'origin/lkgr'], cwd=options.chromium_dir) |
| 29 | DEVTOOLS_PATH = os.path.abspath(options.devtools_dir) |
| 30 | PATCH_FILE = os.path.join(DEVTOOLS_PATH, 'scripts', 'chromium.patch') |
| 31 | subprocess.check_call(['git', 'apply', PATCH_FILE], cwd=options.chromium_dir) |
| 32 | subprocess.check_call(['gclient', 'setdep', '--var=devtools_frontend_url=file://%s' % DEVTOOLS_PATH], cwd=options.chromium_dir) |
| 33 | subprocess.check_call(['gclient', 'setdep', '--var=devtools_frontend_revision=FETCH_HEAD'], cwd=options.chromium_dir) |
| 34 | subprocess.check_call(['gclient', 'sync'], cwd=options.chromium_dir) |
| 35 | |
| 36 | |
| 37 | def build(options): |
| 38 | subprocess.check_call(['autoninja', '-C', 'out/Release', 'blink_tests'], cwd=options.chromium_dir) |
| 39 | |
| 40 | |
| 41 | def run(options): |
| 42 | subprocess.check_call( |
| 43 | [os.path.join(options.chromium_dir, 'third_party', 'blink', 'tools', 'run_web_tests.py'), 'http/tests/devtools/']) |
| 44 | |
| 45 | |
| 46 | if __name__ == '__main__': |
| 47 | OPTIONS = parse_options(sys.argv[1:]) |
| 48 | if not OPTIONS.nopatch: |
| 49 | patch(OPTIONS) |
| 50 | if not OPTIONS.nobuild: |
| 51 | build(OPTIONS) |
| 52 | run(OPTIONS) |