use of com.facebook.buck.rules.FakeBuildRule in project buck by facebook.
the class MavenCoordinatesMacroExpanderTest method testNonHasMavenCoordinatesBuildRule.
@Test
public void testNonHasMavenCoordinatesBuildRule() throws Exception {
assumeFalse("Assuming that FakeBuildRule does not have maven coordinates", FakeBuildRule.class.isAssignableFrom(HasMavenCoordinates.class));
SourcePathResolver sourcePathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
BuildRule rule = new FakeBuildRule("//test:foo", sourcePathResolver);
try {
expander.getMavenCoordinates(rule);
fail("Expected MacroException; Rule does not contain maven coordinates");
} catch (MacroException e) {
assertTrue("Expected MacroException that indicates target does not have maven coordinates", e.getMessage().contains("does not correspond to a rule with maven coordinates"));
}
}
use of com.facebook.buck.rules.FakeBuildRule in project buck by facebook.
the class ExportFileTest method shouldSetInputsFromSourcePaths.
@Test
public void shouldSetInputsFromSourcePaths() throws Exception {
ExportFileBuilder builder = ExportFileBuilder.newExportFileBuilder(target).setSrc(new FakeSourcePath("chips")).setOut("cake");
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
ExportFile exportFile = builder.build(resolver, projectFilesystem);
assertIterablesEquals(singleton(Paths.get("chips")), pathResolver.filterInputsToCompareToOutput(exportFile.getSource()));
resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
FakeBuildRule rule = resolver.addToIndex(new FakeBuildRule(BuildTargetFactory.newInstance("//example:one"), pathResolver));
builder.setSrc(new DefaultBuildTargetSourcePath(rule.getBuildTarget()));
exportFile = builder.build(resolver, projectFilesystem);
assertThat(pathResolver.filterInputsToCompareToOutput(exportFile.getSource()), Matchers.empty());
resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
builder.setSrc(null);
exportFile = builder.build(resolver, projectFilesystem);
assertIterablesEquals(singleton(projectFilesystem.getPath("example.html")), pathResolver.filterInputsToCompareToOutput(exportFile.getSource()));
}
use of com.facebook.buck.rules.FakeBuildRule in project buck by facebook.
the class ShTestTest method depsAreRuntimeDeps.
@Test
public void depsAreRuntimeDeps() {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
BuildRule extraDep = new FakeBuildRule("//:extra_dep", pathResolver);
BuildRule dep = new FakeBuildRule("//:dep", pathResolver);
BuildTarget target = BuildTargetFactory.newInstance("//:rule");
ShTest shTest = new ShTest(new FakeBuildRuleParamsBuilder(target).setDeclaredDeps(ImmutableSortedSet.of(dep)).setExtraDeps(ImmutableSortedSet.of(extraDep)).build(), ruleFinder, new FakeSourcePath("run_test.sh"), /* args */
ImmutableList.of(), /* env */
ImmutableMap.of(), /* resources */
ImmutableSortedSet.of(), Optional.empty(), /* runTestSeparately */
false, /* labels */
ImmutableSet.of(), /* contacts */
ImmutableSet.of());
assertThat(shTest.getRuntimeDeps().collect(MoreCollectors.toImmutableSet()), containsInAnyOrder(dep.getBuildTarget(), extraDep.getBuildTarget()));
}
use of com.facebook.buck.rules.FakeBuildRule in project buck by facebook.
the class SwiftLibraryIntegrationTest method headersOfDependentTargetsAreIncluded.
@Test
public void headersOfDependentTargetsAreIncluded() throws Exception {
// The output path used by the buildable for the link tree.
BuildTarget symlinkTarget = BuildTargetFactory.newInstance("//:symlink");
ProjectFilesystem projectFilesystem = new FakeProjectFilesystem(tmpDir.getRoot());
Path symlinkTreeRoot = BuildTargets.getGenPath(projectFilesystem, symlinkTarget, "%s/symlink-tree-root");
// Setup the map representing the link tree.
ImmutableMap<Path, SourcePath> links = ImmutableMap.of();
HeaderSymlinkTreeWithHeaderMap symlinkTreeBuildRule = HeaderSymlinkTreeWithHeaderMap.create(symlinkTarget, projectFilesystem, symlinkTreeRoot, links, ruleFinder);
resolver.addToIndex(symlinkTreeBuildRule);
BuildTarget libTarget = BuildTargetFactory.newInstance("//:lib");
BuildRuleParams libParams = new FakeBuildRuleParamsBuilder(libTarget).build();
FakeCxxLibrary depRule = new FakeCxxLibrary(libParams, BuildTargetFactory.newInstance("//:header"), symlinkTarget, BuildTargetFactory.newInstance("//:privateheader"), BuildTargetFactory.newInstance("//:privatesymlink"), new FakeBuildRule("//:archive", pathResolver), new FakeBuildRule("//:shared", pathResolver), Paths.get("output/path/lib.so"), "lib.so", ImmutableSortedSet.of());
BuildTarget buildTarget = BuildTargetFactory.newInstance("//foo:bar#iphoneos-x86_64");
BuildRuleParams params = new FakeBuildRuleParamsBuilder(buildTarget).setDeclaredDeps(ImmutableSortedSet.of(depRule)).build();
SwiftLibraryDescription.Arg args = createDummySwiftArg();
SwiftCompile buildRule = (SwiftCompile) FakeAppleRuleDescriptions.SWIFT_LIBRARY_DESCRIPTION.createBuildRule(TargetGraph.EMPTY, params, resolver, args);
ImmutableList<String> swiftIncludeArgs = buildRule.getSwiftIncludeArgs(pathResolver);
assertThat(swiftIncludeArgs.size(), Matchers.equalTo(1));
assertThat(swiftIncludeArgs.get(0), Matchers.startsWith("-I"));
assertThat(swiftIncludeArgs.get(0), Matchers.endsWith("symlink.hmap"));
}
use of com.facebook.buck.rules.FakeBuildRule in project buck by facebook.
the class JavaTestDescriptionTest method rulesExportedFromProvidedDepsBecomeFirstOrderDeps.
@Test
public void rulesExportedFromProvidedDepsBecomeFirstOrderDeps() 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).addProvidedDep(exportingRule.getBuildTarget()).build(resolver);
ImmutableSortedSet<BuildRule> deps = javaTest.getCompiledTestsLibrary().getDeps();
assertThat(deps, Matchers.<BuildRule>hasItem(exportedRule));
}
Aggregations