use of com.facebook.buck.shell.ShBinaryBuilder in project buck by facebook.
the class PythonTestDescriptionTest method pexExecutorRuleIsAddedToParseTimeDeps.
@Test
public void pexExecutorRuleIsAddedToParseTimeDeps() throws Exception {
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);
assertThat(builder.build().getExtraDeps(), Matchers.hasItem(pexExecutorBuilder.getTarget()));
}
use of com.facebook.buck.shell.ShBinaryBuilder in project buck by facebook.
the class WorkerMacroArgTest method testWorkerMacroArgConstruction.
@Test
public void testWorkerMacroArgConstruction() throws MacroException, NoSuchBuildTargetException {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
BuildRule shBinaryRule = new ShBinaryBuilder(BuildTargetFactory.newInstance("//:my_exe")).setMain(new FakeSourcePath("bin/exe")).build(resolver);
String startupArgs = "startupargs";
Integer maxWorkers = 5;
WorkerToolBuilder.newWorkerToolBuilder(BuildTargetFactory.newInstance("//:worker_rule")).setExe(shBinaryRule.getBuildTarget()).setArgs(startupArgs).setMaxWorkers(maxWorkers).build(resolver);
MacroHandler macroHandler = new MacroHandler(ImmutableMap.of("worker", new WorkerMacroExpander()));
ProjectFilesystem filesystem = new FakeProjectFilesystem();
BuildTarget target = BuildTargetFactory.newInstance("//:rule");
String jobArgs = "jobargs";
WorkerMacroArg arg = new WorkerMacroArg(macroHandler, target, TestCellBuilder.createCellRoots(filesystem), resolver, "$(worker //:worker_rule) " + jobArgs);
assertThat(arg.getJobArgs(), Matchers.equalTo(jobArgs));
assertThat(arg.getStartupArgs(pathResolver), Matchers.equalTo(startupArgs));
assertThat(arg.getMaxWorkers(), Matchers.equalTo(maxWorkers));
}
use of com.facebook.buck.shell.ShBinaryBuilder in project buck by facebook.
the class PythonBinaryDescriptionTest method pexExecutorRuleIsAddedToParseTimeDeps.
@Test
public void pexExecutorRuleIsAddedToParseTimeDeps() throws Exception {
ShBinaryBuilder pexExecutorBuilder = new ShBinaryBuilder(BuildTargetFactory.newInstance("//:pex_executor")).setMain(new FakeSourcePath("run.sh"));
PythonBinaryBuilder builder = new PythonBinaryBuilder(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.setMainModule("main").setPackageStyle(PythonBuckConfig.PackageStyle.STANDALONE);
assertThat(builder.build().getExtraDeps(), Matchers.hasItem(pexExecutorBuilder.getTarget()));
}
use of com.facebook.buck.shell.ShBinaryBuilder 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.ShBinaryBuilder 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