Skip to content

Commit

Permalink
Merge pull request #165 from w3c/jgraham/restart_after
Browse files Browse the repository at this point in the history
Add restart-after option to expectation files to indicate that the browser must be restarted after a particular test.
  • Loading branch information
jgraham committed Apr 1, 2016
2 parents e292c9a + 1c64eb7 commit 15e752a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
4 changes: 4 additions & 0 deletions docs/expectation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ When used for expectation data, manifests have the following format:
the (sub)test is disabled and should either not be run (for tests)
or that its results should be ignored (subtests).

* A key ``restart-after`` which can be set to any value to indicate that
the runner should restart the browser after running this test (e.g. to
clear out unwanted state).

* Variables ``debug``, ``os``, ``version``, ``processor`` and
``bits`` that describe the configuration of the browser under
test. ``debug`` is a boolean indicating whether a build is a debug
Expand Down
24 changes: 18 additions & 6 deletions wptrunner/manifestexpected.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ def data_cls_getter(output_node, visited_node):
raise ValueError


def disabled(node):
"""Boolean indicating whether the test is disabled"""
def bool_prop(name, node):
"""Boolean property"""
try:
return node.get("disabled")
return node.get(name)
except KeyError:
return None

Expand Down Expand Up @@ -109,7 +109,11 @@ def url(self):

@property
def disabled(self):
return disabled(self)
return bool_prop("disabled", self)

@property
def restart_after(self):
return bool_prop("restart-after", self)

@property
def tags(self):
Expand All @@ -123,7 +127,11 @@ def prefs(self):
class DirectoryManifest(ManifestItem):
@property
def disabled(self):
return disabled(self)
return bool_prop("disabled", self)

@property
def restart_after(self):
return bool_prop("restart-after", self)

@property
def tags(self):
Expand Down Expand Up @@ -164,7 +172,11 @@ def id(self):

@property
def disabled(self):
return disabled(self)
return bool_prop("disabled", self)

@property
def restart_after(self):
return bool_prop("restart-after", self)

@property
def tags(self):
Expand Down
3 changes: 2 additions & 1 deletion wptrunner/testrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,8 @@ def test_ended(self, test, results):

self.test = None

restart_before_next = (file_result.status in ("CRASH", "EXTERNAL-TIMEOUT") or
restart_before_next = (test.restart_after or
file_result.status in ("CRASH", "EXTERNAL-TIMEOUT") or
subtest_unexpected or is_unexpected)

if (self.pause_after_test or
Expand Down
8 changes: 8 additions & 0 deletions wptrunner/wpttest.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ def disabled(self, subtest=None):
return disabled
return None

@property
def restart_after(self):
for meta in self.itermeta(None):
restart_after = meta.restart_after
if restart_after is not None:
return True
return False

@property
def tags(self):
tags = set()
Expand Down

0 comments on commit 15e752a

Please sign in to comment.