blob: bb47d0c0c742a6162d59a0db916073fc88fd25ee [file] [edit]
#!/usr/bin/env python3
# Copyright (C) 2017 Igalia S.L.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import logging
import optparse
import signal
import sys
from webkitpy.port.linux_container_sdk_utils import maybe_enter_webkit_container_sdk, maybe_use_container_sdk_root_dir
maybe_enter_webkit_container_sdk()
from webkitpy.common.host import Host
from webkitpy.port.factory import configuration_options
from webkitpy.results.options import upload_options
from webkitpy.webdriver_tests.webdriver_test_runner import WebDriverTestRunner
from webkitpy.common.system.logutils import configure_logging
maybe_use_container_sdk_root_dir()
_log = logging.getLogger(__name__)
option_parser = optparse.OptionParser(usage='usage: %prog [options] [test...]')
option_parser.add_option('--verbose', action='store_true', dest='verbose',
help='Show debug message')
option_parser.add_option('--platform', action='store',
help='Platform to use (e.g., "gtk")')
option_parser.add_option('--gtk', action='store_const', dest='platform', const='gtk',
help='Alias for --platform=gtk')
option_parser.add_option('--wpe', action='store_const', dest='platform', const='wpe',
help='Alias for --platform=wpe')
option_parser.add_option('--timeout', action='store', type='int', dest='timeout', default=10,
help='Time in seconds until a test times out (use 0 to disable)')
option_parser.add_option('--json-output', action='store', metavar="FILE",
help='Write results to JSON file at the given path')
option_parser.add_option('--display-server', choices=['xvfb', 'xorg', 'weston', 'wayland', 'headless'], default='xvfb',
help='"xvfb": Use a virtualized X11 server. "xorg": Use the current X11 session. '
'"weston": Use a virtualized Weston server. "wayland": Use the current wayland session.'
'"headless": Headless mode in current session')
option_parser.add_option('--disable-webdriver-bidi', action='store_false',
dest='enable_webdriver_bidi', default=True,
help='Run Selenium tests with BiDi disabled')
option_parser.add_option('--force', action='store_true',
help='Ignore the expectations file, running all given tests and assuming they should PASS')
option_parser.add_option('--site-isolation', action='store_true',
help='Run the tests with Site Isolation, and use its expectations (Mac only)')
option_parser.add_option("--test-list", action="append",
help="Read list of tests to run from file", metavar="FILE")
configuration_group = optparse.OptionGroup(option_parser, 'Configuration options')
configuration_group.add_options(configuration_options())
option_parser.add_option_group(configuration_group)
upload_group = optparse.OptionGroup(option_parser, 'Upload options')
upload_group.add_options(upload_options())
option_parser.add_option_group(upload_group)
options, args = option_parser.parse_args()
configure_logging(logging.DEBUG if options.verbose else logging.INFO)
if options.test_list:
for test_list_file in options.test_list:
try:
with open(test_list_file) as f:
for line in f:
line = line.strip()
if line and not line.startswith('#'):
args.append(line)
except Exception as e:
_log.error(f'Failed to read test list "{test_list_file}": "{e}". Aborting')
sys.exit(1)
try:
port = Host().port_factory.get(options.platform, options)
except NotImplementedError as e:
_log.error(str(e))
sys.exit(-1)
if options.site_isolation and port.port_name != 'mac':
_log.error('--site-isolation is only supported on Mac')
sys.exit(-1)
if options.site_isolation:
if options.result_report_flavor:
_log.error('--site-isolation sets the result flavor, so it can\'t be combined with --result-report-flavor')
sys.exit(-1)
options.result_report_flavor = 'site-isolation'
runner = WebDriverTestRunner(port)
# By default, SIGTERM ends this process without running the finally blocks that stop the driver and the WPT
# server. The driver has a process group of its own, so it and its browser would be left running.
signal.signal(signal.SIGTERM, lambda signal_number, frame: sys.exit(128 + signal_number))
try:
runner.run(args)
finally:
runner.teardown()
retval = runner.process_results()
if options.json_output is not None:
runner.dump_results_to_json_file(options.json_output)
if options.report_urls and not runner.upload_results(options):
retval = retval or 1
sys.exit(retval)