Search in sources :

Example 6 with FakeExportDependenciesRule

use of com.facebook.buck.rules.FakeExportDependenciesRule in project buck by facebook.

the class RobolectricTestDescriptionTest method rulesExportedFromProvidedDepsBecomeFirstOrderDeps.

@Test
public void rulesExportedFromProvidedDepsBecomeFirstOrderDeps() throws Exception {
    SourcePathResolver emptyPathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
    FakeBuildRule exportedRule = new FakeBuildRule("//:exported_rule", emptyPathResolver);
    FakeExportDependenciesRule exportingRule = new FakeExportDependenciesRule("//:exporting_rule", emptyPathResolver, exportedRule);
    BuildTarget target = BuildTargetFactory.newInstance("//:rule");
    TargetNode<?, ?> robolectricTestNode = RobolectricTestBuilder.createBuilder(target).addProvidedDep(exportingRule.getBuildTarget()).build();
    TargetGraph targetGraph = TargetGraphFactory.newInstance(robolectricTestNode, FakeTargetNodeBuilder.build(exportedRule), FakeTargetNodeBuilder.build(exportingRule));
    BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    RobolectricTest robolectricTest = (RobolectricTest) resolver.requireRule(robolectricTestNode.getBuildTarget());
    assertThat(robolectricTest.getCompiledTestsLibrary().getDeps(), Matchers.<BuildRule>hasItem(exportedRule));
}
Also used : FakeExportDependenciesRule(com.facebook.buck.rules.FakeExportDependenciesRule) FakeBuildRule(com.facebook.buck.rules.FakeBuildRule) BuildTarget(com.facebook.buck.model.BuildTarget) TargetGraph(com.facebook.buck.rules.TargetGraph) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Test(org.junit.Test)

Example 7 with FakeExportDependenciesRule

use of com.facebook.buck.rules.FakeExportDependenciesRule in project buck by facebook.

the class RobolectricTestDescriptionTest method rulesExportedFromDepsBecomeFirstOrderDeps.

@Test
public void rulesExportedFromDepsBecomeFirstOrderDeps() throws Exception {
    SourcePathResolver emptyPathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
    FakeBuildRule exportedRule = new FakeBuildRule("//:exported_rule", emptyPathResolver);
    FakeExportDependenciesRule exportingRule = new FakeExportDependenciesRule("//:exporting_rule", emptyPathResolver, exportedRule);
    BuildTarget target = BuildTargetFactory.newInstance("//:rule");
    TargetNode<?, ?> robolectricTestNode = RobolectricTestBuilder.createBuilder(target).addDep(exportingRule.getBuildTarget()).build();
    TargetGraph targetGraph = TargetGraphFactory.newInstance(robolectricTestNode, FakeTargetNodeBuilder.build(exportedRule), FakeTargetNodeBuilder.build(exportingRule));
    BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    RobolectricTest robolectricTest = (RobolectricTest) resolver.requireRule(robolectricTestNode.getBuildTarget());
    assertThat(robolectricTest.getCompiledTestsLibrary().getDeps(), Matchers.<BuildRule>hasItem(exportedRule));
}
Also used : FakeExportDependenciesRule(com.facebook.buck.rules.FakeExportDependenciesRule) FakeBuildRule(com.facebook.buck.rules.FakeBuildRule) BuildTarget(com.facebook.buck.model.BuildTarget) TargetGraph(com.facebook.buck.rules.TargetGraph) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Test(org.junit.Test)

Aggregations

BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)7 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)7 FakeBuildRule (com.facebook.buck.rules.FakeBuildRule)7 FakeExportDependenciesRule (com.facebook.buck.rules.FakeExportDependenciesRule)7 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)7 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)7 BuildTarget (com.facebook.buck.model.BuildTarget)6 Test (org.junit.Test)6 BuildRule (com.facebook.buck.rules.BuildRule)4 TargetGraph (com.facebook.buck.rules.TargetGraph)2 Before (org.junit.Before)1