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

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

Issue 311193003: [telemetry] Cleanups for benchmarks importing page sets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
Index: tools/telemetry/telemetry/test.py
diff --git a/tools/telemetry/telemetry/test.py b/tools/telemetry/telemetry/test.py
index 4b8c1abeae0c7950a34643a20cd3757168f9479b..c686d4d85d2a4632021f5bdd3c7138a0f6b06439 100644
--- a/tools/telemetry/telemetry/test.py
+++ b/tools/telemetry/telemetry/test.py
@@ -37,14 +37,12 @@ class Test(command_line.Command):
name = cls.__module__.split('.')[-1]
if hasattr(cls, 'tag'):
name += '.' + cls.tag
- page_set_name = None
- if hasattr(cls, 'page_set') and isinstance(cls.page_set, page_set.PageSet):
- page_set_name = os.path.basename(
- os.path.splitext(cls.page_set.file_path)[0])
- elif hasattr(cls, 'page_set') and isinstance(cls.page_set, str):
- page_set_name = os.path.basename(os.path.splitext(cls.page_set)[0])
- if page_set_name:
- name += '.' + page_set_name
+ if hasattr(cls, 'page_set'):
+ 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
@@ -170,6 +168,18 @@ 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.
@@ -178,15 +188,12 @@ class Test(command_line.Command):
"""
if not hasattr(cls, 'page_set'):
raise NotImplementedError('This test has no "page_set" attribute.')
-
- if isinstance(cls.page_set, str):
+ if isinstance(cls.page_set, basestring):
+ # TODO(dtu): Remove this code path after crbug.com/362293.
return page_set.PageSet.FromFile(
file_path=os.path.join(util.GetBaseDir(), cls.page_set))
- elif isinstance(cls.page_set, page_set.PageSet):
- return cls.page_set
else:
- raise TypeError('The page_set field of %s has unsupported type.' %
- cls.Name)
+ return cls.PageSetClass()()
tonyg 2014/06/04 21:05:08 Really like initializing lazily :)
@classmethod
def CreateExpectations(cls, ps): # pylint: disable=W0613

Powered by Google App Engine
This is Rietveld 408576698