use of com.facebook.buck.rules.FakeBuildRuleParamsBuilder in project buck by facebook.
the class AndroidLibraryGraphEnhancerTest method testBuildRuleResolverCaching.
@Test
public void testBuildRuleResolverCaching() {
BuildTarget buildTarget = BuildTargetFactory.newInstance("//java/com/example:library");
AndroidLibraryGraphEnhancer graphEnhancer = new AndroidLibraryGraphEnhancer(buildTarget, new FakeBuildRuleParamsBuilder(buildTarget).build(), DEFAULT_JAVAC_OPTIONS, DependencyMode.FIRST_ORDER, /* forceFinalResourceIds */
false, /* unionPackage */
Optional.empty(), /* rName */
Optional.empty(), false);
BuildRuleResolver buildRuleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
Optional<DummyRDotJava> result = graphEnhancer.getBuildableForAndroidResources(buildRuleResolver, /* createdBuildableIfEmptyDeps */
true);
Optional<DummyRDotJava> secondResult = graphEnhancer.getBuildableForAndroidResources(buildRuleResolver, /* createdBuildableIfEmptyDeps */
true);
assertThat(result.get(), Matchers.sameInstance(secondResult.get()));
}
use of com.facebook.buck.rules.FakeBuildRuleParamsBuilder in project buck by facebook.
the class AppleCxxPlatformsTest method constructLinkRuleKeys.
// Create and return some rule keys from a dummy source for the given platforms.
private ImmutableMap<Flavor, RuleKey> constructLinkRuleKeys(ImmutableMap<Flavor, AppleCxxPlatform> cxxPlatforms) throws NoSuchBuildTargetException {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
DefaultRuleKeyFactory ruleKeyFactory = new DefaultRuleKeyFactory(0, FakeFileHashCache.createFromStrings(ImmutableMap.<String, String>builder().put("input.o", Strings.repeat("a", 40)).build()), pathResolver, ruleFinder);
BuildTarget target = BuildTargetFactory.newInstance("//:target");
ImmutableMap.Builder<Flavor, RuleKey> ruleKeys = ImmutableMap.builder();
for (Map.Entry<Flavor, AppleCxxPlatform> entry : cxxPlatforms.entrySet()) {
BuildRule rule = CxxLinkableEnhancer.createCxxLinkableBuildRule(CxxPlatformUtils.DEFAULT_CONFIG, entry.getValue().getCxxPlatform(), new FakeBuildRuleParamsBuilder(target).build(), resolver, pathResolver, ruleFinder, target, Linker.LinkType.EXECUTABLE, Optional.empty(), Paths.get("output"), Linker.LinkableDepType.SHARED, ImmutableList.of(), Optional.empty(), Optional.empty(), ImmutableSet.of(), NativeLinkableInput.builder().setArgs(SourcePathArg.from(new FakeSourcePath("input.o"))).build());
ruleKeys.put(entry.getKey(), ruleKeyFactory.build(rule));
}
return ruleKeys.build();
}
use of com.facebook.buck.rules.FakeBuildRuleParamsBuilder in project buck by facebook.
the class ArchiveTest method testThatOriginalBuildParamsDepsDoNotPropagateToArchive.
@Test
public void testThatOriginalBuildParamsDepsDoNotPropagateToArchive() {
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()));
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
// Create an `Archive` rule using build params with an existing dependency,
// as if coming from a `TargetNode` which had declared deps. These should *not*
// propagate to the `Archive` rule, since it only cares about dependencies generating
// it's immediate inputs.
BuildRule dep = new FakeBuildRule(new FakeBuildRuleParamsBuilder("//:fake").build(), pathResolver);
BuildTarget target = BuildTargetFactory.newInstance("//:archive");
BuildRuleParams params = new FakeBuildRuleParamsBuilder(BuildTargetFactory.newInstance("//:dummy")).setDeclaredDeps(ImmutableSortedSet.of(dep)).build();
Archive archive = Archive.from(target, params, ruleFinder, DEFAULT_ARCHIVER, ImmutableList.of(), DEFAULT_RANLIB, ImmutableList.of(), Archive.Contents.NORMAL, DEFAULT_OUTPUT, DEFAULT_INPUTS);
// Verify that the archive rules dependencies are empty.
assertEquals(archive.getDeps(), ImmutableSortedSet.<BuildRule>of());
}
use of com.facebook.buck.rules.FakeBuildRuleParamsBuilder in project buck by facebook.
the class CxxGtestTestTest method testParseResults.
@Test
public void testParseResults() throws Exception {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "gtest", tmp);
workspace.setUp();
ImmutableList<String> samples = ImmutableList.of("big_output", "malformed_output", "malformed_results", "multisuite_success", "no_tests", "simple_success", "simple_failure", "simple_failure_with_output", "simple_disabled");
BuildTarget target = BuildTargetFactory.newInstance("//:test");
ProjectFilesystem filesystem = new ProjectFilesystem(tmp.getRoot());
BuildRuleResolver ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(ruleResolver);
CxxGtestTest test = new CxxGtestTest(new FakeBuildRuleParamsBuilder(target).setProjectFilesystem(filesystem).build(), ruleFinder, new CxxLink(new FakeBuildRuleParamsBuilder(BuildTargetFactory.newInstance("//:link")).build(), CxxPlatformUtils.DEFAULT_PLATFORM.getLd().resolve(ruleResolver), Paths.get("output"), ImmutableList.of(), Optional.empty(), /* cacheable */
true), new CommandTool.Builder().addArg(StringArg.of("")).build(), ImmutableMap.of(), Suppliers.ofInstance(ImmutableList.of()), ImmutableSortedSet.of(), Suppliers.ofInstance(ImmutableSortedSet.of()), ImmutableSet.of(), ImmutableSet.of(), /* runTestSeparately */
false, /* testRuleTimeoutMs */
Optional.empty(), /* maxTestOutputSize */
100L);
for (String sample : samples) {
Path exitCode = Paths.get("unused");
Path output = workspace.resolve(Paths.get(sample)).resolve("output");
Path results = workspace.resolve(Paths.get(sample)).resolve("results");
Path summaries = workspace.resolve(Paths.get(sample)).resolve("summaries");
List<TestResultSummary> expectedSummaries = mapper.readValue(summaries.toFile(), SUMMARIES_REFERENCE);
ImmutableList<TestResultSummary> actualSummaries = test.parseResults(exitCode, output, results);
assertEquals(sample, expectedSummaries, actualSummaries);
}
}
use of com.facebook.buck.rules.FakeBuildRuleParamsBuilder in project buck by facebook.
the class CxxBinaryTest method getExecutableCommandUsesAbsolutePath.
@Test
public void getExecutableCommandUsesAbsolutePath() throws IOException {
BuildRuleResolver ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(ruleResolver);
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
BuildRuleParams linkParams = new FakeBuildRuleParamsBuilder("//:link").build();
Path bin = Paths.get("path/to/exectuable");
CxxLink cxxLink = ruleResolver.addToIndex(new CxxLink(linkParams, CxxPlatformUtils.DEFAULT_PLATFORM.getLd().resolve(ruleResolver), bin, ImmutableList.of(), Optional.empty(), /* cacheable */
true));
BuildRuleParams params = new FakeBuildRuleParamsBuilder("//:target").build();
CxxBinary binary = ruleResolver.addToIndex(new CxxBinary(params.copyAppendingExtraDeps(ImmutableSortedSet.<BuildRule>of(cxxLink)), ruleResolver, ruleFinder, cxxLink, new CommandTool.Builder().addArg(SourcePathArg.of(cxxLink.getSourcePathToOutput())).build(), ImmutableSortedSet.of(), ImmutableList.of(), params.getBuildTarget()));
ImmutableList<String> command = binary.getExecutableCommand().getCommandPrefix(pathResolver);
assertTrue(Paths.get(command.get(0)).isAbsolute());
}
Aggregations