use of com.facebook.buck.util.cache.StackedFileHashCache in project buck by facebook.
the class CxxHeadersDirTest method getRuleKey.
private RuleKey getRuleKey(ProjectFilesystem filesystem, CxxHeaders cxxHeaders) {
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()));
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
FileHashCache fileHashCache = new StackedFileHashCache(ImmutableList.of(DefaultFileHashCache.createDefaultFileHashCache(filesystem)));
DefaultRuleKeyFactory factory = new DefaultRuleKeyFactory(0, fileHashCache, pathResolver, ruleFinder);
UncachedRuleKeyBuilder builder = new UncachedRuleKeyBuilder(ruleFinder, pathResolver, fileHashCache, factory);
cxxHeaders.appendToRuleKey(builder);
return builder.build();
}
use of com.facebook.buck.util.cache.StackedFileHashCache in project buck by facebook.
the class DirectHeaderMapTest method testRuleKeyDoesNotChangeIfLinkTargetsChange.
@Test
public void testRuleKeyDoesNotChangeIfLinkTargetsChange() throws IOException {
BuildRuleResolver ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
ruleResolver.addToIndex(buildRule);
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(ruleResolver);
SourcePathResolver resolver = new SourcePathResolver(ruleFinder);
// Calculate their rule keys and verify they're different.
DefaultFileHashCache hashCache = DefaultFileHashCache.createDefaultFileHashCache(new ProjectFilesystem(tmpDir.getRoot()));
FileHashLoader hashLoader = new StackedFileHashCache(ImmutableList.of(hashCache));
RuleKey defaultKey1 = new DefaultRuleKeyFactory(0, hashLoader, resolver, ruleFinder).build(buildRule);
RuleKey inputKey1 = new InputBasedRuleKeyFactory(0, hashLoader, resolver, ruleFinder).build(buildRule);
Files.write(file1, "hello other world".getBytes());
hashCache.invalidateAll();
RuleKey defaultKey2 = new DefaultRuleKeyFactory(0, hashLoader, resolver, ruleFinder).build(buildRule);
RuleKey inputKey2 = new InputBasedRuleKeyFactory(0, hashLoader, resolver, ruleFinder).build(buildRule);
// When the file content changes, the rulekey should change but the input rulekey should be
// unchanged. This ensures that a dependent's rulekey changes correctly.
assertNotEquals(defaultKey1, defaultKey2);
assertEquals(inputKey1, inputKey2);
}
use of com.facebook.buck.util.cache.StackedFileHashCache in project buck by facebook.
the class DirectHeaderMapTest method testSymlinkTreeRuleKeysChangeIfLinkMapChanges.
@Test
public void testSymlinkTreeRuleKeysChangeIfLinkMapChanges() throws Exception {
Path aFile = tmpDir.newFile();
Files.write(aFile, "hello world".getBytes(Charsets.UTF_8));
ImmutableMap.Builder<Path, SourcePath> modifiedLinksBuilder = ImmutableMap.builder();
for (Path p : links.keySet()) {
modifiedLinksBuilder.put(tmpDir.getRoot().resolve("modified-" + p.toString()), links.get(p));
}
DirectHeaderMap modifiedBuildRule = new DirectHeaderMap(buildTarget, projectFilesystem, symlinkTreeRoot, modifiedLinksBuilder.build(), ruleFinder);
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()));
SourcePathResolver resolver = new SourcePathResolver(ruleFinder);
// Calculate their rule keys and verify they're different.
FileHashLoader hashCache = new StackedFileHashCache(ImmutableList.of(DefaultFileHashCache.createDefaultFileHashCache(new ProjectFilesystem(tmpDir.getRoot()))));
RuleKey key1 = new DefaultRuleKeyFactory(0, hashCache, resolver, ruleFinder).build(buildRule);
RuleKey key2 = new DefaultRuleKeyFactory(0, hashCache, resolver, ruleFinder).build(modifiedBuildRule);
assertNotEquals(key1, key2);
key1 = new InputBasedRuleKeyFactory(0, hashCache, resolver, ruleFinder).build(buildRule);
key2 = new InputBasedRuleKeyFactory(0, hashCache, resolver, ruleFinder).build(modifiedBuildRule);
assertNotEquals(key1, key2);
}
use of com.facebook.buck.util.cache.StackedFileHashCache in project buck by facebook.
the class HeaderSymlinkTreeWithHeaderMapTest method testSymlinkTreeRuleKeyChangesIfLinkMapChanges.
@Test
public void testSymlinkTreeRuleKeyChangesIfLinkMapChanges() throws Exception {
Path aFile = tmpDir.newFile();
Files.write(aFile, "hello world".getBytes(Charsets.UTF_8));
HeaderSymlinkTreeWithHeaderMap modifiedSymlinkTreeBuildRule = HeaderSymlinkTreeWithHeaderMap.create(buildTarget, projectFilesystem, symlinkTreeRoot, ImmutableMap.of(Paths.get("different/link"), new PathSourcePath(projectFilesystem, MorePaths.relativize(tmpDir.getRoot(), aFile))), ruleFinder);
// Calculate their rule keys and verify they're different.
DefaultFileHashCache hashCache = DefaultFileHashCache.createDefaultFileHashCache(new ProjectFilesystem(tmpDir.getRoot()));
FileHashLoader hashLoader = new StackedFileHashCache(ImmutableList.of(hashCache));
RuleKey key1 = new DefaultRuleKeyFactory(0, hashLoader, resolver, ruleFinder).build(symlinkTreeBuildRule);
RuleKey key2 = new DefaultRuleKeyFactory(0, hashLoader, resolver, ruleFinder).build(modifiedSymlinkTreeBuildRule);
assertNotEquals(key1, key2);
}
use of com.facebook.buck.util.cache.StackedFileHashCache in project buck by facebook.
the class HeaderVerificationTest method getRuleKey.
private RuleKey getRuleKey(HeaderVerification headerVerification) {
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()));
SourcePathResolver resolver = new SourcePathResolver(ruleFinder);
FileHashCache fileHashCache = new StackedFileHashCache(ImmutableList.of(DefaultFileHashCache.createDefaultFileHashCache(new FakeProjectFilesystem())));
DefaultRuleKeyFactory factory = new DefaultRuleKeyFactory(0, fileHashCache, resolver, ruleFinder);
RuleKeyBuilder<RuleKey> builder = new UncachedRuleKeyBuilder(ruleFinder, resolver, fileHashCache, factory);
builder.setReflectively("headerVerification", headerVerification);
return builder.build();
}
Aggregations