use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class CxxBinaryDescriptionTest method staticPicLinkStyle.
@Test
public void staticPicLinkStyle() throws Exception {
BuildTarget target = BuildTargetFactory.newInstance("//foo:bar");
BuildRuleResolver resolver = new BuildRuleResolver(prepopulateWithSandbox(target), new DefaultTargetNodeToBuildRuleTransformer());
ProjectFilesystem filesystem = new FakeProjectFilesystem();
new CxxBinaryBuilder(target, cxxBuckConfig).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new PathSourcePath(filesystem, Paths.get("test.cpp"))))).build(resolver, filesystem);
}
use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class CxxBinaryDescriptionTest method testBinaryWithStripFlavorHasStripLinkRuleWithCorrectStripStyle.
@Test
public void testBinaryWithStripFlavorHasStripLinkRuleWithCorrectStripStyle() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
CxxPlatform platform = CxxLibraryBuilder.createDefaultPlatform();
CxxBinaryBuilder binaryBuilder = new CxxBinaryBuilder(BuildTargetFactory.newInstance("//:foo").withFlavors(platform.getFlavor(), InternalFlavor.of("shared"), StripStyle.ALL_SYMBOLS.getFlavor()), cxxBuckConfig);
binaryBuilder.setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("foo.c"))));
TargetGraph targetGraph = TargetGraphFactory.newInstance(binaryBuilder.build());
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
BuildRule resultRule = binaryBuilder.build(resolver, filesystem, targetGraph);
assertThat(resultRule, Matchers.instanceOf(CxxBinary.class));
assertThat(((CxxBinary) resultRule).getLinkRule(), Matchers.instanceOf(CxxStrip.class));
CxxStrip strip = (CxxStrip) ((CxxBinary) resultRule).getLinkRule();
assertThat(strip.getStripStyle(), equalTo(StripStyle.ALL_SYMBOLS));
}
use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class CxxBinaryDescriptionTest method runtimeDepOnDeps.
@Test
public void runtimeDepOnDeps() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
BuildTarget leafBinaryTarget = BuildTargetFactory.newInstance("//:dep");
CxxBinaryBuilder leafCxxBinaryBuilder = new CxxBinaryBuilder(leafBinaryTarget, cxxBuckConfig);
BuildTarget libraryTarget = BuildTargetFactory.newInstance("//:lib");
CxxLibraryBuilder cxxLibraryBuilder = new CxxLibraryBuilder(libraryTarget).setDeps(ImmutableSortedSet.of(leafBinaryTarget));
BuildTarget topLevelBinaryTarget = BuildTargetFactory.newInstance("//:bin");
CxxBinaryBuilder topLevelCxxBinaryBuilder = new CxxBinaryBuilder(topLevelBinaryTarget, cxxBuckConfig).setDeps(ImmutableSortedSet.of(libraryTarget));
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraphFactory.newInstance(leafCxxBinaryBuilder.build(), cxxLibraryBuilder.build(), topLevelCxxBinaryBuilder.build()), new DefaultTargetNodeToBuildRuleTransformer());
BuildRule leafCxxBinary = leafCxxBinaryBuilder.build(resolver, filesystem);
cxxLibraryBuilder.build(resolver, filesystem);
CxxBinary topLevelCxxBinary = topLevelCxxBinaryBuilder.build(resolver, filesystem);
assertThat(BuildRules.getTransitiveRuntimeDeps(topLevelCxxBinary, resolver), Matchers.hasItem(leafCxxBinary.getBuildTarget()));
}
use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class CxxPreprocessAndCompileIntegrationTest method sanitizeWorkingDirectoryWhenBuildingAssembly.
@Test
public void sanitizeWorkingDirectoryWhenBuildingAssembly() throws IOException {
BuildTarget target = BuildTargetFactory.newInstance("//:simple_assembly#default,static");
ProjectFilesystem filesystem = new FakeProjectFilesystem();
ProjectWorkspace.ProcessResult processResult = workspace.runBuckBuild(target.getFullyQualifiedName());
processResult.assertSuccess();
Path lib = workspace.getPath(BuildTargets.getGenPath(filesystem, target, "%s/libsimple_assembly.a"));
String contents = Files.asByteSource(lib.toFile()).asCharSource(Charsets.ISO_8859_1).read();
assertFalse(lib.toString(), contents.contains(tmp.getRoot().toString()));
}
use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class CxxPreprocessablesTest method getTransitiveCxxPreprocessorInput.
@Test
public void getTransitiveCxxPreprocessorInput() throws Exception {
FakeProjectFilesystem filesystem = new FakeProjectFilesystem();
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
CxxPlatform cxxPlatform = CxxPlatformUtils.build(new CxxBuckConfig(FakeBuckConfig.builder().setFilesystem(filesystem).build()));
// Setup a simple CxxPreprocessorDep which contributes components to preprocessing.
BuildTarget cppDepTarget1 = BuildTargetFactory.newInstance(filesystem, "//:cpp1");
CxxPreprocessorInput input1 = CxxPreprocessorInput.builder().addRules(cppDepTarget1).putPreprocessorFlags(CxxSource.Type.C, "-Dtest=yes").putPreprocessorFlags(CxxSource.Type.CXX, "-Dtest=yes").build();
BuildTarget depTarget1 = BuildTargetFactory.newInstance(filesystem, "//:dep1");
FakeCxxPreprocessorDep dep1 = createFakeCxxPreprocessorDep(depTarget1, pathResolver, input1);
// Setup another simple CxxPreprocessorDep which contributes components to preprocessing.
BuildTarget cppDepTarget2 = BuildTargetFactory.newInstance(filesystem, "//:cpp2");
CxxPreprocessorInput input2 = CxxPreprocessorInput.builder().addRules(cppDepTarget2).putPreprocessorFlags(CxxSource.Type.C, "-DBLAH").putPreprocessorFlags(CxxSource.Type.CXX, "-DBLAH").build();
BuildTarget depTarget2 = BuildTargetFactory.newInstance("//:dep2");
FakeCxxPreprocessorDep dep2 = createFakeCxxPreprocessorDep(depTarget2, pathResolver, input2);
// Create a normal dep which depends on the two CxxPreprocessorDep rules above.
BuildTarget depTarget3 = BuildTargetFactory.newInstance(filesystem, "//:dep3");
CxxPreprocessorInput nothing = CxxPreprocessorInput.EMPTY;
FakeCxxPreprocessorDep dep3 = createFakeCxxPreprocessorDep(depTarget3, pathResolver, nothing, dep1, dep2);
// Verify that getTransitiveCxxPreprocessorInput gets all CxxPreprocessorInput objects
// from the relevant rules above.
ImmutableList<CxxPreprocessorInput> expected = ImmutableList.of(nothing, input1, input2);
ImmutableList<CxxPreprocessorInput> actual = ImmutableList.copyOf(CxxPreprocessables.getTransitiveCxxPreprocessorInput(cxxPlatform, ImmutableList.<BuildRule>of(dep3)));
assertEquals(expected, actual);
}
Aggregations