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

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

Issue 274773002: [telemetry] Prototype for specifying page sets using Python imports and Telemetry discovery. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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/record_wpr.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
index 5f52affb9910e1c747bd5dc1b0d84e502f9fc860..10dc5cd47a58f8c7f0233ce6f9865d92bfd450c2 100644
--- a/tools/telemetry/telemetry/test.py
+++ b/tools/telemetry/telemetry/test.py
@@ -38,7 +38,11 @@ class Test(command_line.Command):
if hasattr(cls, 'tag'):
name += '.' + cls.tag
if hasattr(cls, 'page_set'):
- name += '.' + os.path.basename(os.path.splitext(cls.page_set)[0])
+ if isinstance(cls.page_set, basestring):
+ # TODO(dtu): Remove this code path after crbug.com/362293.
+ name += '.' + os.path.basename(os.path.splitext(cls.page_set)[0])
+ else:
+ name += '.' + cls.page_set.Name()
return name
@classmethod
@@ -164,16 +168,25 @@ class Test(command_line.Command):
return cls.test
@classmethod
+ def PageSetClass(cls):
+ """Get the PageSet for this Test.
+
+ If the Test has no PageSet, raises NotImplementedError.
+ """
+ if not hasattr(cls, 'page_set'):
+ raise NotImplementedError('This test has no "page_set" attribute.')
+ if not issubclass(cls.page_set, page_set.PageSet):
+ raise TypeError('"%s" is not a PageSet.' % cls.page_set.__name__)
+ return cls.page_set
+
+ @classmethod
def CreatePageSet(cls, 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.
"""
- if not hasattr(cls, 'page_set'):
- raise NotImplementedError('This test has no "page_set" attribute.')
- return page_set.PageSet.FromFile(
- file_path=os.path.join(util.GetBaseDir(), cls.page_set))
+ return cls.PageSetClass()()
@classmethod
def CreateExpectations(cls, ps): # pylint: disable=W0613
« no previous file with comments | « tools/telemetry/telemetry/page/record_wpr.py ('k') | tools/telemetry/telemetry/test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698