Search in sources :

Example 36 with AlwaysFoundExecutableFinder

use of com.facebook.buck.io.AlwaysFoundExecutableFinder 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 37 with AlwaysFoundExecutableFinder

use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.

the class PythonTestDescriptionTest method pexBuilderAddedToParseTimeDeps.

@Test
public void pexBuilderAddedToParseTimeDeps() {
    final BuildTarget pexBuilder = BuildTargetFactory.newInstance("//:pex_builder");
    PythonBuckConfig config = new PythonBuckConfig(FakeBuckConfig.builder().build(), new AlwaysFoundExecutableFinder()) {

        @Override
        public Optional<BuildTarget> getPexExecutorTarget() {
            return Optional.of(pexBuilder);
        }
    };
    PythonTestBuilder inplaceBinary = new PythonTestBuilder(BuildTargetFactory.newInstance("//:bin"), config, PythonTestUtils.PYTHON_PLATFORMS, CxxPlatformUtils.DEFAULT_PLATFORM, CxxPlatformUtils.DEFAULT_PLATFORMS).setPackageStyle(PythonBuckConfig.PackageStyle.INPLACE);
    assertThat(inplaceBinary.findImplicitDeps(), Matchers.not(Matchers.hasItem(pexBuilder)));
    PythonTestBuilder standaloneBinary = new PythonTestBuilder(BuildTargetFactory.newInstance("//:bin"), config, PythonTestUtils.PYTHON_PLATFORMS, CxxPlatformUtils.DEFAULT_PLATFORM, CxxPlatformUtils.DEFAULT_PLATFORMS).setPackageStyle(PythonBuckConfig.PackageStyle.STANDALONE);
    assertThat(standaloneBinary.findImplicitDeps(), Matchers.hasItem(pexBuilder));
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) AlwaysFoundExecutableFinder(com.facebook.buck.io.AlwaysFoundExecutableFinder) Test(org.junit.Test)

Example 38 with AlwaysFoundExecutableFinder

use of com.facebook.buck.io.AlwaysFoundExecutableFinder 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)

Example 39 with AlwaysFoundExecutableFinder

use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.

the class PythonBinaryDescriptionTest method extensionConfig.

@Test
public void extensionConfig() throws Exception {
    BuildTarget target = BuildTargetFactory.newInstance("//foo:bin");
    BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
    PythonBuckConfig config = new PythonBuckConfig(FakeBuckConfig.builder().setSections(ImmutableMap.of("python", ImmutableMap.of("pex_extension", ".different_extension"))).build(), new AlwaysFoundExecutableFinder());
    PythonBinaryBuilder builder = new PythonBinaryBuilder(target, config, PythonTestUtils.PYTHON_PLATFORMS, CxxPlatformUtils.DEFAULT_PLATFORM, CxxPlatformUtils.DEFAULT_PLATFORMS);
    PythonBinary binary = builder.setMainModule("main").build(resolver);
    assertThat(pathResolver.getRelativePath(Preconditions.checkNotNull(binary.getSourcePathToOutput())).toString(), Matchers.endsWith(".different_extension"));
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) AlwaysFoundExecutableFinder(com.facebook.buck.io.AlwaysFoundExecutableFinder) Test(org.junit.Test)

Aggregations

AlwaysFoundExecutableFinder (com.facebook.buck.io.AlwaysFoundExecutableFinder)39 Test (org.junit.Test)37 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)30 Path (java.nio.file.Path)18 DefaultBuildTargetSourcePath (com.facebook.buck.rules.DefaultBuildTargetSourcePath)17 BuildTarget (com.facebook.buck.model.BuildTarget)16 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)14 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)14 TargetGraph (com.facebook.buck.rules.TargetGraph)14 HashMap (java.util.HashMap)12 PrebuiltCxxLibraryBuilder (com.facebook.buck.cxx.PrebuiltCxxLibraryBuilder)9 CxxLibraryBuilder (com.facebook.buck.cxx.CxxLibraryBuilder)8 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)8 XCScheme (com.facebook.buck.apple.xcode.XCScheme)6 PBXTarget (com.facebook.buck.apple.xcode.xcodeproj.PBXTarget)6 AllExistingProjectFilesystem (com.facebook.buck.testutil.AllExistingProjectFilesystem)6 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)6 AppleDependenciesCache (com.facebook.buck.apple.AppleDependenciesCache)5 SourcePath (com.facebook.buck.rules.SourcePath)5 ShBinaryBuilder (com.facebook.buck.shell.ShBinaryBuilder)5