use of com.facebook.buck.rules.FakeBuildRule in project buck by facebook.
the class CxxLinkableEnhancerTest method getTransitiveNativeLinkableInputDoesNotTraversePastNonNativeLinkables.
@Test
public void getTransitiveNativeLinkableInputDoesNotTraversePastNonNativeLinkables() throws Exception {
CxxPlatform cxxPlatform = CxxPlatformUtils.build(new CxxBuckConfig(FakeBuckConfig.builder().build()));
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
// Create a native linkable that sits at the bottom of the dep chain.
String sentinel = "bottom";
NativeLinkableInput bottomInput = NativeLinkableInput.of(ImmutableList.of(StringArg.of(sentinel)), ImmutableSet.of(), ImmutableSet.of());
BuildRule bottom = createNativeLinkable("//:bottom", pathResolver, bottomInput, bottomInput);
// Create a non-native linkable that sits in the middle of the dep chain, preventing
// traversals to the bottom native linkable.
BuildRule middle = new FakeBuildRule("//:middle", pathResolver, bottom);
// Create a native linkable that sits at the top of the dep chain.
NativeLinkableInput topInput = NativeLinkableInput.of(ImmutableList.of(), ImmutableSet.of(), ImmutableSet.of());
BuildRule top = createNativeLinkable("//:top", pathResolver, topInput, topInput, middle);
// Now grab all input via traversing deps and verify that the middle rule prevents pulling
// in the bottom input.
NativeLinkableInput totalInput = NativeLinkables.getTransitiveNativeLinkableInput(cxxPlatform, ImmutableList.of(top), Linker.LinkableDepType.STATIC, NativeLinkable.class::isInstance);
assertThat(Arg.stringify(bottomInput.getArgs(), pathResolver), hasItem(sentinel));
assertThat(Arg.stringify(totalInput.getArgs(), pathResolver), not(hasItem(sentinel)));
}
use of com.facebook.buck.rules.FakeBuildRule 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));
}
use of com.facebook.buck.rules.FakeBuildRule 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));
}
Aggregations