use of com.facebook.buck.step.Step in project buck by facebook.
the class ArchiveTest method flagsArePropagated.
@Test
public void flagsArePropagated() throws Exception {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
BuildTarget target = BuildTargetFactory.newInstance("//foo:bar");
BuildRuleParams params = new FakeBuildRuleParamsBuilder(target).build();
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
Archive archive = Archive.from(target, params, ruleFinder, DEFAULT_ARCHIVER, ImmutableList.of("-foo"), DEFAULT_RANLIB, ImmutableList.of("-bar"), Archive.Contents.NORMAL, DEFAULT_OUTPUT, ImmutableList.of(new FakeSourcePath("simple.o")));
BuildContext buildContext = BuildContext.builder().from(FakeBuildContext.NOOP_CONTEXT).setSourcePathResolver(pathResolver).build();
ImmutableList<Step> steps = archive.getBuildSteps(buildContext, new FakeBuildableContext());
Step archiveStep = FluentIterable.from(steps).filter(ArchiveStep.class).first().get();
assertThat(archiveStep.getDescription(TestExecutionContext.newInstance()), containsString("-foo"));
Step ranlibStep = FluentIterable.from(steps).filter(RanlibStep.class).first().get();
assertThat(ranlibStep.getDescription(TestExecutionContext.newInstance()), containsString("-bar"));
}
use of com.facebook.buck.step.Step in project buck by facebook.
the class CxxTestDescriptionTest method environmentIsPropagated.
@Test
public void environmentIsPropagated() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
addFramework(resolver, filesystem);
BuildRule someRule = GenruleBuilder.newGenruleBuilder(BuildTargetFactory.newInstance("//:some_rule")).setOut("someRule").build(resolver);
CxxTestBuilder builder = createTestBuilder().setEnv(ImmutableMap.of("TEST", "value $(location //:some_rule)"));
addSandbox(resolver, filesystem, builder.getTarget());
CxxTest cxxTest = builder.build(resolver);
TestRunningOptions options = TestRunningOptions.builder().setTestSelectorList(TestSelectorList.empty()).build();
ImmutableList<Step> steps = cxxTest.runTests(TestExecutionContext.newInstance(), options, pathResolver, TestRule.NOOP_REPORTING_CALLBACK);
CxxTestStep testStep = (CxxTestStep) Iterables.getLast(steps);
assertThat(testStep.getEnv(), Matchers.equalTo(Optional.of(ImmutableMap.of("TEST", "value " + pathResolver.getAbsolutePath(Preconditions.checkNotNull(someRule.getSourcePathToOutput()))))));
}
use of com.facebook.buck.step.Step in project buck by facebook.
the class CxxTestDescriptionTest method testArgsArePropagated.
@Test
public void testArgsArePropagated() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
addFramework(resolver, filesystem);
BuildRule someRule = GenruleBuilder.newGenruleBuilder(BuildTargetFactory.newInstance("//:some_rule")).setOut("someRule").build(resolver);
CxxTestBuilder builder = createTestBuilder().setArgs(ImmutableList.of("value $(location //:some_rule)"));
addSandbox(resolver, filesystem, builder.getTarget());
CxxTest cxxTest = builder.build(resolver);
TestRunningOptions testOptions = TestRunningOptions.builder().setShufflingTests(false).setTestSelectorList(TestSelectorList.empty()).build();
ImmutableList<Step> steps = cxxTest.runTests(TestExecutionContext.newInstance(), testOptions, pathResolver, TestRule.NOOP_REPORTING_CALLBACK);
CxxTestStep testStep = (CxxTestStep) Iterables.getLast(steps);
assertThat(testStep.getCommand(), Matchers.hasItem("value " + pathResolver.getAbsolutePath(Preconditions.checkNotNull(someRule.getSourcePathToOutput()))));
}
use of com.facebook.buck.step.Step in project buck by facebook.
the class CxxPrepareForLinkStepTest method testCreateCxxPrepareForLinkStep.
@Test
public void testCreateCxxPrepareForLinkStep() throws Exception {
Path dummyPath = Paths.get("dummy");
BuildRuleResolver buildRuleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(buildRuleResolver));
// Setup some dummy values for inputs to the CxxLinkStep
ImmutableList<Arg> dummyArgs = ImmutableList.of(FileListableLinkerInputArg.withSourcePathArg(SourcePathArg.of(new FakeSourcePath("libb.a"))));
CxxPrepareForLinkStep cxxPrepareForLinkStepSupportFileList = CxxPrepareForLinkStep.create(dummyPath, dummyPath, ImmutableList.of(StringArg.of("-filelist"), StringArg.of(dummyPath.toString())), dummyPath, dummyArgs, CxxPlatformUtils.DEFAULT_PLATFORM.getLd().resolve(buildRuleResolver), dummyPath, pathResolver);
ImmutableList<Step> containingSteps = ImmutableList.copyOf(cxxPrepareForLinkStepSupportFileList.iterator());
assertThat(containingSteps.size(), Matchers.equalTo(2));
Step firstStep = containingSteps.get(0);
Step secondStep = containingSteps.get(1);
assertThat(firstStep, Matchers.instanceOf(CxxWriteArgsToFileStep.class));
assertThat(secondStep, Matchers.instanceOf(CxxWriteArgsToFileStep.class));
assertThat(firstStep, Matchers.not(secondStep));
CxxPrepareForLinkStep cxxPrepareForLinkStepNoSupportFileList = CxxPrepareForLinkStep.create(dummyPath, dummyPath, ImmutableList.of(), dummyPath, dummyArgs, CxxPlatformUtils.DEFAULT_PLATFORM.getLd().resolve(buildRuleResolver), dummyPath, pathResolver);
containingSteps = ImmutableList.copyOf(cxxPrepareForLinkStepNoSupportFileList.iterator());
assertThat(containingSteps.size(), Matchers.equalTo(1));
assertThat(containingSteps.get(0), Matchers.instanceOf(CxxWriteArgsToFileStep.class));
}
use of com.facebook.buck.step.Step in project buck by facebook.
the class CxxTestTest method runTests.
@Test
public void runTests() {
final ImmutableList<String> command = ImmutableList.of("hello", "world");
FakeCxxTest cxxTest = new FakeCxxTest() {
@Override
public SourcePath getSourcePathToOutput() {
return new ExplicitBuildTargetSourcePath(getBuildTarget(), Paths.get("output"));
}
@Override
protected ImmutableList<String> getShellCommand(SourcePathResolver resolver, Path output) {
return command;
}
@Override
public Tool getExecutableCommand() {
CommandTool.Builder builder = new CommandTool.Builder();
command.forEach(builder::addArg);
return builder.build();
}
};
ExecutionContext executionContext = TestExecutionContext.newInstance();
TestRunningOptions options = TestRunningOptions.builder().setTestSelectorList(TestSelectorList.empty()).build();
ImmutableList<Step> actualSteps = cxxTest.runTests(executionContext, options, createMock(SourcePathResolver.class), FakeTestRule.NOOP_REPORTING_CALLBACK);
CxxTestStep cxxTestStep = new CxxTestStep(new FakeProjectFilesystem(), command, ImmutableMap.of(), cxxTest.getPathToTestExitCode(), cxxTest.getPathToTestOutput(), TEST_TIMEOUT_MS);
assertEquals(cxxTestStep, Iterables.getLast(actualSteps));
}
Aggregations