示例#1
0
 def roots():
   for subject in subjects:
     for product in products:
       if type(subject) is Address:
         yield SelectNode(subject, product, None, None)
       elif type(subject) in [SingleAddress, SiblingAddresses, DescendantAddresses]:
         yield DependenciesNode(subject, product, None, Addresses, None)
       elif type(subject) is PathGlobs:
         yield DependenciesNode(subject, product, None, Paths, None)
       else:
         raise ValueError('Unsupported root subject type: {}'.format(subject))
示例#2
0
 def roots(self, products_by_goal):
   """Determine the root Nodes for the products and subjects selected by the goals and specs."""
   for goal_name in self.goals:
     product = products_by_goal[goal_name]
     for subject in self._subjects:
       if type(subject) is SingleAddress:
         subject, variants = parse_variants(Address.parse(subject.to_spec_string()))
         yield SelectNode(subject, product, variants, None)
       elif type(subject) in [SiblingAddresses, DescendantAddresses]:
         yield DependenciesNode(subject, product, None, Addresses, None)
       elif type(subject) is PathGlobs:
         yield DependenciesNode(subject, product, None, Paths, None)
       else:
         raise ValueError('Unsupported root subject type: {}'.format(subject))
示例#3
0
    def select_node(self, selector, subject, variants):
        """Constructs a Node for the given Selector and the given Subject/Variants.

    This method is decoupled from Selector classes in order to allow the `selector` package to not
    need a dependency on the `nodes` package.
    """
        selector_type = type(selector)
        if selector_type is Select:
            return SelectNode(subject, selector.product, variants, None)
        elif selector_type is SelectVariant:
            return SelectNode(subject, selector.product, variants,
                              selector.variant_key)
        elif selector_type is SelectDependencies:
            return DependenciesNode(subject, selector.product, variants,
                                    selector.deps_product, selector.field)
        elif selector_type is SelectProjection:
            return ProjectionNode(subject, selector.product, variants,
                                  selector.projected_subject, selector.fields,
                                  selector.input_product)
        elif selector_type is SelectLiteral:
            # NB: Intentionally ignores subject parameter to provide a literal subject.
            return SelectNode(selector.subject, selector.product, variants,
                              None)
        else:
            raise ValueError('Unrecognized Selector type "{}" for: {}'.format(
                selector_type, selector))
示例#4
0
    def test_sibling_specs(self):
        """Test that sibling Addresses are parsed in the 3rdparty/jvm directory."""
        spec = self.spec_parser.parse_spec('3rdparty/jvm:')
        build_request = self.request_specs(['list'], spec)
        walk = self.build_and_walk(build_request)

        # Validate the root.
        root, root_state = walk[0][0]
        root_value = root_state.value
        self.assertEqual(
            DependenciesNode(spec, Address, None, Addresses, None), root)
        self.assertEqual(list, type(root_value))

        # Confirm that an expected address is in the list.
        self.assertIn(self.guava, root_value)
        # And that an subdirectory address is not.
        self.assertNotIn(self.managed_guava, root_value)
示例#5
0
    def test_descendant_specs(self):
        """Test that Addresses are produced via recursive globs of the 3rdparty/jvm directory."""
        spec = self.spec_parser.parse_spec('3rdparty/jvm::')
        build_request = self.request_specs(['list'], spec)
        walk = self.build_and_walk(build_request)

        # Validate the root.
        root, root_state = walk[0][0]
        root_value = root_state.value
        self.assertEqual(
            DependenciesNode(spec, Address, None, Addresses, None), root)
        self.assertEqual(list, type(root_value))

        # Confirm that a few expected addresses are in the list.
        self.assertIn(self.guava, root_value)
        self.assertIn(self.managed_guava, root_value)
        self.assertIn(self.managed_resolve_latest, root_value)
示例#6
0
 def construct_node(self, subject, variants):
     return DependenciesNode(subject, self.product, variants,
                             self.deps_product, self.field)