def test_transitive_closure_spec(self): with self.workspace('./BUILD', 'a/BUILD', 'a/b/BUILD') as root_dir: with open(os.path.join(root_dir, './BUILD'), 'w') as build: build.write(dedent(''' fake(name="foo", dependencies=[ 'a', ]) ''')) with open(os.path.join(root_dir, 'a/BUILD'), 'w') as build: build.write(dedent(''' fake(name="a", dependencies=[ 'a/b:bat', ]) ''')) with open(os.path.join(root_dir, 'a/b/BUILD'), 'w') as build: build.write(dedent(''' fake(name="bat") ''')) build_configuration = BuildConfiguration() build_configuration.register_target_alias('fake', Target) parser = BuildFileParser(build_configuration, root_dir=root_dir) build_graph = BuildGraph(self.address_mapper) parser.inject_spec_closure_into_build_graph(':foo', build_graph) self.assertEqual(len(build_graph.dependencies_of(SyntheticAddress.parse(':foo'))), 1)
def test_transitive_closure_spec(self): with self.workspace('./BUILD', 'a/BUILD', 'a/b/BUILD') as root_dir: with open(os.path.join(root_dir, './BUILD'), 'w') as build: build.write( dedent(''' fake(name="foo", dependencies=[ 'a', ]) ''')) with open(os.path.join(root_dir, 'a/BUILD'), 'w') as build: build.write( dedent(''' fake(name="a", dependencies=[ 'a/b:bat', ]) ''')) with open(os.path.join(root_dir, 'a/b/BUILD'), 'w') as build: build.write(dedent(''' fake(name="bat") ''')) build_configuration = BuildConfiguration() build_configuration.register_target_alias('fake', Target) parser = BuildFileParser(build_configuration, root_dir=root_dir) build_graph = BuildGraph(self.address_mapper) parser.inject_spec_closure_into_build_graph(':foo', build_graph) self.assertEqual( len(build_graph.dependencies_of( SyntheticAddress.parse(':foo'))), 1)
def test_transitive_closure_spec(self): class FakeTarget(Target): def __init__(self, *args, **kwargs): super(FakeTarget, self).__init__(*args, payload=None, **kwargs) with self.workspace('./BUILD', 'a/BUILD', 'a/b/BUILD') as root_dir: with open(os.path.join(root_dir, './BUILD'), 'w') as build: build.write(dedent(''' fake(name="foo", dependencies=[ 'a', ]) ''')) with open(os.path.join(root_dir, 'a/BUILD'), 'w') as build: build.write(dedent(''' fake(name="a", dependencies=[ 'a/b:bat', ]) ''')) with open(os.path.join(root_dir, 'a/b/BUILD'), 'w') as build: build.write(dedent(''' fake(name="bat") ''')) parser = BuildFileParser(root_dir=root_dir, exposed_objects={}, path_relative_utils={}, target_alias_map={'fake': FakeTarget}) build_graph = BuildGraph() parser.inject_spec_closure_into_build_graph(':foo', build_graph) self.assertEqual(len(build_graph.dependencies_of(SyntheticAddress(':foo'))), 1)
def test_transitive_closure_spec(self): class FakeTarget(Target): def __init__(self, *args, **kwargs): super(FakeTarget, self).__init__(*args, payload=None, **kwargs) with self.workspace('./BUILD', 'a/BUILD', 'a/b/BUILD') as root_dir: with open(os.path.join(root_dir, './BUILD'), 'w') as build: build.write( dedent(''' fake(name="foo", dependencies=[ 'a', ]) ''')) with open(os.path.join(root_dir, 'a/BUILD'), 'w') as build: build.write( dedent(''' fake(name="a", dependencies=[ 'a/b:bat', ]) ''')) with open(os.path.join(root_dir, 'a/b/BUILD'), 'w') as build: build.write(dedent(''' fake(name="bat") ''')) parser = BuildFileParser(root_dir=root_dir, exposed_objects={}, path_relative_utils={}, target_alias_map={'fake': FakeTarget}) build_graph = BuildGraph() parser.inject_spec_closure_into_build_graph(':foo', build_graph) self.assertEqual( len(build_graph.dependencies_of(SyntheticAddress(':foo'))), 1)