use of com.facebook.buck.rules.FakeBuildRule in project buck by facebook.
the class JavaTestDescriptionTest method rulesExportedFromDepsBecomeFirstOrderDeps.
@Test
public void rulesExportedFromDepsBecomeFirstOrderDeps() throws Exception {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
FakeBuildRule exportedRule = resolver.addToIndex(new FakeBuildRule("//:exported_rule", pathResolver));
FakeExportDependenciesRule exportingRule = resolver.addToIndex(new FakeExportDependenciesRule("//:exporting_rule", pathResolver, exportedRule));
BuildTarget target = BuildTargetFactory.newInstance("//:rule");
JavaTest javaTest = JavaTestBuilder.createBuilder(target).addDep(exportingRule.getBuildTarget()).build(resolver);
ImmutableSortedSet<BuildRule> deps = javaTest.getCompiledTestsLibrary().getDeps();
assertThat(deps, Matchers.<BuildRule>hasItem(exportedRule));
}
use of com.facebook.buck.rules.FakeBuildRule in project buck by facebook.
the class JavaLibraryDescriptionTest method setUp.
@Before
public void setUp() {
resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
exportedRule = resolver.addToIndex(new FakeBuildRule("//:exported_rule", pathResolver));
exportingRule = resolver.addToIndex(new FakeExportDependenciesRule("//:exporting_rule", pathResolver, exportedRule));
}
use of com.facebook.buck.rules.FakeBuildRule in project buck by facebook.
the class WorkerMacroArgTest method testWorkerMacroArgWithBadReference.
@Test
public void testWorkerMacroArgWithBadReference() throws MacroException, NoSuchBuildTargetException {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
BuildRule nonWorkerBuildRule = new FakeBuildRule(BuildTargetFactory.newInstance("//:not_worker_rule"), new SourcePathResolver(new SourcePathRuleFinder(resolver)));
resolver.addToIndex(nonWorkerBuildRule);
MacroHandler macroHandler = new MacroHandler(ImmutableMap.of("worker", new WorkerMacroExpander()));
ProjectFilesystem filesystem = new FakeProjectFilesystem();
try {
new WorkerMacroArg(macroHandler, BuildTargetFactory.newInstance("//:rule"), TestCellBuilder.createCellRoots(filesystem), resolver, "$(worker //:not_worker_rule)");
} catch (MacroException e) {
assertThat(e.getMessage(), Matchers.containsString("does not correspond to a worker_tool"));
}
}
use of com.facebook.buck.rules.FakeBuildRule in project buck by facebook.
the class AndroidManifestDescriptionTest method testGeneratedSkeletonAppearsInDeps.
@Test
public void testGeneratedSkeletonAppearsInDeps() {
BuildRuleResolver buildRuleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
BuildRule ruleWithOutput = new FakeBuildRule(BuildTargetFactory.newInstance("//foo:bar"), new SourcePathResolver(new SourcePathRuleFinder(buildRuleResolver))) {
@Override
public SourcePath getSourcePathToOutput() {
return new ExplicitBuildTargetSourcePath(getBuildTarget(), Paths.get("buck-out/gen/foo/bar/AndroidManifest.xml"));
}
};
SourcePath skeleton = ruleWithOutput.getSourcePathToOutput();
buildRuleResolver.addToIndex(ruleWithOutput);
AndroidManifestDescription.Arg arg = new AndroidManifestDescription.Arg();
arg.skeleton = skeleton;
arg.deps = ImmutableSortedSet.of();
BuildRuleParams params = new FakeBuildRuleParamsBuilder("//foo:baz").setDeclaredDeps(buildRuleResolver.getAllRules(arg.deps)).build();
BuildRule androidManifest = new AndroidManifestDescription().createBuildRule(TargetGraph.EMPTY, params, buildRuleResolver, arg);
assertEquals(ImmutableSortedSet.of(ruleWithOutput), androidManifest.getDeps());
}
use of com.facebook.buck.rules.FakeBuildRule in project buck by facebook.
the class AndroidLibraryDescriptionTest method rulesExportedFromDepsBecomeFirstOrderDeps.
@Test
public void rulesExportedFromDepsBecomeFirstOrderDeps() throws Exception {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
FakeBuildRule transitiveExportedRule = resolver.addToIndex(new FakeBuildRule("//:transitive_exported_rule", pathResolver));
FakeExportDependenciesRule exportedRule = resolver.addToIndex(new FakeExportDependenciesRule("//:exported_rule", pathResolver, transitiveExportedRule));
FakeExportDependenciesRule exportingRule = resolver.addToIndex(new FakeExportDependenciesRule("//:exporting_rule", pathResolver, exportedRule));
BuildTarget target = BuildTargetFactory.newInstance("//:rule");
BuildRule javaLibrary = AndroidLibraryBuilder.createBuilder(target).addDep(exportingRule.getBuildTarget()).build(resolver);
assertThat(javaLibrary.getDeps(), Matchers.allOf(Matchers.hasItem(exportedRule), Matchers.hasItem(transitiveExportedRule)));
}
Aggregations