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

Unified Diff: tools/telemetry/telemetry/test.py

Issue 17438002: [telemetry] test_runner and run_benchmarks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update docs? Created 7 years, 6 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
« no previous file with comments | « tools/telemetry/telemetry/page/page_test_runner.py ('k') | tools/telemetry/telemetry/test_runner.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/test.py
diff --git a/tools/telemetry/telemetry/test.py b/tools/telemetry/telemetry/test.py
new file mode 100644
index 0000000000000000000000000000000000000000..f48a8823193c9c1cb83a2e4949fad32af8443575
--- /dev/null
+++ b/tools/telemetry/telemetry/test.py
@@ -0,0 +1,39 @@
+# 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.
+from telemetry.page import page_runner
+from telemetry.page import page_set
+from telemetry.page import page_test
+
+
+class Test(object):
+ """Base class for a Telemetry test or benchmark.
+
+ A test packages a PageTest/PageMeasurement and a PageSet together.
+ """
+ options = {}
+ enabled = True
+
+ def Run(self, options):
+ """Run this test with the given options."""
+ assert hasattr(self, 'test'), 'This test has no "test" attribute.'
+ assert issubclass(self.test, page_test.PageTest), (
+ '"%s" is not a PageTest.' % self.test.__name__)
+
+ for key, value in self.options.iteritems():
+ setattr(options, key, value)
+
+ test = self.test()
+ ps = self.CreatePageSet(options)
+ results = page_runner.Run(test, ps, options)
+ results.PrintSummary()
+ return len(results.failures) + len(results.errors)
+
+ def CreatePageSet(self, options): # pylint: disable=W0613
+ """Get the page set this test will run on.
+
+ By default, it will create a page set from the file at this test's
+ page_set attribute. Override to generate a custom page set.
+ """
+ assert hasattr(self, 'page_set'), 'This test has no "page_set" attribute.'
+ return page_set.PageSet.FromFile(self.page_set)
« no previous file with comments | « tools/telemetry/telemetry/page/page_test_runner.py ('k') | tools/telemetry/telemetry/test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698