1# Copyright 2015 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5from telemetry.value import failure 6from telemetry.value import skip 7 8 9class StoryRun(object): 10 def __init__(self, story): 11 self._story = story 12 self._values = [] 13 14 def AddValue(self, value): 15 self._values.append(value) 16 17 @property 18 def story(self): 19 return self._story 20 21 @property 22 def values(self): 23 """The values that correspond to this story run.""" 24 return self._values 25 26 @property 27 def ok(self): 28 """Whether the current run is still ok. 29 30 To be precise: returns true if there is neither FailureValue nor 31 SkipValue in self.values. 32 """ 33 return not self.skipped and not self.failed 34 35 @property 36 def skipped(self): 37 """Whether the current run is being skipped. 38 39 To be precise: returns true if there is any SkipValue in self.values. 40 """ 41 return any(isinstance(v, skip.SkipValue) for v in self.values) 42 43 @property 44 def failed(self): 45 """Whether the current run failed. 46 47 To be precise: returns true if there is a FailureValue but not 48 SkipValue in self.values. 49 """ 50 return not self.skipped and any( 51 isinstance(v, failure.FailureValue) for v in self.values) 52