mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Use most recent webdriver test harness.
This commit is contained in:
parent
6797c2f7c5
commit
8761f53391
4 changed files with 10 additions and 79 deletions
|
@ -65,6 +65,7 @@ def set_defaults(paths, kwargs):
|
||||||
bin_path = servo_path("target", bin_dir, bin_name)
|
bin_path = servo_path("target", bin_dir, bin_name)
|
||||||
|
|
||||||
kwargs["binary"] = bin_path
|
kwargs["binary"] = bin_path
|
||||||
|
kwargs["webdriver_binary"] = bin_path
|
||||||
|
|
||||||
if kwargs["processes"] is None:
|
if kwargs["processes"] is None:
|
||||||
kwargs["processes"] = multiprocessing.cpu_count()
|
kwargs["processes"] = multiprocessing.cpu_count()
|
||||||
|
|
|
@ -42,6 +42,8 @@ def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
|
||||||
rv = base_executor_kwargs(test_type, server_config,
|
rv = base_executor_kwargs(test_type, server_config,
|
||||||
cache_manager, **kwargs)
|
cache_manager, **kwargs)
|
||||||
rv["pause_after_test"] = kwargs["pause_after_test"]
|
rv["pause_after_test"] = kwargs["pause_after_test"]
|
||||||
|
if test_type == "wdspec":
|
||||||
|
rv["capabilities"] = {}
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ from .base import (ExecutorException,
|
||||||
RefTestImplementation,
|
RefTestImplementation,
|
||||||
testharness_result_converter,
|
testharness_result_converter,
|
||||||
reftest_result_converter,
|
reftest_result_converter,
|
||||||
WdspecExecutor)
|
WdspecExecutor, WebDriverProtocol)
|
||||||
from .process import ProcessTestExecutor
|
from .process import ProcessTestExecutor
|
||||||
from ..browsers.base import browser_command
|
from ..browsers.base import browser_command
|
||||||
from ..wpttest import WdspecResult, WdspecSubtestResult
|
from ..wpttest import WdspecResult, WdspecSubtestResult
|
||||||
|
@ -286,82 +286,9 @@ class ServoRefTestExecutor(ProcessTestExecutor):
|
||||||
line,
|
line,
|
||||||
" ".join(self.command))
|
" ".join(self.command))
|
||||||
|
|
||||||
class ServoWdspecProtocol(Protocol):
|
|
||||||
def __init__(self, executor, browser):
|
|
||||||
self.do_delayed_imports()
|
|
||||||
Protocol.__init__(self, executor, browser)
|
|
||||||
self.session = None
|
|
||||||
self.server = None
|
|
||||||
|
|
||||||
def setup(self, runner):
|
|
||||||
try:
|
|
||||||
self.server = ServoDriverServer(self.logger, binary=self.browser.binary, binary_args=self.browser.binary_args)
|
|
||||||
self.server.start(block=False)
|
|
||||||
self.logger.info(
|
|
||||||
"WebDriver HTTP server listening at %s" % self.server.url)
|
|
||||||
|
|
||||||
self.logger.info(
|
|
||||||
"Establishing new WebDriver session with %s" % self.server.url)
|
|
||||||
self.session = webdriver.Session(
|
|
||||||
self.server.host, self.server.port, self.server.base_path)
|
|
||||||
except Exception:
|
|
||||||
self.logger.error(traceback.format_exc())
|
|
||||||
self.executor.runner.send_message("init_failed")
|
|
||||||
else:
|
|
||||||
self.executor.runner.send_message("init_succeeded")
|
|
||||||
|
|
||||||
def teardown(self):
|
|
||||||
if self.server is not None:
|
|
||||||
try:
|
|
||||||
if self.session.session_id is not None:
|
|
||||||
self.session.end()
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
if self.server.is_alive:
|
|
||||||
self.server.stop()
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_alive(self):
|
|
||||||
conn = httplib.HTTPConnection(self.server.host, self.server.port)
|
|
||||||
conn.request("HEAD", self.server.base_path + "invalid")
|
|
||||||
res = conn.getresponse()
|
|
||||||
return res.status == 404
|
|
||||||
|
|
||||||
def do_delayed_imports(self):
|
|
||||||
global pytestrunner, webdriver
|
|
||||||
from . import pytestrunner
|
|
||||||
import webdriver
|
|
||||||
|
|
||||||
|
class ServoDriverProtocol(WebDriverProtocol):
|
||||||
|
server_cls = ServoDriverServer
|
||||||
|
|
||||||
class ServoWdspecExecutor(WdspecExecutor):
|
class ServoWdspecExecutor(WdspecExecutor):
|
||||||
def __init__(self, browser, server_config,
|
protocol_cls = ServoDriverProtocol
|
||||||
timeout_multiplier=1, close_after_done=True, debug_info=None,
|
|
||||||
**kwargs):
|
|
||||||
WdspecExecutor.__init__(self, browser, server_config,
|
|
||||||
timeout_multiplier=timeout_multiplier,
|
|
||||||
debug_info=debug_info)
|
|
||||||
self.protocol = ServoWdspecProtocol(self, browser)
|
|
||||||
|
|
||||||
def is_alive(self):
|
|
||||||
return self.protocol.is_alive
|
|
||||||
|
|
||||||
def on_environment_change(self, new_environment):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def do_test(self, test):
|
|
||||||
timeout = test.timeout * self.timeout_multiplier + extra_timeout
|
|
||||||
|
|
||||||
success, data = WdspecRun(self.do_wdspec,
|
|
||||||
self.protocol.session,
|
|
||||||
test.path,
|
|
||||||
timeout).run()
|
|
||||||
|
|
||||||
if success:
|
|
||||||
return self.convert_result(test, data)
|
|
||||||
|
|
||||||
return (test.result_cls(*data), [])
|
|
||||||
|
|
||||||
def do_wdspec(self, session, path, timeout):
|
|
||||||
harness_result = ("OK", None)
|
|
||||||
subtest_results = pytestrunner.run(path, session, timeout=timeout)
|
|
||||||
return (harness_result, subtest_results)
|
|
||||||
|
|
|
@ -195,10 +195,11 @@ class GeckoDriverServer(WebDriverServer):
|
||||||
|
|
||||||
|
|
||||||
class ServoDriverServer(WebDriverServer):
|
class ServoDriverServer(WebDriverServer):
|
||||||
def __init__(self, logger, binary="servo", binary_args=None, host="127.0.0.1", port=None):
|
def __init__(self, logger, binary="servo", binary_args=None, host="127.0.0.1",
|
||||||
|
port=None, args=None):
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env["RUST_BACKTRACE"] = "1"
|
env["RUST_BACKTRACE"] = "1"
|
||||||
WebDriverServer.__init__(self, logger, binary, host=host, port=port, env=env)
|
WebDriverServer.__init__(self, logger, binary, host=host, port=port, env=env, args=args)
|
||||||
self.binary_args = binary_args
|
self.binary_args = binary_args
|
||||||
|
|
||||||
def make_command(self):
|
def make_command(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue