import os
import sys
+from telemetry import decorators
from telemetry import test
from telemetry.core import browser_options
from telemetry.core import command_line
from telemetry.core import discover
+from telemetry.core import environment
from telemetry.core import util
+from telemetry.page import page_set
from telemetry.page import page_test
from telemetry.page import profile_creator
from telemetry.util import find_dependencies
if not os.path.exists(page_set_path):
parser.error('Page set not found.')
if not (os.path.isfile(page_set_path) and
- os.path.splitext(page_set_path)[1] == '.json'):
- parser.error('Page set is not a JSON file.')
+ discover.IsPageSetFile(page_set_path)):
+ parser.error('Unsupported page set file format.')
class TestWrapper(test.Test):
test = test_class
- page_set = page_set_path
+
+ @classmethod
+ def CreatePageSet(cls, options):
+ return page_set.PageSet.FromFile(page_set_path)
+
test_class = TestWrapper
else:
if len(args.positional_args) > 1:
yield cls
+@decorators.Cache
def _Tests():
- base_dir = util.GetBaseDir()
- tests = discover.DiscoverClasses(base_dir, base_dir, test.Test,
- index_by_class_name=True).values()
- page_tests = discover.DiscoverClasses(base_dir, base_dir, page_test.PageTest,
- index_by_class_name=True).values()
- page_tests = [test_class for test_class in page_tests
- if not issubclass(test_class, profile_creator.ProfileCreator)]
- return tests + page_tests
+ tests = []
+ for base_dir in config.base_paths:
+ tests += discover.DiscoverClasses(base_dir, base_dir, test.Test,
+ index_by_class_name=True).values()
+ page_tests = discover.DiscoverClasses(base_dir, base_dir,
+ page_test.PageTest,
+ index_by_class_name=True).values()
+ tests += [test_class for test_class in page_tests
+ if not issubclass(test_class, profile_creator.ProfileCreator)]
+ return tests
def _MatchTestName(input_test_name, exact_matches=True):
# Exact matching.
if exact_matches:
# Don't add aliases to search dict, only allow exact matching for them.
- if input_test_name in test_aliases:
- exact_match = test_aliases[input_test_name]
+ if input_test_name in config.test_aliases:
+ exact_match = config.test_aliases[input_test_name]
else:
exact_match = input_test_name
print >> sys.stderr
-test_aliases = {}
+config = environment.Environment([util.GetBaseDir()])
-def Main():
+def main():
# Get the command name from the command line.
if len(sys.argv) > 1 and sys.argv[1] == '--help':
sys.argv[1] = 'help'