use of com.facebook.buck.rules.FakeBuildableContext in project buck by facebook.
the class CxxPrecompiledHeaderTest method generatesPchStepShouldUseCorrectLang.
@Test
public void generatesPchStepShouldUseCorrectLang() throws Exception {
BuildTarget target = BuildTargetFactory.newInstance("//foo:bar");
BuildRuleParams params = new FakeBuildRuleParamsBuilder(target).build();
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
Preprocessor preprocessorSupportingPch = new GccPreprocessor(CxxPlatformUtils.DEFAULT_PLATFORM.getCpp().resolve(resolver)) {
@Override
public boolean supportsPrecompiledHeaders() {
return true;
}
};
Compiler compiler = CxxPlatformUtils.DEFAULT_PLATFORM.getCxx().resolve(resolver);
SourcePathResolver sourcePathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
CxxPrecompiledHeader precompiledHeader = new CxxPrecompiledHeader(params, Paths.get("foo.hash1.hash2.gch"), new PreprocessorDelegate(sourcePathResolver, CxxPlatformUtils.DEFAULT_COMPILER_DEBUG_PATH_SANITIZER, CxxPlatformUtils.DEFAULT_PLATFORM.getHeaderVerification(), Paths.get("./"), preprocessorSupportingPch, PreprocessorFlags.builder().build(), CxxDescriptionEnhancer.frameworkPathToSearchPath(CxxPlatformUtils.DEFAULT_PLATFORM, sourcePathResolver), Optional.empty(), /* leadingIncludePaths */
Optional.empty()), new CompilerDelegate(sourcePathResolver, CxxPlatformUtils.DEFAULT_COMPILER_DEBUG_PATH_SANITIZER, compiler, CxxToolFlags.of()), CxxToolFlags.of(), new FakeSourcePath("foo.h"), CxxSource.Type.C, CxxPlatformUtils.DEFAULT_COMPILER_DEBUG_PATH_SANITIZER, CxxPlatformUtils.DEFAULT_ASSEMBLER_DEBUG_PATH_SANITIZER);
resolver.addToIndex(precompiledHeader);
BuildContext buildContext = FakeBuildContext.withSourcePathResolver(sourcePathResolver);
ImmutableList<Step> postBuildSteps = precompiledHeader.getBuildSteps(buildContext, new FakeBuildableContext());
CxxPreprocessAndCompileStep step = Iterables.getOnlyElement(Iterables.filter(postBuildSteps, CxxPreprocessAndCompileStep.class));
assertThat("step that generates pch should have correct flags", step.getCommand(), hasItem(CxxSource.Type.C.getPrecompiledHeaderLanguage().get()));
}
use of com.facebook.buck.rules.FakeBuildableContext in project buck by facebook.
the class DirectHeaderMapTest method testBuildSteps.
@Test
public void testBuildSteps() throws IOException {
BuildContext buildContext = FakeBuildContext.withSourcePathResolver(pathResolver);
FakeBuildableContext buildableContext = new FakeBuildableContext();
ImmutableList<Step> expectedBuildSteps = ImmutableList.of(new MkdirStep(projectFilesystem, headerMapPath.getParent()), new RmStep(projectFilesystem, headerMapPath), new HeaderMapStep(projectFilesystem, headerMapPath, ImmutableMap.of(Paths.get("file"), projectFilesystem.resolve(projectFilesystem.getBuckPaths().getBuckOut()).relativize(file1), Paths.get("directory/then/file"), projectFilesystem.resolve(projectFilesystem.getBuckPaths().getBuckOut()).relativize(file2))));
ImmutableList<Step> actualBuildSteps = buildRule.getBuildSteps(buildContext, buildableContext);
assertEquals(expectedBuildSteps, actualBuildSteps.subList(1, actualBuildSteps.size()));
}
use of com.facebook.buck.rules.FakeBuildableContext in project buck by facebook.
the class KeystoreTest method testBuildInternal.
@Test
public void testBuildInternal() throws Exception {
BuildContext buildContext = FakeBuildContext.NOOP_CONTEXT;
BuildRule keystore = createKeystoreRuleForTest();
List<Step> buildSteps = keystore.getBuildSteps(buildContext, new FakeBuildableContext());
assertEquals(ImmutableList.<Step>of(), buildSteps);
}
use of com.facebook.buck.rules.FakeBuildableContext in project buck by facebook.
the class PythonBinaryDescriptionTest method buildArgs.
@Test
public void buildArgs() throws Exception {
BuildTarget target = BuildTargetFactory.newInstance("//foo:bin");
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
ImmutableList<String> buildArgs = ImmutableList.of("--some", "--args");
PythonBinary binary = PythonBinaryBuilder.create(target).setMainModule("main").setBuildArgs(buildArgs).build(resolver);
ImmutableList<Step> buildSteps = binary.getBuildSteps(FakeBuildContext.withSourcePathResolver(pathResolver), new FakeBuildableContext());
PexStep pexStep = FluentIterable.from(buildSteps).filter(PexStep.class).get(0);
assertThat(pexStep.getCommandPrefix(), Matchers.hasItems(buildArgs.toArray(new String[buildArgs.size()])));
}
use of com.facebook.buck.rules.FakeBuildableContext in project buck by facebook.
the class PythonTestDescriptionTest method buildArgs.
@Test
public void buildArgs() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
BuildTarget target = BuildTargetFactory.newInstance("//foo:test");
ImmutableList<String> buildArgs = ImmutableList.of("--some", "--args");
PythonTestBuilder builder = PythonTestBuilder.create(target).setBuildArgs(buildArgs);
TargetGraph targetGraph = TargetGraphFactory.newInstance(builder.build());
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
PythonTest test = builder.build(resolver, filesystem, targetGraph);
PythonBinary binary = test.getBinary();
ImmutableList<Step> buildSteps = binary.getBuildSteps(FakeBuildContext.withSourcePathResolver(pathResolver), new FakeBuildableContext());
PexStep pexStep = RichStream.from(buildSteps).filter(PexStep.class).toImmutableList().get(0);
assertThat(pexStep.getCommandPrefix(), Matchers.hasItems(buildArgs.toArray(new String[buildArgs.size()])));
}
Aggregations