Skip to content

Commit

Permalink
topotato: fix skip cascading
Browse files Browse the repository at this point in the history
The logic wasn't quite right...

Signed-off-by: David Lamparter <[email protected]>
  • Loading branch information
eqvinox committed Sep 23, 2024
1 parent b96cfe2 commit e89e1da
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions topotato/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ class SkipMode(Enum):
failures in this test item cascade to later items.
"""

SkipThisAndLaterHard = 3
"""
As previous, but Skipping this item cascades as well.
"""


# false warning on get_closest_marker()
# pylint: disable=abstract-method
Expand Down Expand Up @@ -496,14 +501,18 @@ def __exit__(
) -> None:
if exc_value is None:
return
if isinstance(exc_value, Skipped):

if not isinstance(exc_value, (Exception, Failed, Skipped)):
return
if self._item.cascade_failures in [SkipMode.DontSkip, SkipMode.SkipThis]:
return
if not isinstance(exc_value, (Exception, Failed)):
if self._item.cascade_failures in [SkipMode.SkipThisAndLater] and isinstance(
exc_value, Skipped
):
return

if self._item.cascade_failures == SkipMode.SkipThisAndLater:
self._item.cls_node.skipall_node = self._item
self._item.cls_node.skipall = exc_value
self._item.cls_node.skipall_node = self._item
self._item.cls_node.skipall = exc_value


# false warning on get_closest_marker()
Expand All @@ -515,7 +524,7 @@ class InstanceStartup(TopotatoItem):
Includes starting tshark and checking all daemons are running.
"""

cascade_failures = SkipMode.SkipThisAndLater
cascade_failures = SkipMode.SkipThisAndLaterHard

commands: OrderedDict

Expand Down Expand Up @@ -563,6 +572,15 @@ def reportinfo(self):
fspath, _, _ = self.cls_node.reportinfo()
return fspath, float("inf"), "shutdown"

def setup(self):
# specifically skip shutdown only if startup failed
if isinstance(self.cls_node.skipall_node, InstanceStartup):
raise TopotatoEarlierFailSkip(
self.cls_node.skipall_node
) from self.cls_node.skipall

super().setup()

def __call__(self):
self.cls_node.do_stop(self)

Expand Down Expand Up @@ -834,6 +852,7 @@ class TopotatoClass(_pytest.python.Class):
def from_hook(cls, obj, collector, name):
self = super().from_parent(collector, name=name)
self._obj = obj
self.skipall_node = None
self.skipall = None

# TODO: automatically add a bunch of markers for test requirements.
Expand Down

0 comments on commit e89e1da

Please sign in to comment.