示例#1
0
 def setUp(self):
     super(RunPrepCommandTest, self).setUp()
     # This is normally taken care of in RunPrepCommandBase.register_options() when running pants,
     # but these don't get called in testing unless you call `self.create_task()`.
     # Some of these unit tests need to create targets before creating the task.
     PrepCommand.add_allowed_goal('test')
     PrepCommand.add_allowed_goal('binary')
示例#2
0
 def setUp(self):
   super(RunPrepCommandTest, self).setUp()
   # This is normally taken care of in RunPrepCommandBase.register_options() when running pants,
   # but these don't get called in testing unless you call `self.create_task()`.
   # Some of these unit tests need to create targets before creating the task.
   PrepCommand.add_allowed_goal('test')
   PrepCommand.add_allowed_goal('binary')
示例#3
0
  def register_options(cls, register):
    """Register options for this optionable.

    In this case, there are no special options, but we want to use this opportunity to setup
    goal validation in PrepCommand before the build graph is parsed.
    """
    super().register_options(register)
    PrepCommand.add_allowed_goal(cls.goal)
示例#4
0
  def register_options(cls, register):
    """Register options for this optionable.

    In this case, there are no special options, but we want to use this opportunity to setup
    goal validation in PrepCommand before the build graph is parsed.
    """
    super(RunPrepCommandBase, cls).register_options(register)
    PrepCommand.add_allowed_goal(cls.goal)
示例#5
0
    def test_prep_command_case(self):
        PrepCommand.add_allowed_goal("compile")
        PrepCommand.add_allowed_goal("test")
        self.add_to_build_file(
            "build-support/thrift",
            dedent(
                """
                prep_command(
                  name='prepare_binary_compile',
                  goals=['compile'],
                  prep_executable='/bin/true',
                )

                prep_command(
                  name='prepare_binary_test',
                  goals=['test'],
                  prep_executable='/bin/true',
                )

                target(
                  name='prepare_binary',
                  dependencies=[
                    ':prepare_binary_compile',
                    ':prepare_binary_test',
                  ],
                )
                """
            ),
        )
        prepare_binary_compile = self.make_target(
            spec="build-support/thrift:prepare_binary_compile",
            target_type=PrepCommand,
            prep_executable="/bin/true",
            goals=["compile"],
        )
        prepare_binary_test = self.make_target(
            spec="build-support/thrift:prepare_binary_test",
            target_type=PrepCommand,
            prep_executable="/bin/true",
            goals=["test"],
        )
        self.make_target(
            spec="build-support/thrift:prepare_binary",
            dependencies=[prepare_binary_compile, prepare_binary_test],
        )

        pants = self.create_python_library(
            relpath="src/python/pants",
            name="pants",
            provides="setup_py(name='pants', version='0.0.0')",
            dependencies=["build-support/thrift:prepare_binary"],
        )
        with self.run_execute(pants) as created:
            self.assertEqual([pants], list(created.keys()))
示例#6
0
    def test_prep_command_case(self):
        PrepCommand.add_allowed_goal("compile")
        PrepCommand.add_allowed_goal("test")
        self.add_to_build_file(
            "build-support/thrift",
            dedent(
                """
                           prep_command(
                             name='prepare_binary_compile',
                             goal='compile',
                             prep_executable='/bin/true',
                           )

                           prep_command(
                             name='prepare_binary_test',
                             goal='test',
                             prep_executable='/bin/true',
                           )

                           target(
                             name='prepare_binary',
                             dependencies=[
                               ':prepare_binary_compile',
                               ':prepare_binary_test',
                             ],
                           )
                           """
            ),
        )
        prepare_binary_compile = self.make_target(
            spec="build-support/thrift:prepare_binary_compile",
            target_type=PrepCommand,
            prep_executable="/bin/true",
            goal="compile",
        )
        prepare_binary_test = self.make_target(
            spec="build-support/thrift:prepare_binary_test",
            target_type=PrepCommand,
            prep_executable="/bin/true",
            goal="test",
        )
        self.make_target(
            spec="build-support/thrift:prepare_binary", dependencies=[prepare_binary_compile, prepare_binary_test]
        )

        pants = self.create_python_library(
            relpath="src/python/pants",
            name="pants",
            provides="setup_py(name='pants', version='0.0.0')",
            dependencies=["build-support/thrift:prepare_binary"],
        )
        with self.run_execute(pants) as created:
            self.assertEqual([pants], created.keys())
示例#7
0
  def test_prep_command_case(self):
    PrepCommand.add_allowed_goal('compile')
    PrepCommand.add_allowed_goal('test')
    self.add_to_build_file('build-support/thrift',
                           dedent("""
                           prep_command(
                             name='prepare_binary_compile',
                             goals=['compile'],
                             prep_executable='/bin/true',
                           )

                           prep_command(
                             name='prepare_binary_test',
                             goals=['test'],
                             prep_executable='/bin/true',
                           )

                           target(
                             name='prepare_binary',
                             dependencies=[
                               ':prepare_binary_compile',
                               ':prepare_binary_test',
                             ],
                           )
                           """))
    prepare_binary_compile = self.make_target(spec='build-support/thrift:prepare_binary_compile',
                                              target_type=PrepCommand,
                                              prep_executable='/bin/true',
                                              goals=['compile'])
    prepare_binary_test = self.make_target(spec='build-support/thrift:prepare_binary_test',
                                           target_type=PrepCommand,
                                           prep_executable='/bin/true',
                                           goals=['test'])
    self.make_target(spec='build-support/thrift:prepare_binary',
                     dependencies=[
                       prepare_binary_compile,
                       prepare_binary_test
                     ])

    pants = self.create_python_library(
      relpath='src/python/pants',
      name='pants',
      provides="setup_py(name='pants', version='0.0.0')",
      dependencies=[
        'build-support/thrift:prepare_binary'
      ]
    )
    with self.run_execute(pants) as created:
      self.assertEqual([pants], list(created.keys()))
示例#8
0
  def test_prep_command_case(self):
    PrepCommand.add_allowed_goal('compile')
    PrepCommand.add_allowed_goal('test')
    self.add_to_build_file('build-support/thrift',
                           dedent("""
                           prep_command(
                             name='prepare_binary_compile',
                             goal='compile',
                             prep_executable='/bin/true',
                           )

                           prep_command(
                             name='prepare_binary_test',
                             goal='test',
                             prep_executable='/bin/true',
                           )

                           target(
                             name='prepare_binary',
                             dependencies=[
                               ':prepare_binary_compile',
                               ':prepare_binary_test',
                             ],
                           )
                           """))
    prepare_binary_compile = self.make_target(spec='build-support/thrift:prepare_binary_compile',
                                              target_type=PrepCommand,
                                              prep_executable='/bin/true',
                                              goal='compile')
    prepare_binary_test = self.make_target(spec='build-support/thrift:prepare_binary_test',
                                           target_type=PrepCommand,
                                           prep_executable='/bin/true',
                                           goal='test')
    self.make_target(spec='build-support/thrift:prepare_binary',
                     dependencies=[
                       prepare_binary_compile,
                       prepare_binary_test
                     ])

    pants = self.create_python_library(
      relpath='src/python/pants',
      name='pants',
      provides="setup_py(name='pants', version='0.0.0')",
      dependencies=[
        'build-support/thrift:prepare_binary'
      ]
    )
    with self.run_execute(pants) as created:
      self.assertEqual([pants], created.keys())