use of com.facebook.buck.rules.PathSourcePath in project buck by facebook.
the class InputBasedRuleKeyFactoryTest method ruleKeyNotCalculatedIfSizeLimitHitWithMultipleInputs.
@Test
public void ruleKeyNotCalculatedIfSizeLimitHitWithMultipleInputs() throws Exception {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
RuleKeyFieldLoader fieldLoader = new RuleKeyFieldLoader(0);
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
FakeProjectFilesystem filesystem = new FakeProjectFilesystem();
FileHashCache hashCache = new StackedFileHashCache(ImmutableList.of(DefaultFileHashCache.createDefaultFileHashCache(filesystem)));
// Create inputs that combine to pass size limit.
Path input1 = filesystem.getPath("input1");
filesystem.writeBytesToPath(new byte[150], input1);
Path input2 = filesystem.getPath("input2");
filesystem.writeBytesToPath(new byte[150], input2);
// Construct rule which uses inputs.
BuildRule rule = GenruleBuilder.newGenruleBuilder(BuildTargetFactory.newInstance("//:rule")).setOut("out").setSrcs(ImmutableList.of(new PathSourcePath(filesystem, input1), new PathSourcePath(filesystem, input2))).build(resolver, filesystem);
// Verify rule key isn't calculated.
expectedException.expect(SizeLimiter.SizeLimitException.class);
new InputBasedRuleKeyFactory(fieldLoader, hashCache, pathResolver, ruleFinder, 200).build(rule);
}
use of com.facebook.buck.rules.PathSourcePath in project buck by facebook.
the class DependencyFileRuleKeyFactoryTest method testKeysWhenInputArchiveMemberChanges.
@Test
public void testKeysWhenInputArchiveMemberChanges() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
BuildRuleResolver ruleResolver = newRuleResolver();
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(ruleResolver);
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
SourcePath archivePath = new PathSourcePath(filesystem, Paths.get("archive"));
SourcePath usedSourcePath = new ArchiveMemberSourcePath(archivePath, Paths.get("used"));
SourcePath unusedSourcePath = new ArchiveMemberSourcePath(archivePath, Paths.get("unused"));
SourcePath noncoveredSourcePath = new ArchiveMemberSourcePath(archivePath, Paths.get("nc"));
SourcePath interestingSourcePath = new ArchiveMemberSourcePath(archivePath, Paths.get("META-INF"));
testKeysWhenInputContentsChanges(ruleFinder, pathResolver, usedSourcePath, unusedSourcePath, noncoveredSourcePath, interestingSourcePath, Paths.get(pathResolver.getAbsoluteArchiveMemberPath(usedSourcePath).toString()), Paths.get(pathResolver.getAbsoluteArchiveMemberPath(unusedSourcePath).toString()), Paths.get(pathResolver.getAbsoluteArchiveMemberPath(noncoveredSourcePath).toString()), Paths.get(pathResolver.getAbsoluteArchiveMemberPath(interestingSourcePath).toString()), DependencyFileEntry.fromSourcePath(usedSourcePath, pathResolver));
}
use of com.facebook.buck.rules.PathSourcePath in project buck by facebook.
the class InputBasedRuleKeyFactoryTest method nestedSizeLimitExceptionHandled.
@Test
public void nestedSizeLimitExceptionHandled() throws Exception {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
RuleKeyFieldLoader fieldLoader = new RuleKeyFieldLoader(0);
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
final FakeProjectFilesystem filesystem = new FakeProjectFilesystem();
FileHashCache hashCache = new StackedFileHashCache(ImmutableList.of(DefaultFileHashCache.createDefaultFileHashCache(filesystem)));
Path inputFile = filesystem.getPath("input");
filesystem.writeBytesToPath(new byte[1024], inputFile);
BuildRuleParams params = new FakeBuildRuleParamsBuilder("//:rule").setProjectFilesystem(filesystem).build();
BuildRule rule = new NoopBuildRule(params) {
@AddToRuleKey
NestedRuleKeyAppendableWithInput input = new NestedRuleKeyAppendableWithInput(new PathSourcePath(filesystem, inputFile));
};
// Verify rule key isn't calculated.
expectedException.expect(SizeLimiter.SizeLimitException.class);
new InputBasedRuleKeyFactory(fieldLoader, hashCache, pathResolver, ruleFinder, 200).build(rule);
}
use of com.facebook.buck.rules.PathSourcePath in project buck by facebook.
the class StringifyAlterRuleKeyTest method findAbsolutePathsInRecursiveStructure.
@Test
public void findAbsolutePathsInRecursiveStructure() {
FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
Path path1 = MorePathsForTests.rootRelativePath("some/thing");
Path path2 = MorePathsForTests.rootRelativePath("other/thing");
Path path3 = MorePathsForTests.rootRelativePath("yet/another/thing");
Object input = ImmutableList.of(ImmutableMap.of(Optional.empty(), path1), ImmutableSet.of(Optional.of(path2)), Optional.empty(), Optional.of(new PathSourcePath(projectFilesystem, path3)));
Assert.assertEquals(ImmutableSet.of(path1, path2, path3), ImmutableSet.copyOf(StringifyAlterRuleKey.findAbsolutePaths(input)));
}
use of com.facebook.buck.rules.PathSourcePath in project buck by facebook.
the class StringifyAlterRuleKeyTest method findAbsolutePathsInListOfPathSourcePaths.
@Test
public void findAbsolutePathsInListOfPathSourcePaths() {
FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
Path path1 = MorePathsForTests.rootRelativePath("some/thing");
Path path2 = Paths.get("some/thing");
List<SourcePath> input = ImmutableList.of(new PathSourcePath(projectFilesystem, path2), new PathSourcePath(projectFilesystem, path1));
Assert.assertEquals(ImmutableSet.of(path1), ImmutableSet.copyOf(StringifyAlterRuleKey.findAbsolutePaths(input)));
}
Aggregations