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

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

Issue 18576004: [telemetry] Add @RunOnBuildMastersNamed support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: redo 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
« tools/perf/benchmarks/netsim_top25.py ('K') | « tools/telemetry/telemetry/test.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/test_runner.py
diff --git a/tools/telemetry/telemetry/test_runner.py b/tools/telemetry/telemetry/test_runner.py
index ec2ff7ed9616316510e7336f4a4c852482ccf616..70369ff7c112d441ad534a3c821c837761a4111d 100644
--- a/tools/telemetry/telemetry/test_runner.py
+++ b/tools/telemetry/telemetry/test_runner.py
@@ -15,6 +15,7 @@ import os
import sys
from telemetry import test
+from telemetry import bot_properties
from telemetry.core import browser_options
from telemetry.core import discover
@@ -47,38 +48,68 @@ class Help(Command):
"""Display help information"""
def Run(self, options, args):
- print >> sys.stderr, ('usage: %s <command> [<args>]' % _GetScriptName())
- print >> sys.stderr, 'Available commands are:'
+ print ('usage: %s <command> [<args>]' % _GetScriptName())
+ print 'Available commands are:'
for command in COMMANDS:
- print >> sys.stderr, ' %-10s %s' % (command.name, command.description)
+ print ' %-10s %s' % (command.name, command.description)
return 0
+def GetShortDescriptionOf(thing):
+ if not thing.__doc__:
+ return None
+ return thing.__doc__.splitlines()[0]
+
+
+def AddBotPropertiesOption(parser):
+ parser.add_option(
+ '--bot-properties',
+ help='JSON-formatted properties for the bot on which this test is ' +
+ 'running. Used in conjunction with test.CanRunOnBot() to customize ' +
+ 'where a given test will run.')
+
+
+def ValidateBotPropertiesOption(parser, options):
+ if not options.bot_properties:
+ options.bot_properties = bot_properties.BotProperties()
+ return
+ try:
+ options.bot_properties = bot_properties.BotProperties.FromJSON(
+ options.bot_properties)
+ except ValueError:
+ parser.error('--bot-properties must be valid JSON')
+
+
class List(Command):
"""Lists the available tests"""
def AddParserOptions(self, parser):
parser.add_option('-j', '--json', action='store_true')
+ AddBotPropertiesOption(parser)
+
+ def ValidateCommandLine(self, parser, options, args):
+ ValidateBotPropertiesOption(parser, options)
def Run(self, options, args):
+ test_list = []
bulach 2013/07/09 10:07:32 so this would be the only place to do something li
+ for test_name, test_class in sorted(_GetTests().items()):
+ if not test_class.CanRunOnBot(options.bot_properties):
+ continue
+ test_list.append({
+ 'name': test_name,
+ 'description': GetShortDescriptionOf(test_class),
+ 'options': test_class.options,
+ })
+
if options.json:
- test_list = []
- for test_name, test_class in sorted(_GetTests().items()):
- test_list.append({
- 'name': test_name,
- 'description': test_class.__doc__,
- 'enabled': test_class.enabled,
- 'options': test_class.options,
- })
- print >> sys.stderr, json.dumps(test_list)
+ print json.dumps(test_list)
else:
- print >> sys.stderr, 'Available tests are:'
- for test_name, test_class in sorted(_GetTests().items()):
- if test_class.__doc__:
- print >> sys.stderr, ' %-20s %s' % (test_name,
- test_class.__doc__.splitlines()[0])
+ print'Available tests are:'
+ for t in test_list:
+ if t['description']:
+ print ' %-20s %s' % (t['name'], t['description'])
else:
- print >> sys.stderr, ' %-20s' % test_name
+ print ' %-20s' % t['name']
return 0
@@ -90,14 +121,19 @@ class Run(Command):
def CreateParser(self):
options = browser_options.BrowserOptions()
parser = options.CreateParser('%%prog %s %s' % (self.name, self.usage))
+ AddBotPropertiesOption(parser)
return parser
def ValidateCommandLine(self, parser, options, args):
if not args:
parser.error('Must provide at least one test name')
for test_name in args:
- if test_name not in _GetTests():
+ t = _GetTests().get(test_name, None)
+ if not t:
parser.error('No test named "%s"' % test_name)
+ if not t.CanRun(options):
+ parser.error('Test "%s" can not run with these options.' % test_name)
+ ValidateBotPropertiesOption(parser, options)
def Run(self, options, args):
total_failures = 0
« tools/perf/benchmarks/netsim_top25.py ('K') | « tools/telemetry/telemetry/test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698