use of com.facebook.buck.rules.BuildRuleResolver 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.rules.BuildRuleResolver 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.rules.BuildRuleResolver in project buck by facebook.
the class TestCommandTest method testLabelPlingSyntax.
@Test
public void testLabelPlingSyntax() throws CmdLineException {
TestCommand command = getCommand("--labels", "!c", "a+b");
TestRule rule = new FakeTestRule(ImmutableSet.of(Label.of("a"), Label.of("b"), Label.of("c")), BuildTargetFactory.newInstance("//:for"), new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()))), ImmutableSortedSet.of());
List<TestRule> testRules = ImmutableList.of(rule);
Iterable<TestRule> result = command.filterTestRules(FakeBuckConfig.builder().build(), ImmutableSet.of(), testRules);
assertEquals(ImmutableSet.of(), result);
}
use of com.facebook.buck.rules.BuildRuleResolver in project buck by facebook.
the class TestCommandTest method testLabelConjunctionsWithInclude.
@Test
public void testLabelConjunctionsWithInclude() throws CmdLineException {
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
TestCommand command = getCommand("--include", "windows+linux");
TestRule rule1 = new FakeTestRule(ImmutableSet.of(Label.of("windows"), Label.of("linux")), BuildTargetFactory.newInstance("//:for"), pathResolver, ImmutableSortedSet.of());
TestRule rule2 = new FakeTestRule(ImmutableSet.of(Label.of("windows")), BuildTargetFactory.newInstance("//:lulz"), pathResolver, ImmutableSortedSet.of());
List<TestRule> testRules = ImmutableList.of(rule1, rule2);
Iterable<TestRule> result = command.filterTestRules(FakeBuckConfig.builder().build(), ImmutableSet.of(), testRules);
assertEquals(ImmutableSet.of(rule1), result);
}
use of com.facebook.buck.rules.BuildRuleResolver in project buck by facebook.
the class TestCommandTest method testIncludingATestOnTheCommandLineMeansYouWouldLikeItRun.
@Test
public void testIncludingATestOnTheCommandLineMeansYouWouldLikeItRun() throws CmdLineException {
String excludedLabel = "exclude_me";
BuckConfig config = FakeBuckConfig.builder().setSections(ImmutableMap.of("test", ImmutableMap.of("excluded_labels", excludedLabel))).build();
assertThat(config.getDefaultRawExcludedLabelSelectors(), contains(excludedLabel));
TestCommand command = new TestCommand();
new AdditionalOptionsCmdLineParser(command).parseArgument("//example:test");
FakeTestRule rule = new FakeTestRule(/* labels */
ImmutableSet.of(Label.of(excludedLabel)), BuildTargetFactory.newInstance("//example:test"), new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()))), /* deps */
ImmutableSortedSet.of());
Iterable<TestRule> filtered = command.filterTestRules(config, ImmutableSet.of(BuildTargetFactory.newInstance("//example:test")), ImmutableSet.of(rule));
assertEquals(rule, Iterables.getOnlyElement(filtered));
}
Aggregations