Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make wdspec tests runnable #19318

Merged
merged 4 commits into from Nov 21, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Use most recent webdriver test harness.

  • Loading branch information
jdm committed Nov 20, 2017
commit 8761f53391b5bc79427ec1d5f099571c47c059e9
@@ -65,6 +65,7 @@ def set_defaults(paths, kwargs):
bin_path = servo_path("target", bin_dir, bin_name)

kwargs["binary"] = bin_path
kwargs["webdriver_binary"] = bin_path

if kwargs["processes"] is None:
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,
cache_manager, **kwargs)
rv["pause_after_test"] = kwargs["pause_after_test"]
if test_type == "wdspec":
rv["capabilities"] = {}
return rv


@@ -18,7 +18,7 @@
RefTestImplementation,
testharness_result_converter,
reftest_result_converter,
WdspecExecutor)
WdspecExecutor, WebDriverProtocol)
from .process import ProcessTestExecutor
from ..browsers.base import browser_command
from ..wpttest import WdspecResult, WdspecSubtestResult
@@ -286,82 +286,9 @@ def on_output(self, line):
line,
" ".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):
def __init__(self, browser, server_config,
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)
protocol_cls = ServoDriverProtocol
@@ -195,10 +195,11 @@ def make_command(self):


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["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

def make_command(self):
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.