use of com.facebook.buck.step.Step in project buck by facebook.
the class DefaultJavaLibraryTest method testWhenNoJavacIsProvidedAJavacInMemoryStepIsAdded.
@Test
public void testWhenNoJavacIsProvidedAJavacInMemoryStepIsAdded() throws Exception {
BuildTarget libraryOneTarget = BuildTargetFactory.newInstance("//:libone");
BuildRule rule = JavaLibraryBuilder.createBuilder(libraryOneTarget).addSrc(Paths.get("java/src/com/libone/Bar.java")).build(ruleResolver);
DefaultJavaLibrary buildRule = (DefaultJavaLibrary) rule;
ImmutableList<Step> steps = buildRule.getBuildSteps(FakeBuildContext.withSourcePathResolver(new SourcePathResolver(new SourcePathRuleFinder(ruleResolver))), new FakeBuildableContext());
assertEquals(10, steps.size());
assertTrue(((JavacStep) steps.get(6)).getJavac() instanceof Jsr199Javac);
}
use of com.facebook.buck.step.Step in project buck by facebook.
the class JavaSourceJarTest method shouldOnlyIncludePathBasedSources.
@Test
public void shouldOnlyIncludePathBasedSources() {
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
SourcePath fileBased = new FakeSourcePath("some/path/File.java");
SourcePath ruleBased = new DefaultBuildTargetSourcePath(BuildTargetFactory.newInstance("//cheese:cake"));
JavaPackageFinder finderStub = createNiceMock(JavaPackageFinder.class);
expect(finderStub.findJavaPackageFolder((Path) anyObject())).andStubReturn(Paths.get("cheese"));
expect(finderStub.findJavaPackage((Path) anyObject())).andStubReturn("cheese");
// No need to verify. It's a stub. I don't care about the interactions.
EasyMock.replay(finderStub);
JavaSourceJar rule = new JavaSourceJar(new FakeBuildRuleParamsBuilder("//example:target").build(), ImmutableSortedSet.of(fileBased, ruleBased), Optional.empty());
BuildContext buildContext = BuildContext.builder().setActionGraph(new ActionGraph(ImmutableList.of())).setSourcePathResolver(pathResolver).setJavaPackageFinder(finderStub).setEventBus(BuckEventBusFactory.newInstance()).build();
ImmutableList<Step> steps = rule.getBuildSteps(buildContext, new FakeBuildableContext());
// There should be a CopyStep per file being copied. Count 'em.
int copyStepsCount = FluentIterable.from(steps).filter(CopyStep.class::isInstance).size();
assertEquals(1, copyStepsCount);
}
use of com.facebook.buck.step.Step in project buck by facebook.
the class AbstractExecutionStepTest method testDescriptionGetters.
@Test
public void testDescriptionGetters() {
String description = "How I describe myself.";
Step step = new AbstractExecutionStep(description) {
@Override
public StepExecutionResult execute(ExecutionContext context) {
return StepExecutionResult.SUCCESS;
}
};
ExecutionContext context = TestExecutionContext.newInstance();
assertEquals(description, step.getShortName());
assertEquals(description, step.getDescription(context));
}
use of com.facebook.buck.step.Step in project buck by facebook.
the class SymlinkTreeTest method testSymlinkTreeBuildSteps.
@Test
public void testSymlinkTreeBuildSteps() throws IOException {
// Create the fake build contexts.
BuildContext buildContext = FakeBuildContext.withSourcePathResolver(pathResolver);
FakeBuildableContext buildableContext = new FakeBuildableContext();
ProjectFilesystem filesystem = FakeProjectFilesystem.createJavaOnlyFilesystem();
// Verify the build steps are as expected.
ImmutableList<Step> expectedBuildSteps = ImmutableList.of(new MakeCleanDirectoryStep(filesystem, outputPath), new SymlinkTreeStep(filesystem, outputPath, pathResolver.getMappedPaths(links)));
ImmutableList<Step> actualBuildSteps = symlinkTreeBuildRule.getBuildSteps(buildContext, buildableContext);
assertEquals(expectedBuildSteps, actualBuildSteps.subList(1, actualBuildSteps.size()));
}
use of com.facebook.buck.step.Step in project buck by facebook.
the class ExportFileTest method shouldSetSrcAndOutToNameParameterIfNeitherAreSet.
@Test
public void shouldSetSrcAndOutToNameParameterIfNeitherAreSet() throws Exception {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
ExportFile exportFile = ExportFileBuilder.newExportFileBuilder(target).build(resolver, projectFilesystem);
List<Step> steps = exportFile.getBuildSteps(FakeBuildContext.withSourcePathResolver(pathResolver), new FakeBuildableContext());
MoreAsserts.assertSteps("The output directory should be created and then the file should be copied there.", ImmutableList.of("mkdir -p " + projectFilesystem.resolve("buck-out/gen"), "rm -f -r " + projectFilesystem.resolve("buck-out/gen/example.html"), "cp " + projectFilesystem.resolve("example.html") + " " + Paths.get("buck-out/gen/example.html")), steps, TestExecutionContext.newInstance());
assertEquals(projectFilesystem.getBuckPaths().getGenDir().resolve("example.html"), pathResolver.getRelativePath(exportFile.getSourcePathToOutput()));
}
Aggregations