| #!/usr/bin/env vpython |
| # Copyright 2018 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. |
| |
| """Runs WPT as an isolate bundle. |
| |
| This script maps flags supported by run_isolate_script_test.py to flags that are |
| understood by WPT. |
| |
| Here's the mapping [isolate script flag] : [wpt flag] |
| --isolated-script-test-output : --log-chromium |
| --total-shards : --total-chunks |
| --shard-index : -- this-chunk |
| """ |
| |
| import json |
| import os |
| import sys |
| |
| import common |
| |
| |
| class WPTTestAdapter(common.BaseIsolatedScriptArgsAdapter): |
| |
| def generate_test_output_args(self, output): |
| return ['--log-chromium', output] |
| |
| def generate_sharding_args(self, total_shards, shard_index): |
| return ['--total-chunks=%d' % total_shards, |
| # shard_index is 0-based but WPT's this-chunk to be 1-based |
| '--this-chunk=%d' % (shard_index + 1)] |
| |
| def add_extra_arguments(self, parser): |
| # These args are used to rewrite the output generated by WPT to include |
| # missing features, such as flakineess expectations. |
| parser.add_argument("--old-json-output-file-path") |
| parser.add_argument("--new-json-output-dir") |
| parser.add_argument("--new-json-output-filename") |
| |
| def clean_up_after_test_run(self): |
| common.run_command([ |
| sys.executable, |
| os.path.join(common.SRC_DIR, 'third_party', 'blink', 'tools', |
| 'update_wpt_output.py'), |
| '--old-json-output-file-path', |
| self.options.old_json_output_file_path, |
| '--new-json-output-dir', self.options.new_json_output_dir, |
| '--new-json-output-filename', self.options.new_json_output_filename, |
| ]) |
| |
| |
| def main(): |
| adapter = WPTTestAdapter() |
| return adapter.run_test() |
| |
| |
| # This is not really a "script test" so does not need to manually add |
| # any additional compile targets. |
| def main_compile_targets(args): |
| json.dump([], args.output) |
| |
| |
| if __name__ == '__main__': |
| # Conform minimally to the protocol defined by ScriptTest. |
| if 'compile_targets' in sys.argv: |
| funcs = { |
| 'run': None, |
| 'compile_targets': main_compile_targets, |
| } |
| sys.exit(common.run_script(sys.argv[1:], funcs)) |
| sys.exit(main()) |