def assert_bfa_resolved(address: Address) -> None: expected_bfa = BuildFileAddress(rel_path="helloworld/BUILD.ext", address=address) bfa = self.request_single_product(BuildFileAddress, Params(address, bootstrapper)) assert bfa == expected_bfa bfas = self.request_single_product( BuildFileAddresses, Params(Addresses([address]), bootstrapper)) assert bfas == BuildFileAddresses([bfa])
def test_build_file_address(self) -> None: self.create_file("helloworld/BUILD.ext", "mock_tgt()") addr = Address("helloworld") expected_bfa = BuildFileAddress(rel_path="helloworld/BUILD.ext", address=addr) bfa = self.request_single_product(BuildFileAddress, addr) assert bfa == expected_bfa bfas = self.request_single_product(BuildFileAddresses, Addresses([addr])) assert bfas == BuildFileAddresses([bfa])
async def find_build_file(address: Address) -> BuildFileAddress: address_family = await Get(AddressFamily, Dir(address.spec_path)) owning_address = address.maybe_convert_to_base_target() if address_family.get_target_adaptor(owning_address) is None: raise _did_you_mean_exception(address_family=address_family, name=owning_address.target_name) bfa = next(build_file_address for build_file_address in address_family.build_file_addresses if build_file_address.address == owning_address) return (bfa if address.is_base_target else BuildFileAddress( rel_path=bfa.rel_path, address=address))
def test_build_file_address_generated_subtarget(self) -> None: self.create_file("helloworld/BUILD.ext", "mock_tgt(name='original')") addr = Address("helloworld", target_name="original", relative_file_path="generated") expected_bfa = BuildFileAddress(rel_path="helloworld/BUILD.ext", address=addr) bfa = self.request_single_product(BuildFileAddress, addr) assert bfa == expected_bfa bfas = self.request_single_product(BuildFileAddresses, Addresses([addr])) assert bfas == BuildFileAddresses([bfa])
async def find_build_file(address: Address) -> BuildFileAddress: address_family = await Get(AddressFamily, AddressFamilyDir(address.spec_path)) owning_address = address.maybe_convert_to_target_generator() if address_family.get_target_adaptor(owning_address) is None: raise ResolveError.did_you_mean( bad_name=owning_address.target_name, known_names=address_family.target_names, namespace=address_family.namespace, ) bfa = next(build_file_address for build_file_address in address_family.build_file_addresses if build_file_address.address == owning_address) return BuildFileAddress( address, bfa.rel_path) if address.is_generated_target else bfa
def assert_bfa_resolved(address: Address) -> None: expected_bfa = BuildFileAddress(rel_path="helloworld/BUILD.ext", address=address) bfa = rule_runner.request(BuildFileAddress, [address]) assert bfa == expected_bfa
def assert_bfa_resolved(address: Address) -> None: expected_bfa = BuildFileAddress(address, "helloworld/BUILD.ext") bfa = rule_runner.request( BuildFileAddress, [BuildFileAddressRequest(address, description_of_origin="tests")]) assert bfa == expected_bfa