
from sharding_supervisor_old import *  # pylint: disable=W0401,W0614


if __name__ == "__main__":
  sys.exit(main())


"""Defer to run_test_cases.py."""

import os
import optparse
import sys

ROOT_DIR = os.path.dirname(
    os.path.dirname(os.path.dirname(os.path.abspath(__file__))))


def pop_gtest_output(args):
  """Extracts --gtest_output from the args if present."""
  for index, arg in enumerate(args):
    if arg.startswith('--gtest_output='):
      return args.pop(index)


def main():
  parser = optparse.OptionParser()

  group = optparse.OptionGroup(
      parser, 'Compability flag with the old sharding_supervisor')
  group.add_option(
      '--no-color', action='store_true', help='Ignored')
  group.add_option(
      '--retry-failed', action='store_true', help='Ignored')
  group.add_option(
      '-t', '--timeout', type='int', help='Kept as --timeout')
  group.add_option(
      '--total-slaves', type='int', default=1, help='Converted to --index')
  group.add_option(
      '--slave-index', type='int', default=0, help='Converted to --shards')
  parser.add_option_group(group)

  parser.disable_interspersed_args()
  options, args = parser.parse_args()

  swarm_client_dir = os.path.join(ROOT_DIR, 'tools', 'swarm_client')
  sys.path.insert(0, swarm_client_dir)

  cmd = [
    '--shards', str(options.total_slaves),
    '--index', str(options.slave_index),
    '--no-dump',
    '--no-cr',
  ]
  if options.timeout is not None:
    cmd.extend(['--timeout', str(options.timeout)])
  gtest_output = pop_gtest_output(args)
  if gtest_output:
    # It is important that --gtest_output appears before the '--' so it is
    # properly processed by run_test_cases.
    cmd.append(gtest_output)

  import run_test_cases  # pylint: disable=F0401

  return run_test_cases.main(cmd + ['--'] + args)


if __name__ == '__main__':
  sys.exit(main())

Switch over to run_test_cases.py, take 2.
Switch over to run_test_cases.py, take 2.

Instead of doing a "Revert r168479 'Revert r168478'", it's using a simpler version based on renaming sharding_supervisor first.

Try to enable run_test_cases.py again.

R=phajdan.jr@chromium.org
BUG=164886

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

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@180696 0039d316-1c4b-4281-b951-d872f2087c98

  
- from sharding_supervisor_old import *  # pylint: disable=W0401,W0614
+ """Defer to run_test_cases.py."""
+ 
+ import os
+ import optparse
+ import sys
+ 
+ ROOT_DIR = os.path.dirname(
+     os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
  
  
+ def pop_gtest_output(args):
+   """Extracts --gtest_output from the args if present."""
+   for index, arg in enumerate(args):
+     if arg.startswith('--gtest_output='):
+       return args.pop(index)
+ 
+ 
+ def main():
+   parser = optparse.OptionParser()
+ 
+   group = optparse.OptionGroup(
+       parser, 'Compability flag with the old sharding_supervisor')
+   group.add_option(
+       '--no-color', action='store_true', help='Ignored')
+   group.add_option(
+       '--retry-failed', action='store_true', help='Ignored')
+   group.add_option(
+       '-t', '--timeout', type='int', help='Kept as --timeout')
+   group.add_option(
+       '--total-slaves', type='int', default=1, help='Converted to --index')
+   group.add_option(
+       '--slave-index', type='int', default=0, help='Converted to --shards')
+   parser.add_option_group(group)
+ 
+   parser.disable_interspersed_args()
+   options, args = parser.parse_args()
+ 
+   swarm_client_dir = os.path.join(ROOT_DIR, 'tools', 'swarm_client')
+   sys.path.insert(0, swarm_client_dir)
+ 
+   cmd = [
+     '--shards', str(options.total_slaves),
+     '--index', str(options.slave_index),
+     '--no-dump',
+     '--no-cr',
+   ]
+   if options.timeout is not None:
+     cmd.extend(['--timeout', str(options.timeout)])
+   gtest_output = pop_gtest_output(args)
+   if gtest_output:
+     # It is important that --gtest_output appears before the '--' so it is
+     # properly processed by run_test_cases.
+     cmd.append(gtest_output)
+ 
+   import run_test_cases  # pylint: disable=F0401
+ 
+   return run_test_cases.main(cmd + ['--'] + args)
+ 
+ 
- if __name__ == "__main__":
+ if __name__ == '__main__':
    sys.exit(main())
  
Switch over to run_test_cases.py, take 2.
## Code Before:

from sharding_supervisor_old import *  # pylint: disable=W0401,W0614


if __name__ == "__main__":
  sys.exit(main())

## Instruction:
Switch over to run_test_cases.py, take 2.
## Code After:

"""Defer to run_test_cases.py."""

import os
import optparse
import sys

ROOT_DIR = os.path.dirname(
    os.path.dirname(os.path.dirname(os.path.abspath(__file__))))


def pop_gtest_output(args):
  """Extracts --gtest_output from the args if present."""
  for index, arg in enumerate(args):
    if arg.startswith('--gtest_output='):
      return args.pop(index)


def main():
  parser = optparse.OptionParser()

  group = optparse.OptionGroup(
      parser, 'Compability flag with the old sharding_supervisor')
  group.add_option(
      '--no-color', action='store_true', help='Ignored')
  group.add_option(
      '--retry-failed', action='store_true', help='Ignored')
  group.add_option(
      '-t', '--timeout', type='int', help='Kept as --timeout')
  group.add_option(
      '--total-slaves', type='int', default=1, help='Converted to --index')
  group.add_option(
      '--slave-index', type='int', default=0, help='Converted to --shards')
  parser.add_option_group(group)

  parser.disable_interspersed_args()
  options, args = parser.parse_args()

  swarm_client_dir = os.path.join(ROOT_DIR, 'tools', 'swarm_client')
  sys.path.insert(0, swarm_client_dir)

  cmd = [
    '--shards', str(options.total_slaves),
    '--index', str(options.slave_index),
    '--no-dump',
    '--no-cr',
  ]
  if options.timeout is not None:
    cmd.extend(['--timeout', str(options.timeout)])
  gtest_output = pop_gtest_output(args)
  if gtest_output:
    # It is important that --gtest_output appears before the '--' so it is
    # properly processed by run_test_cases.
    cmd.append(gtest_output)

  import run_test_cases  # pylint: disable=F0401

  return run_test_cases.main(cmd + ['--'] + args)


if __name__ == '__main__':
  sys.exit(main())
