Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: tools/telemetry/telemetry/page/test_expectations.py

Issue 16158006: Defining the test expectations object (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/page/test_expectations.py
diff --git a/tools/telemetry/telemetry/page/test_expectations.py b/tools/telemetry/telemetry/page/test_expectations.py
new file mode 100644
index 0000000000000000000000000000000000000000..d2ecb7e39f7d8f4d2be476f56cb8cd3ad85d1050
--- /dev/null
+++ b/tools/telemetry/telemetry/page/test_expectations.py
@@ -0,0 +1,72 @@
+# Copyright (c) 2013 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.
+
+import fnmatch
+
+OS_MODIFIERS = ['win', 'xp', 'vista', 'win7',
+ 'mac', 'leopard', 'snowleopard', 'lion', 'mountainlion',
+ 'linux', 'chromeos']
+GPU_MODIFIERS = ['nvidia', 'amd', 'intel']
+CONFIG_MODIFIERS = ['debug', 'release']
+
+class Expectation(object):
+ def __init__(self, expectation, url_pattern, conditions=None, bug=None):
+ self.expectation = expectation.lower()
+ self.url_pattern = url_pattern
+ self.bug = bug
+
+ self.os_conditions = []
+ self.gpu_conditions = []
+ self.config_conditions = []
+
+ # Make sure that non-absolute paths are searchable
+ if not '://' in self.url_pattern:
+ self.url_pattern = '*/' + self.url_pattern
+
+ if conditions:
+ for c in conditions:
+ condition = c.lower()
+ if condition in OS_MODIFIERS:
+ self.os_conditions.append(condition)
+ elif condition in GPU_MODIFIERS:
+ self.gpu_conditions.append(condition)
+ elif condition in CONFIG_MODIFIERS:
+ self.config_conditions.append(condition)
+ else:
+ raise ValueError('Unknown expectation condition: "%s"' % condition)
+
+class TestExpectations(object):
+ """A class which defines the expectations for a page set test execution"""
+
+ def __init__(self):
+ self.expectations = []
+ self.SetExpectations()
+
+ def SetExpectations(self):
+ """Called on creation. Override to set up custom expectations."""
+ pass
+
+ def Fail(self, url_pattern, conditions=None, bug=None):
+ self._Expect('fail', url_pattern, conditions, bug)
+
+ def _Expect(self, expectation, url_pattern, conditions=None, bug=None):
+ self.expectations.append(Expectation(expectation, url_pattern, conditions,
+ bug))
+
+ def GetExpectationForPage(self, platform, page):
+ for e in self.expectations:
+ if fnmatch.fnmatch(page.url, e.url_pattern):
+ if self._ModifiersApply(platform, e):
+ return e.expectation
+ return 'pass'
+
+ def _ModifiersApply(self, platform, expectation):
+ """Determines if the conditions for an expectation apply to this system."""
+ os_matches = (not expectation.os_conditions or
+ platform.GetOSName() in expectation.os_conditions or
+ platform.GetOSVersionName() in expectation.os_conditions)
+
+ # TODO: Add checks against other modifiers (GPU, configuration, etc.)
+
+ return os_matches
« no previous file with comments | « tools/telemetry/telemetry/page/record_wpr.py ('k') | tools/telemetry/telemetry/page/test_expectations_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698