#!/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 chromium_config
from core import path_util

if __name__ == '__main__':
  project_config = chromium_config.ChromiumConfig()
  telemetry_dir = path_util.GetTelemetryDir()

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

  path_to_run_tests = os.path.join(
      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))
