예제 #1
0
파일: test_scopes.py 프로젝트: rkstap/pants
 def test_invalid_in_scope_params(self):
   bad_values = ['', (), [], {}, set(), OrderedSet(), 'default', 'runtime', ('compile',)]
   for bad_value in bad_values:
     with self.assertRaises(ValueError):
       Scope('').in_scope(exclude_scopes=bad_value)
     with self.assertRaises(ValueError):
       Scope('').in_scope(include_scopes=bad_value)
예제 #2
0
파일: test_scopes.py 프로젝트: rkstap/pants
 def test_scope_inclusion(self):
   self.assertTrue(Scope('').in_scope())
   self.assertTrue(Scopes.DEFAULT.in_scope(include_scopes=None))
   self.assertTrue(Scopes.RUNTIME.in_scope(include_scopes=None))
   self.assertTrue(Scope('runtime test').in_scope(include_scopes=Scopes.TEST))
   self.assertFalse(Scope('').in_scope(include_scopes=Scopes.COMPILE))
   self.assertFalse(Scopes.RUNTIME.in_scope(include_scopes=Scopes.COMPILE))
예제 #3
0
    def test_default_parsing(self):
        equivalent_defaults = [
            (),
            None,
            "",
            "default",
            "DEFAULT",
            Scopes.DEFAULT,
            [None],
            (Scopes.DEFAULT),
            "default ",
        ]

        expected = Scope(Scopes.DEFAULT)
        for i, scope in enumerate(equivalent_defaults):
            received = Scope(scope)
            self.assertEqual(
                expected,
                received,
                "Expected scope {i}. {received} == {expected}".format(
                    i=i,
                    received=received,
                    expected=expected,
                ),
            )
예제 #4
0
 def test_invalid_in_scope_params(self):
     bad_values = [
         "", (), [], {},
         set(),
         OrderedSet(), "default", "runtime", ("compile", )
     ]
     for bad_value in bad_values:
         with self.assertRaises(ValueError):
             Scope("").in_scope(exclude_scopes=bad_value)
         with self.assertRaises(ValueError):
             Scope("").in_scope(include_scopes=bad_value)
예제 #5
0
파일: test_scopes.py 프로젝트: rkstap/pants
  def test_default_parsing(self):
    equivalent_defaults = [
      (), None, '', 'default', 'DEFAULT', Scopes.DEFAULT, [None], (Scopes.DEFAULT), 'default ',
    ]

    expected = Scope(Scopes.DEFAULT)
    for i, scope in enumerate(equivalent_defaults):
      received = Scope(scope)
      self.assertEquals(expected, received, 'Expected scope {i}. {received} == {expected}'.format(
        i=i,
        received=received,
        expected=expected,
      ))
예제 #6
0
    def get(self, context):
        """Return the indexable targets in the given context.

    Computes them lazily from the given context.  They are then fixed for the duration
    of the run, even if this method is called again with a different context.
    """
        if self.get_options().recursive:
            requested_targets = context.targets(
                exclude_scopes=Scope(self.get_options().exclude_scopes))
        else:
            requested_targets = list(context.target_roots)

        expanded_targets = list(requested_targets)
        # We want to act on targets derived from the specified, e.g., if acting on a binary
        # jar_library we actually want to act on the derived java_library wrapping the decompiled
        # sources.
        for t in requested_targets:
            expanded_targets.extend(
                context.build_graph.get_all_derivatives(t.address))

        return tuple(
            sorted([
                t for t in expanded_targets
                if isinstance(t, JvmTarget) and t.has_sources('.java')
            ],
                   key=lambda t: t.address.spec))
예제 #7
0
파일: target.py 프로젝트: lgirault/pants
  def __init__(self, name, address, build_graph, type_alias=None, payload=None, tags=None,
               description=None, no_cache=False, scope=None, _transitive=None,
               **kwargs):
    """
    :API: public

    :param string name: The name of this target, which combined with this build file defines the
                        target address.
    :param dependencies: Target address specs of other targets that this target depends on.
    :type dependencies: list of strings
    :param address: The Address that maps to this Target in the BuildGraph.
    :type address: :class:`pants.build_graph.address.Address`
    :param build_graph: The BuildGraph that this Target lives within.
    :type build_graph: :class:`pants.build_graph.build_graph.BuildGraph`
    :param string type_alias: The type_alias used to construct this target, may be None if
                              constructed directly.
    :param payload: The configuration encapsulated by this target.  Also in charge of most
                    fingerprinting details.
    :type payload: :class:`pants.base.payload.Payload`
    :param tags: Arbitrary string tags that describe this target. Usable by downstream/custom tasks
                 for reasoning about the build graph. NOT included in payloads and thus not used in
                 fingerprinting, thus not suitable for anything that affects how a particular
                 target is built.
    :type tags: :class:`collections.Iterable` of strings
    :param no_cache: If True, results for this target should not be stored in the artifact cache.
    :param string description: Human-readable description of this target.
    :param string scope: The scope of this target, used to determine its inclusion on the classpath
      (and possibly more things in the future). See :class:`pants.build_graph.target_scopes.Scopes`.
      A value of None, '', or 'default' results in the default scope, which is included everywhere.
    """
    # NB: dependencies are in the pydoc above as a BUILD dictionary hack only; implementation hides
    # the dependencies via TargetAddressable.

    self.payload = payload or Payload()
    self._scope = Scope(scope)
    self.payload.add_field('scope_string', PrimitiveField(str(scope)))
    self.payload.add_field('transitive',
                           PrimitiveField(True if _transitive is None else _transitive))
    self.payload.freeze()
    self.name = name
    self.address = address
    self._build_graph = weakref.proxy(build_graph)
    self._type_alias = type_alias
    self._tags = set(tags or []).union(self.TagAssignments.tags_for(address.spec))
    self.description = description

    self._cached_fingerprint_map = {}
    self._cached_all_transitive_fingerprint_map = {}
    self._cached_direct_transitive_fingerprint_map = {}
    self._cached_strict_dependencies_map = {}
    self._cached_exports_addresses = None
    self._no_cache = no_cache
    if kwargs:
      self.Arguments.check(self, kwargs)
예제 #8
0
파일: test_scopes.py 프로젝트: rkstap/pants
 def test_scope_equality(self):
   self.assertEquals(Scope('a b'), Scope('b') + Scope('a'))
예제 #9
0
파일: test_scopes.py 프로젝트: rkstap/pants
 def test_mixed_case(self):
   self.assertEquals(Scope('RUNTIME'), Scope('runtime'))
   self.assertNotEquals(Scope('RUNTIME'), Scope('COMPILE'))
예제 #10
0
 def test_scope_equality(self):
     self.assertEqual(Scope("a b"), Scope("b") + Scope("a"))
예제 #11
0
 def test_mixed_case(self):
     self.assertEqual(Scope("RUNTIME"), Scope("runtime"))
     self.assertNotEqual(Scope("RUNTIME"), Scope("COMPILE"))