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

Unified Diff: tools/telemetry/telemetry/core/discover.py

Issue 180873008: Add support for python pageset (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove attributes from page constructor Created 6 years, 9 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/perf/page_sets/top_10.py ('k') | tools/telemetry/telemetry/core/discover_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/discover.py
diff --git a/tools/telemetry/telemetry/core/discover.py b/tools/telemetry/telemetry/core/discover.py
index 88f22bd8349fdb109653c83d78712d375b6f977b..78c33cdaa80f73f606ccc35c019d45edcc63d9f0 100644
--- a/tools/telemetry/telemetry/core/discover.py
+++ b/tools/telemetry/telemetry/core/discover.py
@@ -9,6 +9,7 @@ import re
from telemetry import decorators
from telemetry.core import camel_case
+from telemetry.core import util
@decorators.Cache
@@ -95,12 +96,31 @@ def DiscoverClasses(start_dir, top_level_dir, base_class, pattern='*',
return classes
+_counter = [0]
+def _GetUniqueModuleName():
+ _counter[0] += 1
+ return "module_" + str(_counter[0])
+
+def IsPageSetFile(file_path):
+ root_name, ext_name = os.path.splitext(file_path)
+ if ext_name == '.json':
+ return True
+ elif ext_name != '.py':
+ return False
+ if 'unittest' in root_name or root_name in ('PRESUBMIT', '__init__'):
+ return False
+ module = util.GetPythonPageSetModule(file_path)
+ for class_name in dir(module):
+ if class_name.endswith('PageSet') and class_name != 'PageSet':
+ return True
+ return False
+
def GetAllPageSetFilenames(dir_path):
results = []
start_dir = os.path.dirname(dir_path)
for dirpath, _, filenames in os.walk(start_dir):
for f in filenames:
- if os.path.splitext(f)[1] != '.json':
+ if not IsPageSetFile(filenames):
continue
filename = os.path.join(dirpath, f)
results.append(filename)
« no previous file with comments | « tools/perf/page_sets/top_10.py ('k') | tools/telemetry/telemetry/core/discover_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698