blob: ed35213716f99bbb4118dd783b16116d9881da35 [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 shutil
import sys
import common
import wpt_common
# The checked-in manifest is copied to a temporary working directory so it can
# be mutated by wptrunner
WPT_CHECKED_IN_METADATA_DIR = "../../third_party/blink/web_tests/external/wpt"
WPT_METADATA_OUTPUT_DIR = "../../out/{}/wpt_expectations_metadata/"
CHROME_BINARY = "../../out/{}/chrome"
CHROME_BINARY_MAC = "../../out/{}/"
CHROMEDRIVER_BINARY = "../../out/{}/chromedriver"
DEFAULT_ISOLATED_SCRIPT_TEST_OUTPUT = "../../out/{}/results.json"
MOJO_JS_PATH = "../../out/{}/gen/"
TESTS_ROOT_DIR = "../../third_party/blink/web_tests/external/wpt"
class WPTTestAdapter(wpt_common.BaseWptScriptAdapter):
def rest_args(self):
rest_args = super(WPTTestAdapter, self).rest_args
# Update the output directory to the default if it's not set.
chrome = CHROME_BINARY.format(
chromedriver = CHROMEDRIVER_BINARY.format(
chrome = "%s.exe" % chrome
chromedriver = "%s.exe" % chromedriver
chrome = CHROME_BINARY_MAC.format(
# Here we add all of the arguments required to run WPT tests on Chrome.
# TODO( We should be running WPT under Python 3.
] + self.options.test_list + [
"--binary=" + chrome,
"MAP nonexistent.*.test ~NOTFOUND, MAP *.test",
"--webdriver-binary=" + chromedriver,
# Exclude webdriver tests for now. They are run separately on the CI
# Setting --no-fail-on-unexpected makes the return code of wpt 0
# even if there were test failures. The CQ doesn't like this since
# it uses the exit code to determine which shards to retry (ie:
# those that had non-zero exit codes).
"--metadata", WPT_METADATA_OUTPUT_DIR.format(,
# 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.
"--manifest", WPT_WORKING_COPY_MANIFEST.format(,
# ( 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()
"--processes=" + self.options.child_processes,
"--mojojs-path=" + MOJO_JS_PATH.format(,
"--tests=" + TESTS_ROOT_DIR,
return rest_args
def add_extra_arguments(self, parser):
target_help = "Specify the target build subdirectory under src/out/"
parser.add_argument("-t", "--target", dest="target", default="Release",
child_processes_help = "Number of drivers to run in parallel"
parser.add_argument("-j", "--child-processes", dest="child_processes",
default="1", help=child_processes_help)
parser.add_argument("test_list", nargs="*",
help="List of tests or test directories to run")
def maybe_set_default_isolated_script_test_output(self):
if self.options.isolated_script_test_output:
print("--isolated-script-test-output not set, defaulting to %s" %
self.options.isolated_script_test_output = default_value
def do_pre_test_run_tasks(self):
# Copy the checked-in manifest to the temporary working directory
# Generate WPT metadata files.
os.path.join(wpt_common.BLINK_TOOLS_DIR, ''),
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))