Skip to content

Commit

Permalink
Support expectations have more nested expectations that can match.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitali Lovich committed Jul 28, 2015
1 parent 8a20f8f commit 83e66ff
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions master/buildbot/test/fake/remotecommand.py
Expand Up @@ -279,6 +279,12 @@ def shouldKeepMatchingAfter(self, command):
"""
return False

def nestedExpectations(self):
"""
Any sub-expectations that should be validated.
"""
return []

def __repr__(self):
return "Expect(" + repr(self.remote_command) + ")"

Expand Down
12 changes: 12 additions & 0 deletions master/buildbot/test/util/steps.py
Expand Up @@ -322,6 +322,18 @@ def check(result):
def _validate_expectation(self, exp, command):
got = (command.remote_command, command.args)

for child_exp in exp.nestedExpectations():
try:
yield self._validate_expectation(child_exp, command)
exp.expectationPassed(exp)
except AssertionError as e:
# log this error, as the step may swallow the AssertionError or
# otherwise obscure the failure. Trial will see the exception in
# the log and print an [ERROR]. This may result in
# double-reporting, but that's better than non-reporting!
log.err()
exp.raiseExpectationFailure(child_exp, e)

if exp.shouldAssertCommandEqualExpectation():
# handle any incomparable args
for arg in exp.incomparable_args:
Expand Down

0 comments on commit 83e66ff

Please sign in to comment.