aboutsummaryrefslogtreecommitdiff
path: root/catapult/telemetry/telemetry/internal/results/story_run.py
blob: 078d0fcb5ef8c73cc5bc272acfa5b7b7cb79f1d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from telemetry.value import failure
from telemetry.value import skip


class StoryRun(object):
  def __init__(self, story):
    self._story = story
    self._values = []

  def AddValue(self, value):
    self._values.append(value)

  @property
  def story(self):
    return self._story

  @property
  def values(self):
    """The values that correspond to this story run."""
    return self._values

  @property
  def ok(self):
    """Whether the current run is still ok.

    To be precise: returns true if there is neither FailureValue nor
    SkipValue in self.values.
    """
    return not self.skipped and not self.failed

  @property
  def skipped(self):
    """Whether the current run is being skipped.

    To be precise: returns true if there is any SkipValue in self.values.
    """
    return any(isinstance(v, skip.SkipValue) for v in self.values)

  @property
  def failed(self):
    """Whether the current run failed.

    To be precise: returns true if there is a FailureValue but not
    SkipValue in self.values.
    """
    return not self.skipped and any(
        isinstance(v, failure.FailureValue) for v in self.values)