1# Copyright 2015 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import os 6import subprocess 7import sys 8 9from telemetry.core import util 10 11 12def Run(project_config, no_browser=False): 13 args = sys.argv[1:] 14 assert '--top-level-dir' not in args, ( 15 'Top level directory for running tests should be specified through ' 16 'the instance of telemetry.project_config.ProjectConfig.') 17 assert '--client-config' not in args, ( 18 'Client config file to be used for telemetry should be specified through ' 19 'the instance of telemetry.project_config.ProjectConfig.') 20 assert project_config.top_level_dir, 'Must specify top level dir for project' 21 args.extend(['--top-level-dir', project_config.top_level_dir]) 22 if project_config.client_config: 23 args.extend(['--client-config', project_config.client_config]) 24 if no_browser and not '--no-browser' in args: 25 args.extend(['--no-browser']) 26 27 if project_config.default_chrome_root and not '--chrome-root' in args: 28 args.extend(['--chrome-root', project_config.default_chrome_root]) 29 30 env = os.environ.copy() 31 telemetry_dir = util.GetTelemetryDir() 32 if 'PYTHONPATH' in env: 33 env['PYTHONPATH'] = os.pathsep.join([env['PYTHONPATH'], telemetry_dir]) 34 else: 35 env['PYTHONPATH'] = telemetry_dir 36 37 path_to_run_tests = os.path.join(os.path.abspath(os.path.dirname(__file__)), 38 'run_tests.py') 39 return subprocess.call([sys.executable, path_to_run_tests] + args, env=env) 40