Search in sources :

Example 86 with BuildRuleResolver

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));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) BuildRule(com.facebook.buck.rules.BuildRule) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) TargetGraph(com.facebook.buck.rules.TargetGraph) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Test(org.junit.Test)

Example 87 with BuildRuleResolver

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()));
}
Also used : FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) BuildTarget(com.facebook.buck.model.BuildTarget) BuildRule(com.facebook.buck.rules.BuildRule) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Test(org.junit.Test)

Example 88 with BuildRuleResolver

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);
}
Also used : FakeTestRule(com.facebook.buck.rules.FakeTestRule) TestRule(com.facebook.buck.rules.TestRule) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) FakeTestRule(com.facebook.buck.rules.FakeTestRule) Test(org.junit.Test)

Example 89 with BuildRuleResolver

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);
}
Also used : FakeTestRule(com.facebook.buck.rules.FakeTestRule) TestRule(com.facebook.buck.rules.TestRule) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) FakeTestRule(com.facebook.buck.rules.FakeTestRule) Test(org.junit.Test)

Example 90 with BuildRuleResolver

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));
}
Also used : FakeTestRule(com.facebook.buck.rules.FakeTestRule) TestRule(com.facebook.buck.rules.TestRule) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) FakeTestRule(com.facebook.buck.rules.FakeTestRule) Test(org.junit.Test)

Aggregations

BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)622 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)578 Test (org.junit.Test)540 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)402 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)376 BuildTarget (com.facebook.buck.model.BuildTarget)287 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)240 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)211 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)211 TargetGraph (com.facebook.buck.rules.TargetGraph)196 BuildRule (com.facebook.buck.rules.BuildRule)185 Path (java.nio.file.Path)136 SourcePath (com.facebook.buck.rules.SourcePath)133 PathSourcePath (com.facebook.buck.rules.PathSourcePath)104 FakeBuildRuleParamsBuilder (com.facebook.buck.rules.FakeBuildRuleParamsBuilder)101 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)83 FakeBuildRule (com.facebook.buck.rules.FakeBuildRule)75 RuleKey (com.facebook.buck.rules.RuleKey)71 AllExistingProjectFilesystem (com.facebook.buck.testutil.AllExistingProjectFilesystem)62 DefaultBuildTargetSourcePath (com.facebook.buck.rules.DefaultBuildTargetSourcePath)54