Search in sources :

Example 1 with ShBinary

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()));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) ShBinary(com.facebook.buck.shell.ShBinary) ShBinaryBuilder(com.facebook.buck.shell.ShBinaryBuilder) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) AlwaysFoundExecutableFinder(com.facebook.buck.io.AlwaysFoundExecutableFinder) HashedFileTool(com.facebook.buck.rules.HashedFileTool) Tool(com.facebook.buck.rules.Tool) CommandTool(com.facebook.buck.rules.CommandTool) Test(org.junit.Test)

Example 2 with ShBinary

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()));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) ShBinary(com.facebook.buck.shell.ShBinary) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) AllExistingProjectFilesystem(com.facebook.buck.testutil.AllExistingProjectFilesystem) ShBinaryBuilder(com.facebook.buck.shell.ShBinaryBuilder) TargetGraph(com.facebook.buck.rules.TargetGraph) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) AlwaysFoundExecutableFinder(com.facebook.buck.io.AlwaysFoundExecutableFinder) Test(org.junit.Test)

Aggregations

AlwaysFoundExecutableFinder (com.facebook.buck.io.AlwaysFoundExecutableFinder)2 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)2 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)2 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)2 ShBinary (com.facebook.buck.shell.ShBinary)2 ShBinaryBuilder (com.facebook.buck.shell.ShBinaryBuilder)2 Test (org.junit.Test)2 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)1 CommandTool (com.facebook.buck.rules.CommandTool)1 HashedFileTool (com.facebook.buck.rules.HashedFileTool)1 TargetGraph (com.facebook.buck.rules.TargetGraph)1 Tool (com.facebook.buck.rules.Tool)1 AllExistingProjectFilesystem (com.facebook.buck.testutil.AllExistingProjectFilesystem)1 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)1