def do_test_codegen_simple(self, scheduler): def address(name): return Address(spec_path='graph_test', target_name=name) resolved_java1 = self.resolve(scheduler, address('java1')) nonstrict = ApacheThriftConfiguration(address=address('nonstrict'), version='0.9.2', strict=False, lang='java') public = Struct(address=address('public'), url='https://oss.sonatype.org/#stagingRepositories') thrift1 = Target(address=address('thrift1')) thrift2 = Target(address=address('thrift2'), dependencies=[thrift1]) expected_java1 = Target(address=address('java1'), configurations=[ ApacheThriftConfiguration(version='0.9.2', strict=True, lang='java'), nonstrict, PublishConfiguration( default_repo=public, repos={ 'jake': Struct(url='https://dl.bintray.com/pantsbuild/maven'), 'jane': public } ) ], dependencies=[thrift2]) self.assertEqual(expected_java1, resolved_java1)
def test_walk_descendants(self): self.assertEqual({self.addr('//:root'): Struct(name='root', type_alias='struct'), self.addr('a/b:b'): self.a_b_target, self.addr('a/d:d'): Target(name='d', type_alias='target'), self.addr('a/d/e:e'): Target(name='e', type_alias='target'), self.addr('a/d/e:e-prime'): Struct(name='e-prime', type_alias='struct')}, self.resolve_multi(DescendantAddresses('')))
def test_walk_descendants_rel_path(self): self.assertEqual( { self.addr('a/d:d'): Target(name='d', type_alias='target'), self.addr('a/d/e:e'): Target(name='e', type_alias='target'), self.addr('a/d/e:e-prime'): Struct(name='e-prime', type_alias='struct') }, self.resolve_multi(DescendantAddresses('a/d')))
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')
def setUp(self): # Set up a scheduler that supports address mapping. address_mapper = AddressMapper(parser=JsonParser(TARGET_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) 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(address=self.a_b, dependencies=['//a/d/e'], configurations=['//a/d/e', Struct(embedded='yes')], type_alias='target')
def do_test_codegen_simple(self, scheduler): def address(name): return Address(spec_path='graph_test', target_name=name) java1_address = address('java1') resolved_java1 = self.resolve(scheduler, java1_address) nonstrict_address = address('nonstrict') expected_nonstrict = ApacheThriftConfiguration(address=nonstrict_address, version='0.9.2', strict=False, lang='java') public_address = address('public') expected_public = Struct(address=public_address, url='https://oss.sonatype.org/#stagingRepositories') thrift2_address = address('thrift2') expected_java1 = Target(address=java1_address, sources={}, configurations=[ PublishConfiguration( default_repo=expected_public, repos={ 'jake': Struct(url='https://dl.bintray.com/pantsbuild/maven'), 'jane': expected_public } ), expected_nonstrict, ApacheThriftConfiguration( version='0.9.2', strict=True, lang='java', dependencies=[thrift2_address] ), ]) self.assertEqual(expected_java1, resolved_java1) resolved_nonstrict = self.resolve(scheduler, nonstrict_address) self.assertEqual(expected_nonstrict, resolved_nonstrict) self.assertEqual(expected_nonstrict, expected_java1.configurations[1]) self.assertEquals(resolved_java1.configurations[1], resolved_nonstrict) resolved_public = self.resolve(scheduler, public_address) self.assertEqual(expected_public, resolved_public) self.assertEqual(expected_public, expected_java1.configurations[0].default_repo) self.assertEqual(expected_public, expected_java1.configurations[0].repos['jane']) self.assertEquals(resolved_java1.configurations[0].default_repo, resolved_public) self.assertEquals(resolved_java1.configurations[0].repos['jane'], resolved_public) # NB: `dependencies` lists must be explicitly requested by tasks, so we expect an Address. thrift1_address = address('thrift1') expected_thrift2 = Target(address=thrift2_address, dependencies=[thrift1_address]) resolved_thrift2 = self.resolve(scheduler, thrift2_address) self.assertEqual(expected_thrift2, resolved_thrift2) expected_thrift1 = Target(address=thrift1_address) resolved_thrift1 = self.resolve(scheduler, thrift1_address) self.assertEqual(expected_thrift1, resolved_thrift1)
def test_walk_descendants_path_excludes(self): self.assertEqual( { self.addr('//:root'): Struct(name='root'), self.addr('a/d:d'): Target(name='d') }, self.resolve_multi(DescendantAddresses('')))