Skip to content

Commit

Permalink
Merge pull request #116 from w3c/jgraham/servo_fixups
Browse files Browse the repository at this point in the history
Small improvements for servodriver executor
  • Loading branch information
jgraham committed May 26, 2015
2 parents ee3d537 + e70257f commit b5afb22
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
44 changes: 29 additions & 15 deletions wptrunner/executors/executorservodriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def wait(self):


class ServoWebDriverRun(object):
def __init__(self, func, session, url, timeout):
def __init__(self, func, session, url, timeout, current_timeout=None):
self.func = func
self.result = None
self.session = session
Expand All @@ -93,18 +93,10 @@ def __init__(self, func, session, url, timeout):
self.result_flag = threading.Event()

def run(self):
timeout = self.timeout

try:
self.session.timeouts.script = timeout + extra_timeout
except IOError:
self.logger.error("Lost webdriver connection")
return Stop

executor = threading.Thread(target=self._run)
executor.start()

flag = self.result_flag.wait(timeout + 2 * extra_timeout)
flag = self.result_flag.wait(self.timeout + extra_timeout)
if self.result is None:
assert not flag
self.result = False, ("EXTERNAL-TIMEOUT", None)
Expand Down Expand Up @@ -144,6 +136,7 @@ def __init__(self, browser, server_config, timeout_multiplier=1,
self.protocol = ServoWebDriverProtocol(self, browser, capabilities=capabilities)
with open(os.path.join(here, "testharness_servodriver.js")) as f:
self.script = f.read()
self.timeout = None

def on_protocol_change(self, new_protocol):
pass
Expand All @@ -154,10 +147,20 @@ def is_alive(self):
def do_test(self, test):
url = self.test_url(test)

timeout = test.timeout * self.timeout_multiplier + extra_timeout

if timeout != self.timeout:
try:
self.protocol.session.timeouts.script = timeout
self.timeout = timeout
except IOError:
self.logger.error("Lost webdriver connection")
return Stop

success, data = ServoWebDriverRun(self.do_testharness,
self.protocol.session,
url,
test.timeout * self.timeout_multiplier).run()
timeout).run()

if success:
return self.convert_result(test, data)
Expand All @@ -172,8 +175,9 @@ def do_testharness(self, session, url, timeout):
"url": strip_server(url),
"timeout_multiplier": self.timeout_multiplier,
"timeout": timeout * 1000}))
if "test" not in result:
result["test"] = strip_server(url)
# Prevent leaking every page in history until Servo develops a more sane
# page cache
session.back()
return result


Expand All @@ -194,7 +198,7 @@ def __init__(self, browser, server_config, timeout_multiplier=1,
self.protocol = ServoWebDriverProtocol(self, browser,
capabilities=capabilities)
self.implementation = RefTestImplementation(self)

self.timeout = None
with open(os.path.join(here, "reftest-wait_servodriver.js")) as f:
self.wait_script = f.read()

Expand All @@ -217,7 +221,17 @@ def do_test(self, test):
return test.result_cls("ERROR", message), []

def screenshot(self, test):
timeout = test.timeout * self.timeout_multiplier if self.debug_info is None else None
timeout = (test.timeout * self.timeout_multiplier + extra_timeout
if self.debug_info is None else None)

if self.timeout != timeout:
try:
self.protocol.session.timeouts.script = timeout
self.timeout = timeout
except IOError:
self.logger.error("Lost webdriver connection")
return Stop

return ServoWebDriverRun(self._screenshot,
self.protocol.session,
self.test_url(test),
Expand Down
2 changes: 1 addition & 1 deletion wptrunner/executors/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def switch_frame(self, frame):
body = {"id": frame.json()}
else:
body = {"id": frame}
print body

return self.send_command("POST", url, body)

@command
Expand Down
4 changes: 3 additions & 1 deletion wptrunner/testharnessreport-servodriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ add_completion_callback(function() {
var test_results = tests.map(function(x) {
return {name:x.name, status:x.status, message:x.message, stack:x.stack}
});
var results = JSON.stringify({tests:test_results,
var id = location.pathname + location.search + location.hash;
var results = JSON.stringify({test: id,
tests:test_results,
status: status.status,
message: status.message,
stack: status.stack});
Expand Down

0 comments on commit b5afb22

Please sign in to comment.