From 83e66ffb6dc98bebece854e8bb89417a406b7873 Mon Sep 17 00:00:00 2001 From: Vitali Lovich Date: Sat, 6 Jun 2015 19:30:33 -0700 Subject: [PATCH] Support expectations have more nested expectations that can match. --- master/buildbot/test/fake/remotecommand.py | 6 ++++++ master/buildbot/test/util/steps.py | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/master/buildbot/test/fake/remotecommand.py b/master/buildbot/test/fake/remotecommand.py index 6779ba31550..0637682aada 100644 --- a/master/buildbot/test/fake/remotecommand.py +++ b/master/buildbot/test/fake/remotecommand.py @@ -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) + ")" diff --git a/master/buildbot/test/util/steps.py b/master/buildbot/test/util/steps.py index 9364de9ff61..33b4da52c68 100644 --- a/master/buildbot/test/util/steps.py +++ b/master/buildbot/test/util/steps.py @@ -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: