Commit dc96c0b0 authored by Luke Zielinski's avatar Luke Zielinski Committed by Commit Bot

Introduce testing/scripts/wpt_common.py

This will contain functionality that is shared between desktop and
android wptrunner. For now it's just copying the output to
full_results.json but the plan is to start adding support for more files
that are needed by the results viewer.

Change-Id: Iedd7e9a624274d90dd79f91c60ae3452d483a1f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2218528Reviewed-by: default avatarStephen Martinis <martiniss@chromium.org>
Reviewed-by: default avatarRakib Hasan <rmhasan@google.com>
Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Commit-Queue: Luke Z <lpz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774624}
parent 232a35e4
...@@ -9,8 +9,11 @@ martiniss@chromium.org ...@@ -9,8 +9,11 @@ martiniss@chromium.org
per-file check_static_initializers.py=thakis@chromium.org per-file check_static_initializers.py=thakis@chromium.org
per-file check_static_initializers.py=thomasanderson@chromium.org per-file check_static_initializers.py=thomasanderson@chromium.org
per-file run-wpt_tests.py=lpz@chromium.org per-file run_wpt_tests.py=lpz@chromium.org
per-file run_wpt_tests.py=robertma@chromium.org per-file run_wpt_tests.py=robertma@chromium.org
per-file wpt_common.py=lpz@chromium.org
per-file wpt_common.py=robertma@chromium.org
per-file wpt_common.py=rmhasan@chromium.org
per-file run_performance_tests.py=johnchen@chromium.org per-file run_performance_tests.py=johnchen@chromium.org
per-file run_performance_tests.py=wenbinzhang@google.com per-file run_performance_tests.py=wenbinzhang@google.com
......
...@@ -30,7 +30,8 @@ def main(argv): ...@@ -30,7 +30,8 @@ def main(argv):
if filename in ('common.py', if filename in ('common.py',
'get_compile_targets.py', 'get_compile_targets.py',
'gpu_integration_test_adapter.py', 'gpu_integration_test_adapter.py',
'sizes_common.py'): 'sizes_common.py',
'wpt_common.py'):
continue continue
with common.temporary_file() as tempfile_path: with common.temporary_file() as tempfile_path:
......
...@@ -33,6 +33,7 @@ import shutil ...@@ -33,6 +33,7 @@ import shutil
import sys import sys
import common import common
import wpt_common
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -60,9 +61,7 @@ if PYUTILS not in sys.path: ...@@ -60,9 +61,7 @@ if PYUTILS not in sys.path:
from py_utils.tempfile_ext import NamedTemporaryDirectory from py_utils.tempfile_ext import NamedTemporaryDirectory
BLINK_TOOLS_DIR = os.path.join(SRC_DIR, 'third_party', 'blink', 'tools') DEFAULT_WPT = os.path.join(wpt_common.WEB_TESTS_DIR, 'external', 'wpt', 'wpt')
WEB_TESTS_DIR = os.path.join(BLINK_TOOLS_DIR, os.pardir, 'web_tests')
DEFAULT_WPT = os.path.join(WEB_TESTS_DIR, 'external', 'wpt', 'wpt')
ANDROID_WEBLAYER = 'android_weblayer' ANDROID_WEBLAYER = 'android_weblayer'
ANDROID_WEBVIEW = 'android_webview' ANDROID_WEBVIEW = 'android_webview'
...@@ -107,7 +106,7 @@ def _get_adapter(device): ...@@ -107,7 +106,7 @@ def _get_adapter(device):
return WPTClankAdapter(device) return WPTClankAdapter(device)
class WPTAndroidAdapter(common.BaseIsolatedScriptArgsAdapter): class WPTAndroidAdapter(wpt_common.BaseWptScriptAdapter):
def __init__(self, device): def __init__(self, device):
self.pass_through_wpt_args = [] self.pass_through_wpt_args = []
...@@ -121,14 +120,6 @@ class WPTAndroidAdapter(common.BaseIsolatedScriptArgsAdapter): ...@@ -121,14 +120,6 @@ class WPTAndroidAdapter(common.BaseIsolatedScriptArgsAdapter):
# its safe to parse the arguments and set self._options # its safe to parse the arguments and set self._options
self.parse_args() self.parse_args()
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)]
@property @property
def rest_args(self): def rest_args(self):
rest_args = super(WPTAndroidAdapter, self).rest_args rest_args = super(WPTAndroidAdapter, self).rest_args
...@@ -178,14 +169,15 @@ class WPTAndroidAdapter(common.BaseIsolatedScriptArgsAdapter): ...@@ -178,14 +169,15 @@ class WPTAndroidAdapter(common.BaseIsolatedScriptArgsAdapter):
metadata_builder_cmd = [ metadata_builder_cmd = [
sys.executable, sys.executable,
os.path.join(BLINK_TOOLS_DIR, 'build_wpt_metadata.py'), os.path.join(wpt_common.BLINK_TOOLS_DIR, 'build_wpt_metadata.py'),
'--android-product', '--android-product',
self.options.product, self.options.product,
'--ignore-default-expectations', '--ignore-default-expectations',
'--metadata-output-dir', '--metadata-output-dir',
self._metadata_dir, self._metadata_dir,
'--additional-expectations', '--additional-expectations',
os.path.join(WEB_TESTS_DIR, 'android', 'AndroidWPTNeverFixTests') os.path.join(wpt_common.WEB_TESTS_DIR, 'android',
'AndroidWPTNeverFixTests')
] ]
metadata_builder_cmd.extend(self._extra_metadata_builder_args()) metadata_builder_cmd.extend(self._extra_metadata_builder_args())
return common.run_command(metadata_builder_cmd) return common.run_command(metadata_builder_cmd)
...@@ -205,24 +197,6 @@ class WPTAndroidAdapter(common.BaseIsolatedScriptArgsAdapter): ...@@ -205,24 +197,6 @@ class WPTAndroidAdapter(common.BaseIsolatedScriptArgsAdapter):
# which was deleted # which was deleted
self._metadata_dir = None self._metadata_dir = None
def do_post_test_run_tasks(self):
# Move json results into layout-test-results directory
results_dir = os.path.dirname(self.options.isolated_script_test_output)
layout_test_results = os.path.join(results_dir, 'layout-test-results')
os.mkdir(layout_test_results)
shutil.copyfile(self.options.isolated_script_test_output,
os.path.join(layout_test_results, 'full_results.json'))
# create full_results_jsonp.js file which is used to
# load results into the results viewer
with open(self.options.isolated_script_test_output, 'r') as full_results, \
open(os.path.join(
layout_test_results, 'full_results_jsonp.js'), 'w') as json_js:
json_js.write('ADD_FULL_RESULTS(%s);' % full_results.read())
# copy layout test results viewer to layout-test-results directory
shutil.copyfile(
os.path.join(WEB_TESTS_DIR, 'fast', 'harness', 'results.html'),
os.path.join(layout_test_results, 'results.html'))
def add_extra_arguments(self, parser): def add_extra_arguments(self, parser):
# TODO: |pass_through_args| are broke and need to be supplied by way of # TODO: |pass_through_args| are broke and need to be supplied by way of
# --binary-arg". # --binary-arg".
...@@ -307,7 +281,7 @@ class WPTWeblayerAdapter(WPTAndroidAdapter): ...@@ -307,7 +281,7 @@ class WPTWeblayerAdapter(WPTAndroidAdapter):
def _extra_metadata_builder_args(self): def _extra_metadata_builder_args(self):
return [ return [
'--additional-expectations', '--additional-expectations',
os.path.join(WEB_TESTS_DIR, os.path.join(wpt_common.WEB_TESTS_DIR,
'android', 'WeblayerWPTOverrideExpectations')] 'android', 'WeblayerWPTOverrideExpectations')]
def add_extra_arguments(self, parser): def add_extra_arguments(self, parser):
...@@ -350,7 +324,8 @@ class WPTWebviewAdapter(WPTAndroidAdapter): ...@@ -350,7 +324,8 @@ class WPTWebviewAdapter(WPTAndroidAdapter):
return [ return [
'--additional-expectations', '--additional-expectations',
os.path.join( os.path.join(
WEB_TESTS_DIR, 'android', 'WebviewWPTOverrideExpectations')] wpt_common.WEB_TESTS_DIR, 'android',
'WebviewWPTOverrideExpectations')]
def add_extra_arguments(self, parser): def add_extra_arguments(self, parser):
super(WPTWebviewAdapter, self).add_extra_arguments(parser) super(WPTWebviewAdapter, self).add_extra_arguments(parser)
...@@ -384,7 +359,8 @@ class WPTClankAdapter(WPTAndroidAdapter): ...@@ -384,7 +359,8 @@ class WPTClankAdapter(WPTAndroidAdapter):
def _extra_metadata_builder_args(self): def _extra_metadata_builder_args(self):
return [ return [
'--additional-expectations', '--additional-expectations',
os.path.join(WEB_TESTS_DIR, 'android', 'ClankWPTOverrideExpectations')] os.path.join(wpt_common.WEB_TESTS_DIR, 'android',
'ClankWPTOverrideExpectations')]
def add_extra_arguments(self, parser): def add_extra_arguments(self, parser):
super(WPTClankAdapter, self).add_extra_arguments(parser) super(WPTClankAdapter, self).add_extra_arguments(parser)
......
...@@ -16,26 +16,16 @@ Here's the mapping [isolate script flag] : [wpt flag] ...@@ -16,26 +16,16 @@ Here's the mapping [isolate script flag] : [wpt flag]
import json import json
import os import os
import shutil
import sys import sys
import common import common
import wpt_common
BLINK_TOOLS_DIR = os.path.join(common.SRC_DIR, 'third_party', 'blink', 'tools')
WEB_TESTS_DIR = os.path.join(BLINK_TOOLS_DIR, os.pardir, 'web_tests')
WPT_METADATA_DIR = "../../wpt_expectations_metadata/" WPT_METADATA_DIR = "../../wpt_expectations_metadata/"
WPT_OVERRIDE_EXPECTATIONS_PATH = ( WPT_OVERRIDE_EXPECTATIONS_PATH = (
"../../third_party/blink/web_tests/WPTOverrideExpectations") "../../third_party/blink/web_tests/WPTOverrideExpectations")
class WPTTestAdapter(common.BaseIsolatedScriptArgsAdapter): class WPTTestAdapter(wpt_common.BaseWptScriptAdapter):
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)]
@property @property
def rest_args(self): def rest_args(self):
...@@ -88,33 +78,11 @@ class WPTTestAdapter(common.BaseIsolatedScriptArgsAdapter): ...@@ -88,33 +78,11 @@ class WPTTestAdapter(common.BaseIsolatedScriptArgsAdapter):
]) ])
return rest_args return rest_args
def do_post_test_run_tasks(self):
# Move json results into layout-test-results directory
results_dir = os.path.dirname(self.options.isolated_script_test_output)
layout_test_results = os.path.join(results_dir, 'layout-test-results')
if os.path.exists(layout_test_results):
shutil.rmtree(layout_test_results)
os.mkdir(layout_test_results)
shutil.copyfile(self.options.isolated_script_test_output,
os.path.join(layout_test_results, 'full_results.json'))
# create full_results_jsonp.js file which is used to
# load results into the results viewer
with open(self.options.isolated_script_test_output, 'r') \
as full_results, \
open(os.path.join(
layout_test_results, 'full_results_jsonp.js'), 'w') \
as json_js:
json_js.write('ADD_FULL_RESULTS(%s);' % full_results.read())
# copy layout test results viewer to layout-test-results directory
shutil.copyfile(
os.path.join(WEB_TESTS_DIR, 'fast', 'harness', 'results.html'),
os.path.join(layout_test_results, 'results.html'))
def main(): def main():
# First, generate WPT metadata files. # First, generate WPT metadata files.
common.run_command([ common.run_command([
sys.executable, sys.executable,
os.path.join(BLINK_TOOLS_DIR, 'build_wpt_metadata.py'), os.path.join(wpt_common.BLINK_TOOLS_DIR, 'build_wpt_metadata.py'),
"--metadata-output-dir", "--metadata-output-dir",
WPT_METADATA_DIR, WPT_METADATA_DIR,
"--additional-expectations", "--additional-expectations",
......
# Copyright 2020 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.
import os
import shutil
import common
BLINK_TOOLS_DIR = os.path.join(common.SRC_DIR, 'third_party', 'blink', 'tools')
WEB_TESTS_DIR = os.path.join(BLINK_TOOLS_DIR, os.pardir, 'web_tests')
class BaseWptScriptAdapter(common.BaseIsolatedScriptArgsAdapter):
"""The base class for script adapters that use wptrunner to execute web
platform tests. This contains any code shared between these scripts, such
as integrating output with the results viewer. Subclasses contain other
(usually platform-specific) logic."""
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 do_post_test_run_tasks(self):
# Move json results into layout-test-results directory
results_dir = os.path.dirname(self.options.isolated_script_test_output)
layout_test_results = os.path.join(results_dir, 'layout-test-results')
if os.path.exists(layout_test_results):
shutil.rmtree(layout_test_results)
os.mkdir(layout_test_results)
shutil.copyfile(self.options.isolated_script_test_output,
os.path.join(layout_test_results, 'full_results.json'))
# create full_results_jsonp.js file which is used to
# load results into the results viewer
with open(self.options.isolated_script_test_output, 'r') \
as full_results, \
open(os.path.join(
layout_test_results, 'full_results_jsonp.js'), 'w') \
as json_js:
json_js.write('ADD_FULL_RESULTS(%s);' % full_results.read())
# copy layout test results viewer to layout-test-results directory
shutil.copyfile(
os.path.join(WEB_TESTS_DIR, 'fast', 'harness', 'results.html'),
os.path.join(layout_test_results, 'results.html'))
\ No newline at end of file
...@@ -7,6 +7,7 @@ group("wpt_tests_isolate") { ...@@ -7,6 +7,7 @@ group("wpt_tests_isolate") {
testonly = true testonly = true
data = [ data = [
"//testing/scripts/common.py", "//testing/scripts/common.py",
"//testing/scripts/wpt_common.py",
"//testing/xvfb.py", "//testing/xvfb.py",
# Include blinkpy tools for setting up expectations. # Include blinkpy tools for setting up expectations.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment