#!/usr/bin/python

"""Runs the unit test suite for perf dashboard."""

import argparse
import dev_appserver
import os
import sys
import unittest

_DASHBOARD_PARENT = os.path.join(os.path.dirname(__file__))
_DASHBOARD = os.path.join(_DASHBOARD_PARENT, 'dashboard')


def _GetTests(args):
  loader = unittest.TestLoader()
  if args.tests:
    return loader.loadTestsFromNames(args.tests)
  return loader.discover(_DASHBOARD, pattern='*_test.py')


def _FixPath():
  dev_appserver.fix_sys_path()
  sys.path.append(os.path.dirname(__file__))
  # The __init__.py in the dashboard package should add third party
  # libraries to the path.
  import dashboard  # pylint: disable=unused-variable


def main():
  _FixPath()
  parser = argparse.ArgumentParser(description='Run the test suite.')
  parser.add_argument(
      'tests', nargs='*', help='Fully-qualified names of tests to run.')
  args = parser.parse_args()
  runner = unittest.TextTestRunner(verbosity=1)
  result = runner.run(_GetTests(args))
  if result.wasSuccessful():
    sys.exit(0)
  else:
    sys.exit(1)


if __name__ == '__main__':
  main()

#!/usr/bin/python

"""Runs the unit test suite for perf dashboard."""

import argparse
import dev_appserver
import logging
import os
import sys
import unittest

_DASHBOARD_PARENT = os.path.join(os.path.dirname(__file__))
_DASHBOARD = os.path.join(_DASHBOARD_PARENT, 'dashboard')


def _GetTests(args):
  loader = unittest.TestLoader()
  if args.tests:
    return loader.loadTestsFromNames(args.tests)
  return loader.discover(_DASHBOARD, pattern='*_test.py')


def _FixPath():
  dev_appserver.fix_sys_path()
  sys.path.append(os.path.dirname(__file__))
  # The __init__.py in the dashboard package should add third party
  # libraries to the path.
  import dashboard  # pylint: disable=unused-variable


def main():
  _FixPath()
  parser = argparse.ArgumentParser(description='Run the test suite.')
  parser.add_argument(
      'tests', nargs='*', help='Fully-qualified names of tests to run.')
  args = parser.parse_args()
  runner = unittest.TextTestRunner(verbosity=1)
  logging.basicConfig(level=logging.CRITICAL)
  result = runner.run(_GetTests(args))
  if result.wasSuccessful():
    sys.exit(0)
  else:
    sys.exit(1)


if __name__ == '__main__':
  main()

Stop printing logs while running dashboard tests in catapult.
Stop printing logs while running dashboard tests in catapult.

Some of the dashboard tests invoke functions which log errors,
but these are not interesting or indicative of actual errors when
running the test.

By setting the logging level in run_tests.py, this makes it so
no log messages are printed when run_tests.py is run, so the
output is a bit cleaner.

Review URL: https://codereview.chromium.org/1180363002
