blob: 0b8ddcf323c333ccbdd09654816c5a09f9ebcd49 [file] [log] [blame]
#!/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 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
BLINK_TOOLS_DIR = os.path.join(common.SRC_DIR, 'third_party', 'blink', 'tools')
WPT_METADATA_DIR = "../../wpt_expectations_metadata/"
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 rest_args(self):
rest_args = super(WPTTestAdapter, self).rest_args
# Here we add all of the arguments required to run WPT tests on Chrome.
"MAP nonexistent.*.test ~NOTFOUND, MAP *.test",
# By specifying metadata above, WPT will try to find manifest in the
# metadata directory. So here we point it back to the correct path
# for the manifest.
# TODO(lpz): Allowing WPT to rebuild its own manifest temporarily to
# gauge performance impact. Issue with specifying the base manifest
# below is that it can get stale if tests are renamed, and requires
# a lengthy import/export cycle to refresh. So we allow WPT to
# update the manifest in cast it's stale.
# ( The flags below are temporary to aid debugging
# See if multi-processing affects timeouts.
# TODO(lpz): Consider removing --processes and compute automatically
# from multiprocessing.cpu_count()
return rest_args
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.
def clean_up_after_test_run(self):
os.path.join(BLINK_TOOLS_DIR, ''),
'--new-json-output-dir', self.options.new_json_output_dir,
'--new-json-output-filename', self.options.new_json_output_filename,
def main():
# First, generate WPT metadata files.
os.path.join(BLINK_TOOLS_DIR, ''),
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))