use of com.facebook.buck.rules.keys.UncachedRuleKeyBuilder 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.rules.keys.UncachedRuleKeyBuilder 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();
}
use of com.facebook.buck.rules.keys.UncachedRuleKeyBuilder in project buck by facebook.
the class CommandToolTest method sourcePathsContributeToRuleKeys.
@Test
public void sourcePathsContributeToRuleKeys() {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
SourcePath path = new FakeSourcePath("input");
CommandTool tool = new CommandTool.Builder().addArg(SourcePathArg.of(path)).build();
FileHashCache hashCache = FakeFileHashCache.createFromStrings(ImmutableMap.of("input", Strings.repeat("a", 40)));
DefaultRuleKeyFactory ruleKeyFactory = new DefaultRuleKeyFactory(0, hashCache, pathResolver, ruleFinder);
RuleKey ruleKey = new UncachedRuleKeyBuilder(ruleFinder, pathResolver, hashCache, ruleKeyFactory).setReflectively("key", tool).build();
hashCache = FakeFileHashCache.createFromStrings(ImmutableMap.of("input", Strings.repeat("b", 40)));
ruleKeyFactory = new DefaultRuleKeyFactory(0, hashCache, pathResolver, ruleFinder);
RuleKey changedRuleKey = new UncachedRuleKeyBuilder(ruleFinder, pathResolver, hashCache, ruleKeyFactory).setReflectively("key", tool).build();
assertThat(ruleKey, Matchers.not(Matchers.equalTo(changedRuleKey)));
}
use of com.facebook.buck.rules.keys.UncachedRuleKeyBuilder in project buck by facebook.
the class SanitizedArgTest method createRuleKeyBuilder.
private RuleKeyBuilder<RuleKey> createRuleKeyBuilder() {
FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
FileHashCache fileHashCache = new StackedFileHashCache(ImmutableList.of(DefaultFileHashCache.createDefaultFileHashCache(projectFilesystem)));
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()));
SourcePathResolver resolver = new SourcePathResolver(ruleFinder);
return new UncachedRuleKeyBuilder(ruleFinder, resolver, fileHashCache, new DefaultRuleKeyFactory(0, fileHashCache, resolver, ruleFinder));
}
use of com.facebook.buck.rules.keys.UncachedRuleKeyBuilder in project buck by facebook.
the class RuleKeyTest method subclassWithNoopSetter.
@Test
public void subclassWithNoopSetter() {
class NoopSetterRuleKeyBuilder extends UncachedRuleKeyBuilder {
public NoopSetterRuleKeyBuilder(SourcePathRuleFinder ruleFinder, SourcePathResolver pathResolver, FileHashCache hashCache, RuleKeyFactory<RuleKey> defaultRuleKeyFactory) {
super(ruleFinder, pathResolver, hashCache, defaultRuleKeyFactory);
}
@Override
protected NoopSetterRuleKeyBuilder setSourcePath(SourcePath sourcePath) {
return this;
}
}
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()));
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
FileHashCache hashCache = new FakeFileHashCache(ImmutableMap.of());
RuleKeyFactory<RuleKey> ruleKeyFactory = new DefaultRuleKeyFactory(0, hashCache, pathResolver, ruleFinder);
RuleKey nullRuleKey = new NoopSetterRuleKeyBuilder(ruleFinder, pathResolver, hashCache, ruleKeyFactory).build();
RuleKey noopRuleKey = new NoopSetterRuleKeyBuilder(ruleFinder, pathResolver, hashCache, ruleKeyFactory).setReflectively("key", new FakeSourcePath("value")).build();
assertThat(noopRuleKey, is(equalTo(nullRuleKey)));
}
Aggregations