示例#1
0
def _run(exiter):
    # Place the registration of the unhandled exception hook as early as possible in the code.
    sys.excepthook = exiter.unhandled_exception_hook

    # We want to present warnings to the user, set this up early to ensure all warnings are seen.
    # The "default" action displays a warning for a particular file and line number exactly once.
    # See https://docs.python.org/2/library/warnings.html#the-warnings-filter for the complete action
    # list.
    warnings.simplefilter("default")

    # The GoalRunner will setup final logging below in `.setup()`, but span the gap until then.
    logging.basicConfig(level=logging.INFO)
    # This routes the warnings we enabled above through our loggers instead of straight to stderr raw.
    logging.captureWarnings(True)

    root_dir = get_buildroot()
    if not os.path.exists(root_dir):
        exiter.exit_and_fail(
            'PANTS_BUILD_ROOT does not point to a valid path: {}'.format(
                root_dir))

    options_bootstrapper = OptionsBootstrapper()

    plugin_resolver = PluginResolver(options_bootstrapper)
    working_set = plugin_resolver.resolve()

    goal_runner = GoalRunner(root_dir)
    goal_runner.setup(options_bootstrapper, working_set)
    exiter.apply_options(goal_runner.options)
    result = goal_runner.run()
    exiter.do_exit(result)
示例#2
0
def _run(exiter):
  # Place the registration of the unhandled exception hook as early as possible in the code.
  sys.excepthook = exiter.unhandled_exception_hook

  # We want to present warnings to the user, set this up early to ensure all warnings are seen.
  # The "default" action displays a warning for a particular file and line number exactly once.
  # See https://docs.python.org/2/library/warnings.html#the-warnings-filter for the complete action
  # list.
  warnings.simplefilter("default")

  # The GoalRunner will setup final logging below in `.setup()`, but span the gap until then.
  logging.basicConfig()
  # This routes the warnings we enabled above through our loggers instead of straight to stderr raw.
  logging.captureWarnings(True)

  version = pants_version()
  if len(sys.argv) == 2 and sys.argv[1] == _VERSION_OPTION:
    exiter.do_exit(msg=version, out=sys.stdout)

  root_dir = get_buildroot()
  if not os.path.exists(root_dir):
    exiter.exit_and_fail('PANTS_BUILD_ROOT does not point to a valid path: %s' % root_dir)

  goal_runner = GoalRunner(root_dir)
  goal_runner.setup()
  result = goal_runner.run()
  exiter.do_exit(result)
示例#3
0
def test_version_request(version_flag):
  class ExitException(Exception):
    def __init__(self, exit_code):
      self.exit_code = exit_code

  with temporary_dir() as build_root:
    def exiter(exit_code):
      raise ExitException(exit_code)

    goal_runner = GoalRunner(build_root, exiter=exiter)
    options_bootstrapper = OptionsBootstrapper(args=[version_flag])

    with pytest.raises(ExitException) as excinfo:
      goal_runner.setup(options_bootstrapper=options_bootstrapper, working_set=WorkingSet())
    assert 0 == excinfo.value.exit_code
示例#4
0
def _run(exiter):
  # Place the registration of the unhandled exception hook as early as possible in the code.
  sys.excepthook = exiter.unhandled_exception_hook

  logging.basicConfig()
  version = pants_version()
  if len(sys.argv) == 2 and sys.argv[1] == _VERSION_OPTION:
    exiter.do_exit(msg=version, out=sys.stdout)

  root_dir = get_buildroot()
  if not os.path.exists(root_dir):
    exiter.exit_and_fail('PANTS_BUILD_ROOT does not point to a valid path: %s' % root_dir)

  goal_runner = GoalRunner(root_dir)
  goal_runner.setup()
  result = goal_runner.run()
  exiter.do_exit(result)
示例#5
0
def _run():
    # Place the registration of the unhandled exception hook as early as possible in the code.
    sys.excepthook = _unhandled_exception_hook

    logging.basicConfig()
    version = pants_version()
    if len(sys.argv) == 2 and sys.argv[1] == _VERSION_OPTION:
        _do_exit(msg=version, out=sys.stdout)

    root_dir = get_buildroot()
    if not os.path.exists(root_dir):
        _exit_and_fail('PANTS_BUILD_ROOT does not point to a valid path: %s' %
                       root_dir)

    goal_runner = GoalRunner(root_dir)
    goal_runner.setup()
    result = goal_runner.run()
    _do_exit(result)