| Index: telemetry/telemetry/story/expectations.py
|
| diff --git a/telemetry/telemetry/story/expectations.py b/telemetry/telemetry/story/expectations.py
|
| index 3626f143397a52805c110585ac06744fe292d6e0..1bf43c2cd3d1ca3086091675a1455c923e06d332 100644
|
| --- a/telemetry/telemetry/story/expectations.py
|
| +++ b/telemetry/telemetry/story/expectations.py
|
| @@ -18,7 +18,8 @@ class StoryExpectations(object):
|
| ...
|
| """
|
| def __init__(self):
|
| - self._disabled_platforms = []
|
| + self._permanently_disabled_platforms = []
|
| + self._temporarily_disabled_platforms = []
|
| self._expectations = {}
|
| self._frozen = False
|
| self.SetExpectations()
|
| @@ -42,6 +43,28 @@ class StoryExpectations(object):
|
| def _Freeze(self):
|
| self._frozen = True
|
|
|
| + def TemporarilyDisableBenchmark(self, conditions, reason):
|
| + """Temporarily Disable benchmark under the given conditions.
|
| +
|
| + This means that if --also-run-disabled-tests is passed, the benchmark will
|
| + run.
|
| +
|
| + Example:
|
| + TemporarilyDisableBenchmark(
|
| + [expectations.ALL_MOBILE], 'crbug.com/123')
|
| +
|
| + Args:
|
| + conditions: List of _TestCondition subclasses.
|
| + reason: Reason for disabling the benchmark.
|
| + """
|
| + assert reason, 'A reason for disabling must be given.'
|
| + assert not self._frozen, ('Cannot disable benchmark on a frozen '
|
| + 'StoryExpectation object.')
|
| + for condition in conditions:
|
| + assert isinstance(condition, _TestCondition)
|
| +
|
| + self._temporarily_disabled_platforms.append((conditions, reason))
|
| +
|
| def PermanentlyDisableBenchmark(self, conditions, reason):
|
| """Permanently Disable benchmark under the given conditions.
|
|
|
| @@ -64,15 +87,29 @@ class StoryExpectations(object):
|
| for condition in conditions:
|
| assert isinstance(condition, _TestCondition)
|
|
|
| - self._disabled_platforms.append((conditions, reason))
|
| + self._permanently_disabled_platforms.append((conditions, reason))
|
| +
|
| + def IsBenchmarkTemporarilyDisabled(self, platform, finder_options):
|
| + """Returns reason benchmark is disabled, or None if not disabled.
|
| +
|
| + Args:
|
| + platform: A platform object.
|
| + """
|
| + for conditions, reason in self._temporarily_disabled_platforms:
|
| + for condition in conditions:
|
| + if condition.ShouldDisable(platform, finder_options):
|
| + logging.info('Benchmark permanently disabled on %s due to %s.',
|
| + condition, reason)
|
| + return reason
|
| + return None
|
|
|
| - def IsBenchmarkDisabled(self, platform, finder_options):
|
| - """Returns the reason the benchmark was disabled, or None if not disabled.
|
| + def IsBenchmarkPermanentlyDisabled(self, platform, finder_options):
|
| + """Returns reason benchmark is permanently disabled, or None if not disabled
|
|
|
| Args:
|
| platform: A platform object.
|
| """
|
| - for conditions, reason in self._disabled_platforms:
|
| + for conditions, reason in self._permanently_disabled_platforms:
|
| for condition in conditions:
|
| if condition.ShouldDisable(platform, finder_options):
|
| logging.info('Benchmark permanently disabled on %s due to %s.',
|
|
|