<commit_before>#!/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)
  runner.run(_GetTests(args))


if __name__ == '__main__':
  main()<commit_msg>Turn perf dashboard tests step red on failure<commit_after>#!/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()
{'fraction_non_alphanumeric': 0.11934900542495479, 'fraction_numerical': 0.0018083182640144665, 'mean_word_length': 4.793193717277487, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1839475', 'n_tokens_mistral': 760, 'n_tokens_neox': 738, 'n_words': 178}