#!/usr/bin/env python
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""This script runs unit tests of the code in the perf directory.

This script DOES NOT run benchmarks. run_benchmark does that.
"""

import os
import subprocess
import sys

from core import project_config as project_config_module

if __name__ == '__main__':
  project_config = project_config_module.config

  env = os.environ.copy()
  if 'PYTHONPATH' in env:
    env['PYTHONPATH'] = os.path.join(env['PYTHONPATH'],
                                     project_config.telemetry_dir)
  else:
    env['PYTHONPATH'] = project_config.telemetry_dir

  path_to_run_tests = os.path.join(
      project_config.telemetry_dir, 'telemetry', 'testing', 'run_tests.py')
  argv = ['--top-level-dir', project_config.top_level_dir,
          '--client-config', project_config.client_config] + sys.argv[1:]
  sys.exit(subprocess.call([sys.executable, path_to_run_tests] + argv, env=env))
