def test_normal_resolution(self) -> None: self.add_to_build_file("src/smalltalk", "smalltalk()") addr = Address.parse("src/smalltalk") deps = Addresses([Address.parse("//:dep1"), Address.parse("//:dep2")]) deps_field = Dependencies(deps, address=addr) assert self.request_single_product(Addresses, DependenciesRequest(deps_field)) == deps # Also test that we handle no dependencies. empty_deps_field = Dependencies(None, address=addr) assert self.request_single_product( Addresses, DependenciesRequest(empty_deps_field) ) == Addresses([])
def test_dependency_inference(self) -> None: self.add_to_build_file( "", dedent("""\ smalltalk(name='inferred1') smalltalk(name='inferred2') smalltalk(name='inferred3') smalltalk(name='provided') """), ) self.create_file("demo/f1.st", "//:inferred1\n//:inferred2\n") self.create_file("demo/f2.st", "//:inferred3\n") self.add_to_build_file( "demo", "smalltalk(sources=['*.st'], dependencies=['//:provided'])") deps_field = Dependencies([Address.parse("//:provided")], address=Address.parse("demo")) result = self.request_single_product( Addresses, Params( DependenciesRequest(deps_field), create_options_bootstrapper(args=["--dependency-inference"]), ), ) assert result == Addresses( sorted( Address.parse(addr) for addr in [ "//:inferred1", "//:inferred2", "//:inferred3", "//:provided" ]))
def assert_invalid_type(raw_value: Any) -> None: with pytest.raises(InvalidFieldTypeException): Sources(raw_value, address=addr) with pytest.raises(InvalidFieldTypeException): Dependencies(raw_value, address=addr)
def assert_flexible_constructor(raw_value: Iterable[str]) -> None: assert Sources(raw_value, address=addr).sanitized_raw_value == tuple(raw_value) assert Dependencies( raw_value, address=addr).sanitized_raw_value == tuple(raw_value)