コード例 #1
0
    def tearDown(self):
        """
    :API: public
    """
        Goal.clear()

        super(EngineTestBase, self).tearDown()
コード例 #2
0
  def setUp(self):
    super(BaseTest, self).setUp()
    Goal.clear()
    Subsystem.reset()

    self.real_build_root = BuildRoot().path

    self.build_root = os.path.realpath(mkdtemp(suffix='_BUILD_ROOT'))
    self.addCleanup(safe_rmtree, self.build_root)

    self.pants_workdir = os.path.join(self.build_root, '.pants.d')
    safe_mkdir(self.pants_workdir)

    self.options = defaultdict(dict)  # scope -> key-value mapping.
    self.options[''] = {
      'pants_workdir': self.pants_workdir,
      'pants_supportdir': os.path.join(self.build_root, 'build-support'),
      'pants_distdir': os.path.join(self.build_root, 'dist'),
      'pants_configdir': os.path.join(self.build_root, 'config'),
      'cache_key_gen_version': '0-test',
    }

    BuildRoot().path = self.build_root
    self.addCleanup(BuildRoot().reset)

    # We need a pants.ini, even if empty. get_buildroot() uses its presence.
    self.create_file('pants.ini')
    self._build_configuration = BuildConfiguration()
    self._build_configuration.register_aliases(self.alias_groups)
    self.build_file_parser = BuildFileParser(self._build_configuration, self.build_root)
    self.address_mapper = BuildFileAddressMapper(self.build_file_parser, FilesystemBuildFile)
    self.build_graph = BuildGraph(address_mapper=self.address_mapper)
コード例 #3
0
    def setUp(self):
        super(EngineTestBase, self).setUp()

        # TODO(John Sirois): Now that the BuildFileParser controls goal registration by iterating
        # over plugin callbacks a GoalRegistry can be constructed by it and handed to all these
        # callbacks in place of having a global Goal registry.  Remove the Goal static cling.
        Goal.clear()
コード例 #4
0
def clean_global_runtime_state():
    """Resets the global runtime state of a pants runtime for cleaner forking."""
    # Reset RunTracker state.
    RunTracker.global_instance().reset(reset_options=False)

    # Reset Goals and Tasks.
    Goal.clear()
コード例 #5
0
    def tearDown(self):
        """
        :API: public
        """
        Goal.clear()

        super().tearDown()
コード例 #6
0
ファイル: test_list_goals.py プロジェクト: arloherrine/pants
  def test_list_goals(self):
    Goal.clear()
    self.assert_console_output(self._INSTALLED_HEADER)

    TaskRegistrar(name=self._LIST_GOALS_NAME, action=ListGoals)\
      .install().with_description(self._LIST_GOALS_DESC)
    self.assert_console_output(
      self._INSTALLED_HEADER,
      '  %s: %s' % (self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
    )

    TaskRegistrar(name=self._LLAMA_NAME, action=ListGoalsTest.LlamaTask)\
      .install().with_description(self._LLAMA_DESC)
    self.assert_console_output(
      self._INSTALLED_HEADER,
      '  %s: %s' % (self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
      '  %s: %s' % (self._LLAMA_NAME, self._LLAMA_DESC),
    )

    TaskRegistrar(name=self._ALPACA_NAME, action=ListGoalsTest.AlpacaTask, dependencies=[self._LLAMA_NAME])\
      .install()
    self.assert_console_output(
      self._INSTALLED_HEADER,
      '  %s: %s' % (self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
      '  %s: %s' % (self._LLAMA_NAME, self._LLAMA_DESC),
    )
コード例 #7
0
ファイル: test_list_goals.py プロジェクト: arloherrine/pants
  def test_list_goals_graph(self):
    Goal.clear()

    TaskRegistrar(name=self._LIST_GOALS_NAME, action=ListGoals)\
      .install().with_description(self._LIST_GOALS_DESC)
    TaskRegistrar(name=self._LLAMA_NAME, action=ListGoalsTest.LlamaTask)\
      .install().with_description(self._LLAMA_DESC)
    TaskRegistrar(name=self._ALPACA_NAME, action=ListGoalsTest.AlpacaTask, dependencies=[self._LLAMA_NAME])\
      .install()

    self.assert_console_output(
      'digraph G {\n  rankdir=LR;\n  graph [compound=true];',
      '  subgraph cluster_goals {\n    node [style=filled];\n    color = blue;\n    label = "goals";',
      '    goals_goals [label="goals"];',
      '  }',
      '  subgraph cluster_llama {\n    node [style=filled];\n    color = blue;\n    label = "llama";',
      '    llama_llama [label="llama"];',
      '  }',
      '  subgraph cluster_alpaca {\n    node [style=filled];\n    color = blue;\n    label = "alpaca";',
      '    alpaca_alpaca [label="alpaca"];',
      '  }',
      '  alpaca_alpaca -> llama_llama [ltail=cluster_alpaca lhead=cluster_llama];',
      '}',
      args=['--test-graph'],
    )
コード例 #8
0
ファイル: test_list_goals.py プロジェクト: CaitieM20/pants
  def test_list_goals(self):
    Goal.clear()
    self.assert_console_output(self._INSTALLED_HEADER)

    # Goals with no tasks should always be elided.
    list_goals_goal = Goal.register(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC)
    self.assert_console_output(self._INSTALLED_HEADER)

    list_goals_goal.install(self._LIST_GOALS_TASK)
    self.assert_console_output(
      self._INSTALLED_HEADER,
      '  {0}: {1}'.format(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
    )

    Goal.register(self._LLAMA_NAME, self._LLAMA_DESC).install(self._LLAMA_TASK)
    self.assert_console_output(
      self._INSTALLED_HEADER,
      '  {0}: {1}'.format(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
      '  {0}: {1}'.format(self._LLAMA_NAME, self._LLAMA_DESC),
    )

    Goal.register(self._ALPACA_NAME, description='').install(self._ALPACA_TASK)
    self.assert_console_output(
      self._INSTALLED_HEADER,
      '  {0}: {1}'.format(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
      '  {0}: {1}'.format(self._LLAMA_NAME, self._LLAMA_DESC),
    )
コード例 #9
0
ファイル: base_engine_test.py プロジェクト: jduan/pants
    def setUp(self):
        super(EngineTestBase, self).setUp()

        # TODO(John Sirois): Now that the BuildFileParser controls goal registration by iterating
        # over plugin callbacks a GoalRegistry can be constructed by it and handed to all these
        # callbacks in place of having a global Goal registry.  Remove the Goal static cling.
        Goal.clear()
コード例 #10
0
    def test_load_valid_partial_goals(self):
        def register_goals():
            Goal.by_name("jack").install(TaskRegistrar("jill", DummyTask))

        with self.create_register(
                register_goals=register_goals) as backend_package:
            Goal.clear()
            self.assertEqual(0, len(Goal.all()))

            load_backend(self.build_configuration,
                         backend_package,
                         is_v1_backend=False)
            self.assertEqual(0, len(Goal.all()))

            load_backend(self.build_configuration,
                         backend_package,
                         is_v1_backend=True)
            self.assert_empty_aliases()
            self.assertEqual(1, len(Goal.all()))

            task_names = Goal.by_name("jack").ordered_task_names()
            self.assertEqual(1, len(task_names))

            task_name = task_names[0]
            self.assertEqual("jill", task_name)
コード例 #11
0
ファイル: task_test_base.py プロジェクト: lclementi/pants
    def setUp(self):
        Goal.clear()
        super(ConsoleTaskTestBase, self).setUp()

        task_type = self.task_type()
        assert issubclass(task_type, ConsoleTask), \
            'task_type() must return a ConsoleTask subclass, got %s' % task_type
コード例 #12
0
ファイル: test_list_goals.py プロジェクト: rogerswingle/pants
    def test_list_goals_graph(self):
        Goal.clear()

        TaskRegistrar(name=self._LIST_GOALS_NAME, action=ListGoals)\
          .install().with_description(self._LIST_GOALS_DESC)
        TaskRegistrar(name=self._LLAMA_NAME, action=ListGoalsTest.LlamaTask)\
          .install().with_description(self._LLAMA_DESC)
        TaskRegistrar(name=self._ALPACA_NAME, action=ListGoalsTest.AlpacaTask, dependencies=[self._LLAMA_NAME])\
          .install()

        self.assert_console_output(
            'digraph G {\n  rankdir=LR;\n  graph [compound=true];',
            '  subgraph cluster_goals {\n    node [style=filled];\n    color = blue;\n    label = "goals";',
            '    goals_goals [label="goals"];',
            '  }',
            '  subgraph cluster_llama {\n    node [style=filled];\n    color = blue;\n    label = "llama";',
            '    llama_llama [label="llama"];',
            '  }',
            '  subgraph cluster_alpaca {\n    node [style=filled];\n    color = blue;\n    label = "alpaca";',
            '    alpaca_alpaca [label="alpaca"];',
            '  }',
            '  alpaca_alpaca -> llama_llama [ltail=cluster_alpaca lhead=cluster_llama];',
            '}',
            args=['--test-graph'],
        )
コード例 #13
0
    def test_list_goals(self):
        Goal.clear()
        self.assert_console_output(self._INSTALLED_HEADER)

        TaskRegistrar(name=self._LIST_GOALS_NAME, action=ListGoals)\
          .install().with_description(self._LIST_GOALS_DESC)
        self.assert_console_output(
            self._INSTALLED_HEADER,
            '  {0}: {1}'.format(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
        )

        TaskRegistrar(name=self._LLAMA_NAME, action=ListGoalsTest.LlamaTask)\
          .install().with_description(self._LLAMA_DESC)
        self.assert_console_output(
            self._INSTALLED_HEADER,
            '  {0}: {1}'.format(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
            '  {0}: {1}'.format(self._LLAMA_NAME, self._LLAMA_DESC),
        )

        TaskRegistrar(name=self._ALPACA_NAME, action=ListGoalsTest.AlpacaTask, dependencies=[self._LLAMA_NAME])\
          .install()
        self.assert_console_output(
            self._INSTALLED_HEADER,
            '  {0}: {1}'.format(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
            '  {0}: {1}'.format(self._LLAMA_NAME, self._LLAMA_DESC),
        )
コード例 #14
0
ファイル: base_engine_test.py プロジェクト: CaitieM20/pants
  def tearDown(self):
    """
    :API: public
    """
    Goal.clear()

    super(EngineTestBase, self).tearDown()
コード例 #15
0
ファイル: test_list_goals.py プロジェクト: tglstory/pants
    def test_list_goals(self):
        Goal.clear()
        self.assert_console_output(self._INSTALLED_HEADER)

        # Goals with no tasks should always be elided.
        list_goals_goal = Goal.register(self._LIST_GOALS_NAME,
                                        self._LIST_GOALS_DESC)
        self.assert_console_output(self._INSTALLED_HEADER)

        list_goals_goal.install(self._LIST_GOALS_TASK)
        self.assert_console_output(
            self._INSTALLED_HEADER,
            '  {0}: {1}'.format(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
        )

        Goal.register(self._LLAMA_NAME,
                      self._LLAMA_DESC).install(self._LLAMA_TASK)
        self.assert_console_output(
            self._INSTALLED_HEADER,
            '  {0}: {1}'.format(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
            '  {0}: {1}'.format(self._LLAMA_NAME, self._LLAMA_DESC),
        )

        Goal.register(self._ALPACA_NAME,
                      description='').install(self._ALPACA_TASK)
        self.assert_console_output(
            self._INSTALLED_HEADER,
            '  {0}: {1}'.format(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
            '  {0}: {1}'.format(self._LLAMA_NAME, self._LLAMA_DESC),
        )
コード例 #16
0
ファイル: test_base.py プロジェクト: digideskio/pants
  def setUp(self):
    Goal.clear()
    super(ConsoleTaskTest, self).setUp()

    task_type = self.task_type()
    assert issubclass(task_type, ConsoleTask), \
        'task_type() must return a ConsoleTask subclass, got %s' % task_type
コード例 #17
0
ファイル: util.py プロジェクト: adamchainz/pants
def clean_global_runtime_state():
  """Resets the global runtime state of a pants runtime for cleaner forking."""
  # Reset RunTracker state.
  RunTracker.global_instance().reset(reset_options=False)

  # Reset Goals and Tasks.
  Goal.clear()
コード例 #18
0
ファイル: task_test_base.py プロジェクト: triplequote/pants
    def setUp(self):
        """
    :API: public
    """
        Goal.clear()
        super().setUp()

        task_type = self.task_type()
        assert issubclass(task_type, ConsoleTask), \
            'task_type() must return a ConsoleTask subclass, got %s' % task_type
コード例 #19
0
ファイル: pants_daemon.py プロジェクト: wolframarnold/pants
  def _clean_runtime_state(self):
    """Resets the runtime state from running ./pants -> running in the fork()'d daemon context."""
    # TODO(kwlzn): Make this logic available to PantsRunner et al for inline state reset before
    # pants runs to improve testability and avoid potential bitrot.

    # Reset RunTracker state.
    RunTracker.global_instance().reset(reset_options=False)

    # Reset Goals and Tasks.
    Goal.clear()
コード例 #20
0
ファイル: base_test.py プロジェクト: slackhappy/pants
  def setUp(self):
    Goal.clear()
    self.real_build_root = BuildRoot().path
    self.build_root = os.path.realpath(mkdtemp(suffix='_BUILD_ROOT'))
    BuildRoot().path = self.build_root

    self.create_file('pants.ini')
    build_configuration = BuildConfiguration()
    build_configuration.register_aliases(self.alias_groups)
    self.build_file_parser = BuildFileParser(build_configuration, self.build_root)
    self.address_mapper = BuildFileAddressMapper(self.build_file_parser)
    self.build_graph = BuildGraph(address_mapper=self.address_mapper)
コード例 #21
0
 def test_task_subclass_singletons(self):
   # Install the same task class twice (before/after Goal.clear()) and confirm that the
   # resulting task is equal.
   class MyTask(Task):
     pass
   def install():
     reg = super(RoundEngineTest, self).install_task(name='task1', action=MyTask, goal='goal1')
     return reg.task_types()
   task1_pre, = install()
   Goal.clear()
   task1_post, = install()
   self.assertEquals(task1_pre, task1_post)
コード例 #22
0
    def setUp(self):
        Goal.clear()
        self.real_build_root = BuildRoot().path
        self.build_root = os.path.realpath(mkdtemp(suffix='_BUILD_ROOT'))
        BuildRoot().path = self.build_root

        self.create_file('pants.ini')
        build_configuration = BuildConfiguration()
        build_configuration.register_aliases(self.alias_groups)
        self.build_file_parser = BuildFileParser(build_configuration,
                                                 self.build_root)
        self.address_mapper = BuildFileAddressMapper(self.build_file_parser)
        self.build_graph = BuildGraph(address_mapper=self.address_mapper)
コード例 #23
0
def clean_global_runtime_state(reset_subsystem=False):
    """Resets the global runtime state of a pants runtime for cleaner forking.

    :param bool reset_subsystem: Whether or not to clean Subsystem global state.
    """
    if reset_subsystem:
        # Reset subsystem state.
        Subsystem.reset()

    # Reset Goals and Tasks.
    Goal.clear()

    # Reset global plugin state.
    BuildConfigInitializer.reset()
コード例 #24
0
ファイル: base_test.py プロジェクト: rgbenson/pants
  def setUp(self):
    super(BaseTest, self).setUp()
    Goal.clear()
    self.real_build_root = BuildRoot().path
    self.build_root = os.path.realpath(mkdtemp(suffix='_BUILD_ROOT'))
    self.new_options = defaultdict(dict)  # scope -> key-value mapping.
    BuildRoot().path = self.build_root

    self.create_file('pants.ini')
    build_configuration = BuildConfiguration()
    build_configuration.register_aliases(self.alias_groups)
    self.build_file_parser = BuildFileParser(build_configuration, self.build_root)
    self.address_mapper = BuildFileAddressMapper(self.build_file_parser)
    self.build_graph = BuildGraph(address_mapper=self.address_mapper)
コード例 #25
0
ファイル: util.py プロジェクト: benjyw/pants
def clean_global_runtime_state(reset_subsystem=False):
  """Resets the global runtime state of a pants runtime for cleaner forking.

  :param bool reset_subsystem: Whether or not to clean Subsystem global state.
  """
  if reset_subsystem:
    # Reset subsystem state.
    Subsystem.reset()

  # Reset Goals and Tasks.
  Goal.clear()

  # Reset backend/plugins state.
  OptionsInitializer.reset()
コード例 #26
0
ファイル: test_list_goals.py プロジェクト: Gointer/pants
  def test_list_goals_all(self):
    Goal.clear()

    Goal.register(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC)
    Goal.register(self._LLAMA_NAME, self._LLAMA_DESC)
    Goal.register(self._ALPACA_NAME, description='')

    self.assert_console_output(
      self._INSTALLED_HEADER,
      '  {0}: {1}'.format(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
      '  {0}: {1}'.format(self._LLAMA_NAME, self._LLAMA_DESC),
      '',
      self._UNDOCUMENTED_HEADER,
      '  {0}'.format(self._ALPACA_NAME),
      options={'all': True}
    )
コード例 #27
0
    def test_task_subclass_singletons(self):
        # Install the same task class twice (before/after Goal.clear()) and confirm that the
        # resulting task is equal.
        class MyTask(Task):
            pass

        def install():
            reg = super(RoundEngineTest, self).install_task(name="task1",
                                                            action=MyTask,
                                                            goal="goal1")
            return reg.task_types()

        (task1_pre, ) = install()
        Goal.clear()
        (task1_post, ) = install()
        self.assertEqual(task1_pre, task1_post)
コード例 #28
0
    def test_list_goals_all(self):
        Goal.clear()

        Goal.register(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC)
        Goal.register(self._LLAMA_NAME, self._LLAMA_DESC)
        Goal.register(self._ALPACA_NAME, description='')

        self.assert_console_output(self._INSTALLED_HEADER,
                                   '  {0}: {1}'.format(self._LIST_GOALS_NAME,
                                                       self._LIST_GOALS_DESC),
                                   '  {0}: {1}'.format(self._LLAMA_NAME,
                                                       self._LLAMA_DESC),
                                   '',
                                   self._UNDOCUMENTED_HEADER,
                                   '  {0}'.format(self._ALPACA_NAME),
                                   options={'all': True})
コード例 #29
0
ファイル: test_list_goals.py プロジェクト: ryokugyu/pants
  def test_register_duplicate_task_name_is_not_error_when_replacing(self):
    Goal.clear()

    class NoopTask(Task):
      def execute(self):
        pass

    class OtherNoopTask(Task):
      def execute(self):
        pass

    goal = Goal.register(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC)
    task_name = 'foo'
    goal.install(TaskRegistrar(task_name, NoopTask))
    goal.install(TaskRegistrar(task_name, OtherNoopTask), replace=True)

    self.assertTrue(issubclass(goal.task_type_by_name(task_name), OtherNoopTask))
コード例 #30
0
ファイル: test_list_goals.py プロジェクト: foursquare/pants
  def test_register_duplicate_task_name_is_not_error_when_replacing(self):
    Goal.clear()

    class NoopTask(Task):
      def execute(self):
        pass

    class OtherNoopTask(Task):
      def execute(self):
        pass

    goal = Goal.register(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC)
    task_name = 'foo'
    goal.install(TaskRegistrar(task_name, NoopTask))
    goal.install(TaskRegistrar(task_name, OtherNoopTask), replace=True)

    self.assertTrue(issubclass(goal.task_type_by_name(task_name), OtherNoopTask))
コード例 #31
0
  def test_load_valid_partial_goals(self):
    def register_goals():
      Goal.by_name('jack').install(TaskRegistrar('jill', DummyTask))

    with self.create_register(register_goals=register_goals) as backend_package:
      Goal.clear()
      self.assertEqual(0, len(Goal.all()))

      load_backend(self.build_configuration, backend_package)
      self.assert_empty_aliases()
      self.assertEqual(1, len(Goal.all()))

      task_names = Goal.by_name('jack').ordered_task_names()
      self.assertEqual(1, len(task_names))

      task_name = task_names[0]
      self.assertEqual('jill', task_name)
コード例 #32
0
  def test_load_valid_partial_goals(self):
    def register_goals():
      Goal.by_name('jack').install(TaskRegistrar('jill', lambda: 42))

    with self.create_register(register_goals=register_goals) as backend_package:
      Goal.clear()
      self.assertEqual(0, len(Goal.all()))

      load_backend(self.build_configuration, backend_package)
      self.assert_empty_aliases()
      self.assertEqual(1, len(Goal.all()))

      task_names = Goal.by_name('jack').ordered_task_names()
      self.assertEqual(1, len(task_names))

      task_name = task_names[0]
      self.assertEqual('jill', task_name)
コード例 #33
0
    def setUp(self):
        """
    :API: public
    """
        super(BaseTest, self).setUp()
        Goal.clear()
        Subsystem.reset()

        self.real_build_root = BuildRoot().path

        self.build_root = os.path.realpath(mkdtemp(suffix='_BUILD_ROOT'))
        self.subprocess_dir = os.path.join(self.build_root, '.pids')
        self.addCleanup(safe_rmtree, self.build_root)

        self.pants_workdir = os.path.join(self.build_root, '.pants.d')
        safe_mkdir(self.pants_workdir)

        self.options = defaultdict(dict)  # scope -> key-value mapping.
        self.options[''] = {
            'pants_workdir': self.pants_workdir,
            'pants_supportdir': os.path.join(self.build_root, 'build-support'),
            'pants_distdir': os.path.join(self.build_root, 'dist'),
            'pants_configdir': os.path.join(self.build_root, 'config'),
            'pants_subprocessdir': self.subprocess_dir,
            'cache_key_gen_version': '0-test',
        }
        self.options['cache'] = {
            'read_from': [],
            'write_to': [],
        }

        BuildRoot().path = self.build_root
        self.addCleanup(BuildRoot().reset)

        self._build_configuration = BuildConfiguration()
        self._build_configuration.register_aliases(self.alias_groups)
        self.build_file_parser = BuildFileParser(self._build_configuration,
                                                 self.build_root)
        self.project_tree = FileSystemProjectTree(self.build_root)
        self.address_mapper = BuildFileAddressMapper(
            self.build_file_parser,
            self.project_tree,
            build_ignore_patterns=self.build_ignore_patterns)
        self.build_graph = MutableBuildGraph(
            address_mapper=self.address_mapper)
コード例 #34
0
ファイル: test_list_goals.py プロジェクト: ryokugyu/pants
  def test_list_goals_all(self):
    Goal.clear()

    Goal.register(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC).install(self._LIST_GOALS_TASK)

    # Goals with no tasks should always be elided.
    Goal.register(self._LLAMA_NAME, self._LLAMA_DESC)

    Goal.register(self._ALPACA_NAME, description='').install(self._ALPACA_TASK)

    self.assert_console_output(
      self._INSTALLED_HEADER,
      '  {0}: {1}'.format(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
      '',
      self._UNDOCUMENTED_HEADER,
      '  {0}'.format(self._ALPACA_NAME),
      options={'all': True}
    )
コード例 #35
0
ファイル: test_list_goals.py プロジェクト: CaitieM20/pants
  def test_list_goals_all(self):
    Goal.clear()

    Goal.register(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC).install(self._LIST_GOALS_TASK)

    # Goals with no tasks should always be elided.
    Goal.register(self._LLAMA_NAME, self._LLAMA_DESC)

    Goal.register(self._ALPACA_NAME, description='').install(self._ALPACA_TASK)

    self.assert_console_output(
      self._INSTALLED_HEADER,
      '  {0}: {1}'.format(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
      '',
      self._UNDOCUMENTED_HEADER,
      '  {0}'.format(self._ALPACA_NAME),
      options={'all': True}
    )
コード例 #36
0
ファイル: test_list_goals.py プロジェクト: jduan/pants
  def test_list_goals_all(self):
    Goal.clear()

    TaskRegistrar(name=self._LIST_GOALS_NAME, action=ListGoals)\
      .install().with_description(self._LIST_GOALS_DESC)
    TaskRegistrar(name=self._LLAMA_NAME, action=ListGoalsTest.LlamaTask)\
      .install().with_description(self._LLAMA_DESC)
    TaskRegistrar(name=self._ALPACA_NAME, action=ListGoalsTest.AlpacaTask, dependencies=[self._LLAMA_NAME])\
      .install()

    self.assert_console_output(
      self._INSTALLED_HEADER,
      '  {0}: {1}'.format(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
      '  {0}: {1}'.format(self._LLAMA_NAME, self._LLAMA_DESC),
      '',
      self._UNDOCUMENTED_HEADER,
      '  {0}'.format(self._ALPACA_NAME),
      options={'all': True}
    )
コード例 #37
0
def clean_global_runtime_state(reset_runtracker=True, reset_subsystem=False):
    """Resets the global runtime state of a pants runtime for cleaner forking.

  :param bool reset_runtracker: Whether or not to clean RunTracker global state.
  :param bool reset_subsystem: Whether or not to clean Subsystem global state.
  """
    if reset_runtracker:
        # Reset RunTracker state.
        RunTracker.global_instance().reset(reset_options=False)

    if reset_subsystem:
        # Reset subsystem state.
        Subsystem.reset()

    # Reset Goals and Tasks.
    Goal.clear()

    # Reset backend/plugins state.
    OptionsInitializer.reset()
コード例 #38
0
ファイル: test_list_goals.py プロジェクト: rogerswingle/pants
    def test_list_goals_all(self):
        Goal.clear()

        TaskRegistrar(name=self._LIST_GOALS_NAME, action=ListGoals)\
          .install().with_description(self._LIST_GOALS_DESC)
        TaskRegistrar(name=self._LLAMA_NAME, action=ListGoalsTest.LlamaTask)\
          .install().with_description(self._LLAMA_DESC)
        TaskRegistrar(name=self._ALPACA_NAME, action=ListGoalsTest.AlpacaTask, dependencies=[self._LLAMA_NAME])\
          .install()

        self.assert_console_output(
            self._INSTALLED_HEADER,
            '  %s: %s' % (self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
            '  %s: %s' % (self._LLAMA_NAME, self._LLAMA_DESC),
            '',
            self._UNDOCUMENTED_HEADER,
            '  %s' % self._ALPACA_NAME,
            args=['--test-all'],
        )
コード例 #39
0
ファイル: test_list_goals.py プロジェクト: tglstory/pants
    def test_register_duplicate_task_name_is_error(self):
        Goal.clear()

        class NoopTask(Task):
            def execute(self):
                pass

        class OtherNoopTask(Task):
            def execute(self):
                pass

        goal = Goal.register(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC)
        task_name = 'foo'
        goal.install(TaskRegistrar(task_name, NoopTask))

        with self.assertRaises(GoalError) as ctx:
            goal.install(TaskRegistrar(task_name, OtherNoopTask))

        self.assertIn('foo', ctx.exception.message)
        self.assertIn(self._LIST_GOALS_NAME, ctx.exception.message)
コード例 #40
0
ファイル: base_test.py プロジェクト: dominichamon/pants
  def setUp(self):
    super(BaseTest, self).setUp()
    Goal.clear()
    self.real_build_root = BuildRoot().path
    self.build_root = os.path.realpath(mkdtemp(suffix='_BUILD_ROOT'))
    self.options = defaultdict(dict)  # scope -> key-value mapping.
    self.options[''] = {
      'pants_workdir': os.path.join(self.build_root, '.pants.d'),
      'pants_supportdir': os.path.join(self.build_root, 'build-support'),
      'pants_distdir': os.path.join(self.build_root, 'dist'),
      'cache_key_gen_version': '0-test'
    }
    BuildRoot().path = self.build_root

    self.create_file('pants.ini')
    build_configuration = BuildConfiguration()
    build_configuration.register_aliases(self.alias_groups)
    self.build_file_parser = BuildFileParser(build_configuration, self.build_root)
    self.address_mapper = BuildFileAddressMapper(self.build_file_parser)
    self.build_graph = BuildGraph(address_mapper=self.address_mapper)
コード例 #41
0
    def setUp(self):
        super(BaseTest, self).setUp()
        Goal.clear()
        self.real_build_root = BuildRoot().path
        self.build_root = os.path.realpath(mkdtemp(suffix='_BUILD_ROOT'))
        self.new_options = defaultdict(dict)  # scope -> key-value mapping.
        self.new_options[''] = {
            'pants_workdir': os.path.join(self.build_root, '.pants.d'),
            'pants_supportdir': os.path.join(self.build_root, 'build-support'),
            'pants_distdir': os.path.join(self.build_root, 'dist')
        }
        BuildRoot().path = self.build_root

        self.create_file('pants.ini')
        build_configuration = BuildConfiguration()
        build_configuration.register_aliases(self.alias_groups)
        self.build_file_parser = BuildFileParser(build_configuration,
                                                 self.build_root)
        self.address_mapper = BuildFileAddressMapper(self.build_file_parser)
        self.build_graph = BuildGraph(address_mapper=self.address_mapper)
コード例 #42
0
ファイル: test_list_goals.py プロジェクト: patricklaw/pants
    def test_list_goals_all(self):
        Goal.clear()

        TaskRegistrar(name=self._LIST_GOALS_NAME, action=ListGoals).install().with_description(self._LIST_GOALS_DESC)
        TaskRegistrar(name=self._LLAMA_NAME, action=ListGoalsTest.LlamaTask).install().with_description(
            self._LLAMA_DESC
        )
        TaskRegistrar(
            name=self._ALPACA_NAME, action=ListGoalsTest.AlpacaTask, dependencies=[self._LLAMA_NAME]
        ).install()

        self.assert_console_output(
            self._INSTALLED_HEADER,
            "  %s: %s" % (self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
            "  %s: %s" % (self._LLAMA_NAME, self._LLAMA_DESC),
            "",
            self._UNDOCUMENTED_HEADER,
            "  %s" % self._ALPACA_NAME,
            args=["--test-all"],
        )
コード例 #43
0
ファイル: test_list_goals.py プロジェクト: foursquare/pants
  def test_register_duplicate_task_name_is_error(self):
    Goal.clear()

    class NoopTask(Task):
      def execute(self):
        pass

    class OtherNoopTask(Task):
      def execute(self):
        pass

    goal = Goal.register(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC)
    task_name = 'foo'
    goal.install(TaskRegistrar(task_name, NoopTask))

    with self.assertRaises(GoalError) as ctx:
      goal.install(TaskRegistrar(task_name, OtherNoopTask))

    self.assertIn('foo', ctx.exception.message)
    self.assertIn(self._LIST_GOALS_NAME, ctx.exception.message)
コード例 #44
0
ファイル: base_test.py プロジェクト: adamchainz/pants
  def setUp(self):
    """
    :API: public
    """
    super(BaseTest, self).setUp()
    Goal.clear()
    Subsystem.reset()

    self.real_build_root = BuildRoot().path

    self.build_root = os.path.realpath(mkdtemp(suffix='_BUILD_ROOT'))
    self.subprocess_dir = os.path.join(self.build_root, '.pids')
    self.addCleanup(safe_rmtree, self.build_root)

    self.pants_workdir = os.path.join(self.build_root, '.pants.d')
    safe_mkdir(self.pants_workdir)

    self.options = defaultdict(dict)  # scope -> key-value mapping.
    self.options[''] = {
      'pants_workdir': self.pants_workdir,
      'pants_supportdir': os.path.join(self.build_root, 'build-support'),
      'pants_distdir': os.path.join(self.build_root, 'dist'),
      'pants_configdir': os.path.join(self.build_root, 'config'),
      'pants_subprocessdir': self.subprocess_dir,
      'cache_key_gen_version': '0-test',
    }
    self.options['cache'] = {
      'read_from': [],
      'write_to': [],
    }

    BuildRoot().path = self.build_root
    self.addCleanup(BuildRoot().reset)

    self._build_configuration = BuildConfiguration()
    self._build_configuration.register_aliases(self.alias_groups)
    self.build_file_parser = BuildFileParser(self._build_configuration, self.build_root)
    self.project_tree = FileSystemProjectTree(self.build_root)
    self.address_mapper = BuildFileAddressMapper(self.build_file_parser, self.project_tree,
                                                 build_ignore_patterns=self.build_ignore_patterns)
    self.build_graph = MutableBuildGraph(address_mapper=self.address_mapper)
コード例 #45
0
    def test_list_goals_graph(self):
        Goal.clear()

        Goal.register(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC)
        Goal.register(self._LLAMA_NAME, self._LLAMA_DESC)
        Goal.register(self._ALPACA_NAME, description='')

        self.assert_console_output(
            'digraph G {\n  rankdir=LR;\n  graph [compound=true];',
            '  subgraph cluster_goals {\n    node [style=filled];\n    color = blue;\n    label = "goals";',
            '    goals_goals [label="goals"];',
            '  }',
            '  subgraph cluster_llama {\n    node [style=filled];\n    color = blue;\n    label = "llama";',
            '    llama_llama [label="llama"];',
            '  }',
            '  subgraph cluster_alpaca {\n    node [style=filled];\n    color = blue;\n    label = "alpaca";',
            '    alpaca_alpaca [label="alpaca"];',
            '  }',
            '  alpaca_alpaca -> llama_llama [ltail=cluster_alpaca lhead=cluster_llama];',
            '}',
            options={'graph': True})
コード例 #46
0
ファイル: test_list_goals.py プロジェクト: CaitieM20/pants
  def test_list_goals_graph(self):
    Goal.clear()

    Goal.register(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC).install(self._LIST_GOALS_TASK)
    Goal.register(self._LLAMA_NAME, self._LLAMA_DESC).install(self._LLAMA_TASK)
    Goal.register(self._ALPACA_NAME, description='')

    self.assert_console_output(
      'digraph G {\n  rankdir=LR;\n  graph [compound=true];',
      '  subgraph cluster_goals {\n    node [style=filled];\n    color = blue;\n    label = "goals";',
      '    goals_goals [label="goals"];',
      '  }',
      '  subgraph cluster_llama {\n    node [style=filled];\n    color = blue;\n    label = "llama";',
      '    llama_llama [label="llama"];',
      '  }',
      '  subgraph cluster_alpaca {\n    node [style=filled];\n    color = blue;\n    label = "alpaca";',
      '    alpaca_alpaca [label="alpaca"];',
      '  }',
      '  alpaca_alpaca -> llama_llama [ltail=cluster_alpaca lhead=cluster_llama];',
      '}',
      options={'graph': True}
    )
コード例 #47
0
ファイル: util.py プロジェクト: lahosken/pants
def clean_global_runtime_state(reset_runtracker=True, reset_subsystem=False):
    """Resets the global runtime state of a pants runtime for cleaner forking.

  :param bool reset_runtracker: Whether or not to clean RunTracker global state.
  :param bool reset_subsystem: Whether or not to clean Subsystem global state.
  """
    if reset_runtracker:
        # Reset RunTracker state.
        RunTracker.global_instance().reset(reset_options=False)

    if reset_subsystem:
        # Reset subsystem state.
        Subsystem.reset()

    #TODO: Think of an alternative for IntermediateTargetFactoryBase._targets to avoid this call
    IntermediateTargetFactoryBase.reset()

    # Reset Goals and Tasks.
    Goal.clear()

    # Reset backend/plugins state.
    OptionsInitializer.reset()
コード例 #48
0
    def test_list_goals(self):
        Goal.clear()
        self.assert_console_output(self._INSTALLED_HEADER)

        Goal.register(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC)
        self.assert_console_output(
            self._INSTALLED_HEADER,
            '  {0}: {1}'.format(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
        )

        Goal.register(self._LLAMA_NAME, self._LLAMA_DESC)
        self.assert_console_output(
            self._INSTALLED_HEADER,
            '  {0}: {1}'.format(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
            '  {0}: {1}'.format(self._LLAMA_NAME, self._LLAMA_DESC),
        )

        Goal.register(self._ALPACA_NAME, description='')
        self.assert_console_output(
            self._INSTALLED_HEADER,
            '  {0}: {1}'.format(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
            '  {0}: {1}'.format(self._LLAMA_NAME, self._LLAMA_DESC),
        )
コード例 #49
0
ファイル: test_list_goals.py プロジェクト: Gointer/pants
  def test_list_goals(self):
    Goal.clear()
    self.assert_console_output(self._INSTALLED_HEADER)

    Goal.register(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC)
    self.assert_console_output(
      self._INSTALLED_HEADER,
      '  {0}: {1}'.format(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
    )

    Goal.register(self._LLAMA_NAME, self._LLAMA_DESC)
    self.assert_console_output(
      self._INSTALLED_HEADER,
      '  {0}: {1}'.format(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
      '  {0}: {1}'.format(self._LLAMA_NAME, self._LLAMA_DESC),
    )

    Goal.register(self._ALPACA_NAME, description='')
    self.assert_console_output(
      self._INSTALLED_HEADER,
      '  {0}: {1}'.format(self._LIST_GOALS_NAME, self._LIST_GOALS_DESC),
      '  {0}: {1}'.format(self._LLAMA_NAME, self._LLAMA_DESC),
    )
コード例 #50
0
 def tearDown(self):
   Goal.clear()
コード例 #51
0
ファイル: test_goal.py プロジェクト: sheltowt/pants
 def tearDown(self):
   super(GoalTest, self).tearDown()
   Goal.clear()
コード例 #52
0
    def tearDown(self):
        Goal.clear()

        super(EngineTestBase, self).tearDown()
コード例 #53
0
 def tearDown(self):
   Goal.clear()
コード例 #54
0
ファイル: base_engine_test.py プロジェクト: jduan/pants
    def tearDown(self):
        Goal.clear()

        super(EngineTestBase, self).tearDown()