def main():
  """CLI frontend to validate arguments."""
  run_test_cases.run_isolated.disable_buffering()
  parser = run_test_cases.OptionParserWithTestShardingAndFiltering(
      usage='%prog <options> [gtest]')
  options, args = parser.parse_args()
  if not args:
    parser.error('Please provide the executable to run')

  cmd = run_test_cases.fix_python_path(args)
  try:
    tests = run_test_cases.list_test_cases(
        cmd,
        os.getcwd(),
        index=options.index,
        shards=options.shards,
        disabled=options.disabled,
        fails=options.fails,
        flaky=options.flaky,
        pre=False,
        manual=options.manual,
        seed=0)
    for test in tests:
      print test
  except run_test_cases.Failure, e:
    print e.args[0]
    return e.args[1]
Beispiel #2
0
def main():
  """CLI frontend to validate arguments."""
  parser = run_test_cases.OptionParserWithTestSharding(
      usage='%prog <options> [gtest]')
  parser.add_option(
      '-d', '--disabled',
      action='store_true',
      help='Include DISABLED_ tests')
  parser.add_option(
      '-f', '--fails',
      action='store_true',
      help='Include FAILS_ tests')
  parser.add_option(
      '-F', '--flaky',
      action='store_true',
      help='Include FLAKY_ tests')
  options, args = parser.parse_args()
  if not args:
    parser.error('Please provide the executable to run')

  cmd = run_test_cases.fix_python_path(args)
  try:
    tests = run_test_cases.list_test_cases(
        cmd,
        options.index,
        options.shards,
        options.disabled,
        options.fails,
        options.flaky)
    for test in tests:
      print test
  except run_test_cases.Failure, e:
    print e.args[0]
    return e.args[1]
Beispiel #3
0
def main():
  """CLI frontend to validate arguments."""
  parser = optparse.OptionParser(
      usage='%prog <options> [gtest]')
  parser.add_option(
      '-d', '--disabled',
      action='store_true',
      help='Include DISABLED_ tests')
  parser.add_option(
      '-f', '--fails',
      action='store_true',
      help='Include FAILS_ tests')
  parser.add_option(
      '-F', '--flaky',
      action='store_true',
      help='Include FLAKY_ tests')
  parser.add_option(
      '-i', '--index',
      type='int',
      help='Shard index to run')
  parser.add_option(
      '-s', '--shards',
      type='int',
      help='Total number of shards to calculate from the --index to run')
  options, args = parser.parse_args()
  if len(args) != 1:
    parser.error('Please provide the executable to run')

  if bool(options.shards) != bool(options.index is not None):
    parser.error('Use both --index X --shards Y or none of them')

  try:
    tests = run_test_cases.list_test_cases(
        args[0],
        options.index,
        options.shards,
        options.disabled,
        options.fails,
        options.flaky)
    for test in tests:
      print test
  except run_test_cases.Failure, e:
    print e.args[0]
    return e.args[1]
Beispiel #4
0
def run_all(result, executable):
  """Runs all the test cases in a gtest executable and trace the failing tests.

  Then make sure the test passes afterward.
  """
  test_cases = run_test_cases.list_test_cases(
      executable, 0, 0, False, False, False)
  print 'Found %d test cases.' % len(test_cases)
  failures = []
  fixed_tests = []
  try:
    for index, test_case in enumerate(test_cases):
      if get_keyboard():
        # Return early.
        return True

      try:
        if run(result, test_case):
          continue

        if not trace_and_verify(result, test_case):
          failures.append(test_case)
          print 'Failed to fix %s' % test_case
        else:
          fixed_tests.append(test_case)
      except:  # pylint: disable=W0702
        failures.append(test_case)
        print 'Failed to fix %s' % test_case
      print '%d/%d' % (index+1, len(test_cases))
  finally:
    print 'Test cases fixed (%d):' % len(fixed_tests)
    for fixed_test in fixed_tests:
      print '  %s' % fixed_test
    print ''

    print 'Test cases still failing (%d):' % len(failures)
    for failure in failures:
      print '  %s' % failure
  return not failures