blob: 6b2ff5242510fbc2bb2c677e8002fe8bbdd83f70 [file] [log] [blame]
#!/usr/bin/env python
# Copyright (c) 2015 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.
import argparse
import logging
import os
import subprocess
import sys
_THIS_PATH = os.path.dirname(__file__)
_RUN_PY_TESTS_PATH = os.path.join(_THIS_PATH, 'run_py_tests')
_RUN_VINN_TESTS_PATH = os.path.join(_THIS_PATH, 'run_vinn_tests')
_RUN_DEV_SERVER_TESTS_PATH = os.path.join(_THIS_PATH, 'run_dev_server_tests')
class bcolors(object):
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
def _RunPyTests():
command = [_RUN_PY_TESTS_PATH]
if sys.platform == 'win32':
command = ['python'] + command
return subprocess.call(command)
def _RunVinnTests():
if sys.platform == 'win32': # Vinn doesn't work on Windows yet.
return 0
return subprocess.call([_RUN_VINN_TESTS_PATH])
def _RunDevServerTests(chrome_command):
command = [_RUN_DEV_SERVER_TESTS_PATH]
if chrome_command:
command += ['--chrome_path', chrome_command]
if sys.platform == 'win32':
command = ['python'] + command
return subprocess.call(command)
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='Run all tests of tracing project.')
parser.add_argument('--chrome_path', type=str,
help='Path to Chrome browser binary.')
args = parser.parse_args()
run_py_tests_exit_code = _RunPyTests()
run_vinn_tests_exit_code = _RunVinnTests()
run_dev_server_exit_code = _RunDevServerTests(args.chrome_path)
exit_code = (run_py_tests_exit_code | run_dev_server_exit_code |
run_vinn_tests_exit_code)
if exit_code:
print (bcolors.FAIL +
'Oooops! Looks like some of your tests have failed.' +
bcolors.ENDC), u'\U0001F631'.encode('utf-8')
else:
print (bcolors.OKGREEN +
'Woho! All the tests have passed. You are awesome!' +
bcolors.ENDC), u'\U0001F601'.encode('utf-8')
if run_py_tests_exit_code:
sys.stderr.write(
'run_py_tests have some failed tests. Rerun run_py_tests script '
'to see those.\n')
if run_vinn_tests_exit_code:
sys.stderr.write(
'run_vinn_tests have some failed tests. Rerun run_vinn_tests script '
'to see those.\n')
if run_dev_server_exit_code:
sys.stderr.write(
'run_dev_server have some failed tests. Rerun run_dev_server_test script '
'and open the browser to see those.\n')
sys.exit(exit_code)