Esempio n. 1
0
  def setUp(self):
    # Set up a scheduler that supports address mapping.
    symbol_table = TargetTable()
    address_mapper = AddressMapper(parser=JsonParser(symbol_table),
                                   build_patterns=('*.BUILD.json',))
    rules = create_fs_rules() + create_graph_rules(address_mapper, symbol_table)
    # TODO handle updating the rule graph when passed unexpected root selectors.
    # Adding the following task allows us to get around the fact that SelectDependencies
    # requests are not currently supported.
    rules.append(TaskRule(UnhydratedStructs,
                          [SelectDependencies(UnhydratedStruct,
                                              BuildFileAddresses,
                                              field_types=(Address,),
                                              field='addresses')],
                          UnhydratedStructs))

    project_tree = self.mk_fs_tree(os.path.join(os.path.dirname(__file__), 'examples/mapper_test'))
    self.build_root = project_tree.build_root
    self.scheduler = self.mk_scheduler(rules=rules, project_tree=project_tree)

    self.a_b = Address.parse('a/b')
    self.a_b_target = Target(name='b',
                             dependencies=['//d:e'],
                             configurations=['//a', Struct(embedded='yes')],
                             type_alias='target')
Esempio n. 2
0
    def test_full_graph_for_planner_example(self):
        symbol_table = TargetTable()
        address_mapper = AddressMapper(JsonParser(symbol_table),
                                       '*.BUILD.json')
        rules = create_graph_rules(address_mapper,
                                   symbol_table) + create_fs_rules()

        fullgraph_str = self.create_full_graph(rules)

        print('---diagnostic------')
        print(fullgraph_str)
        print('/---diagnostic------')

        in_root_rules = False
        in_all_rules = False
        all_rules = []
        root_rule_lines = []
        for line in fullgraph_str.splitlines():
            if line.startswith('  // root subject types:'):
                pass
            elif line.startswith('  // root entries'):
                in_root_rules = True
            elif line.startswith('  // internal entries'):
                in_all_rules = True
            elif in_all_rules:
                all_rules.append(line)
            elif in_root_rules:
                root_rule_lines.append(line)
            else:
                pass

        self.assertTrue(6 < len(all_rules))
        self.assertTrue(12 < len(root_rule_lines))  # 2 lines per entry
Esempio n. 3
0
  def setUp(self):
    # Set up a scheduler that supports address mapping.
    symbol_table = TargetTable()
    address_mapper = AddressMapper(parser=JsonParser(symbol_table),
                                   build_patterns=('*.BUILD.json',))

    # We add the `unhydrated_structs` rule because it is otherwise not used in the core engine.
    rules = [
        unhydrated_structs
      ] + create_fs_rules() + create_graph_rules(address_mapper, symbol_table)

    project_tree = self.mk_fs_tree(os.path.join(os.path.dirname(__file__), 'examples/mapper_test'))
    self.build_root = project_tree.build_root
    self.scheduler = self.mk_scheduler(rules=rules, project_tree=project_tree)

    self.a_b = Address.parse('a/b')
    self.a_b_target = Target(name='b',
                             dependencies=['//d:e'],
                             configurations=['//a', Struct(embedded='yes')],
                             type_alias='target')