use of com.facebook.buck.shell.ShBinary in project buck by facebook.
the class PythonBinaryDescriptionTest method pexToolBuilderAddedToRuntimeDeps.
@Test
public void pexToolBuilderAddedToRuntimeDeps() throws Exception {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraphFactory.newInstance(), new DefaultTargetNodeToBuildRuleTransformer());
ShBinary pyTool = new ShBinaryBuilder(BuildTargetFactory.newInstance("//:py_tool")).setMain(new FakeSourcePath("run.sh")).build(resolver);
PythonBuckConfig config = new PythonBuckConfig(FakeBuckConfig.builder().build(), new AlwaysFoundExecutableFinder()) {
@Override
public Optional<Tool> getPexExecutor(BuildRuleResolver resolver) {
return Optional.of(pyTool.getExecutableCommand());
}
};
PythonBinary standaloneBinary = new PythonBinaryBuilder(BuildTargetFactory.newInstance("//:bin"), config, PythonTestUtils.PYTHON_PLATFORMS, CxxPlatformUtils.DEFAULT_PLATFORM, CxxPlatformUtils.DEFAULT_PLATFORMS).setMainModule("hello").setPackageStyle(PythonBuckConfig.PackageStyle.STANDALONE).build(resolver);
assertThat(standaloneBinary.getRuntimeDeps().collect(MoreCollectors.toImmutableSet()), Matchers.hasItem(pyTool.getBuildTarget()));
}
use of com.facebook.buck.shell.ShBinary in project buck by facebook.
the class PythonTestDescriptionTest method pexExecutorIsAddedToTestRuntimeDeps.
@Test
public void pexExecutorIsAddedToTestRuntimeDeps() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
ShBinaryBuilder pexExecutorBuilder = new ShBinaryBuilder(BuildTargetFactory.newInstance("//:pex_executor")).setMain(new FakeSourcePath("run.sh"));
PythonTestBuilder builder = new PythonTestBuilder(BuildTargetFactory.newInstance("//:bin"), new PythonBuckConfig(FakeBuckConfig.builder().setSections(ImmutableMap.of("python", ImmutableMap.of("path_to_pex_executer", pexExecutorBuilder.getTarget().toString()))).build(), new AlwaysFoundExecutableFinder()), PythonTestUtils.PYTHON_PLATFORMS, CxxPlatformUtils.DEFAULT_PLATFORM, CxxPlatformUtils.DEFAULT_PLATFORMS);
builder.setPackageStyle(PythonBuckConfig.PackageStyle.STANDALONE);
TargetGraph targetGraph = TargetGraphFactory.newInstance(pexExecutorBuilder.build(), builder.build());
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
ShBinary pexExecutor = pexExecutorBuilder.build(resolver);
PythonTest binary = builder.build(resolver, filesystem, targetGraph);
assertThat(binary.getRuntimeDeps().collect(MoreCollectors.toImmutableSet()), Matchers.hasItem(pexExecutor.getBuildTarget()));
}
Aggregations