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()));
}
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));
}
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()));
}
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"));
}
Aggregations