use of com.facebook.buck.rules.RuleKey in project buck by facebook.
the class AaptPackageResourcesTest method testThatChangingAssetsChangesRuleKey.
@Test
public void testThatChangingAssetsChangesRuleKey() {
// Generate a rule key for the defaults.
AaptConstructorArgs args = new AaptConstructorArgs();
RuleKey previousRuleKey = calculateRuleKey(args);
args.hasAndroidResourceDeps = ImmutableList.of(resource1);
args.assetsDirectories = ImmutableSet.of(resource1.getAssets(), justAssets.getAssets());
// AndroidBinaryGraphEnhancer directly adds resource deps that have assets and no resources to
// extraDeps.
args.extraDeps = ImmutableSortedSet.of(justAssets);
previousRuleKey = assertKeyChanged(previousRuleKey, args);
createPathSourcePath("asset1", "different_value");
previousRuleKey = assertKeyChanged(previousRuleKey, args);
createPathSourcePath("justAssets", "different_value");
previousRuleKey = assertKeyChanged(previousRuleKey, args);
}
use of com.facebook.buck.rules.RuleKey in project buck by facebook.
the class AndroidResourceFilterIntegrationTest method testStringArtifactsAreCached.
@Test
public void testStringArtifactsAreCached() throws IOException {
Assume.assumeFalse(true);
workspace.enableDirCache();
workspace.runBuckBuild("//apps/sample:app_comp_str").assertSuccess();
BuckBuildLog buildLog = workspace.getBuildLog();
Sha1HashCode androidBinaryRuleKey = buildLog.getRuleKey("//apps/sample:app_comp_str");
ArtifactCache cache = TestArtifactCaches.createDirCacheForTest(workspace.getPath("."), filesystem.getBuckPaths().getCacheDir());
Path cachedFile = DirArtifactCacheTestUtil.getPathForRuleKey(cache, new RuleKey(androidBinaryRuleKey.getHash()), Optional.empty());
Files.delete(workspace.resolve(cachedFile));
workspace.runBuckCommand("clean").assertSuccess();
workspace.runBuckBuild("//apps/sample:app_comp_str").assertSuccess();
}
use of com.facebook.buck.rules.RuleKey in project buck by facebook.
the class AndroidResourceTest method testInputRuleKeyChangesIfDependencySymbolsChanges.
@Test
public void testInputRuleKeyChangesIfDependencySymbolsChanges() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
TargetNode<?, ?> depNode = AndroidResourceBuilder.createBuilder(BuildTargetFactory.newInstance("//:dep"), filesystem).setManifest(new FakeSourcePath("manifest")).setRes(Paths.get("res")).build();
TargetNode<?, ?> resourceNode = AndroidResourceBuilder.createBuilder(BuildTargetFactory.newInstance("//:rule"), filesystem).setDeps(ImmutableSortedSet.of(depNode.getBuildTarget())).build();
TargetGraph targetGraph = TargetGraphFactory.newInstance(depNode, resourceNode);
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
AndroidResource dep = (AndroidResource) resolver.requireRule(depNode.getBuildTarget());
AndroidResource resource = (AndroidResource) resolver.requireRule(resourceNode.getBuildTarget());
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
FileHashCache fileHashCache = new StackedFileHashCache(ImmutableList.of(DefaultFileHashCache.createDefaultFileHashCache(filesystem)));
filesystem.writeContentsToPath("something", pathResolver.getRelativePath(dep.getPathToTextSymbolsFile()));
RuleKey original = new InputBasedRuleKeyFactory(0, fileHashCache, pathResolver, ruleFinder).build(resource);
fileHashCache.invalidateAll();
filesystem.writeContentsToPath("something else", pathResolver.getRelativePath(dep.getPathToTextSymbolsFile()));
RuleKey changed = new InputBasedRuleKeyFactory(0, fileHashCache, pathResolver, ruleFinder).build(resource);
assertThat(original, Matchers.not(Matchers.equalTo(changed)));
}
use of com.facebook.buck.rules.RuleKey in project buck by facebook.
the class AppleCxxPlatformsTest method constructCompileRuleKeys.
// Create and return some rule keys from a dummy source for the given platforms.
private ImmutableMap<Flavor, RuleKey> constructCompileRuleKeys(Operation operation, ImmutableMap<Flavor, AppleCxxPlatform> cxxPlatforms) {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
String source = "source.cpp";
DefaultRuleKeyFactory ruleKeyFactory = new DefaultRuleKeyFactory(0, FakeFileHashCache.createFromStrings(ImmutableMap.<String, String>builder().put("source.cpp", 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()) {
CxxSourceRuleFactory cxxSourceRuleFactory = CxxSourceRuleFactory.builder().setParams(new FakeBuildRuleParamsBuilder(target).build()).setResolver(resolver).setPathResolver(pathResolver).setRuleFinder(ruleFinder).setCxxBuckConfig(CxxPlatformUtils.DEFAULT_CONFIG).setCxxPlatform(entry.getValue().getCxxPlatform()).setPicType(CxxSourceRuleFactory.PicType.PIC).build();
CxxPreprocessAndCompile rule;
switch(operation) {
case PREPROCESS_AND_COMPILE:
rule = cxxSourceRuleFactory.createPreprocessAndCompileBuildRule(source, CxxSource.of(CxxSource.Type.CXX, new FakeSourcePath(source), ImmutableList.of()));
break;
case COMPILE:
rule = cxxSourceRuleFactory.createCompileBuildRule(source, CxxSource.of(CxxSource.Type.CXX_CPP_OUTPUT, new FakeSourcePath(source), ImmutableList.of()));
break;
default:
throw new IllegalStateException();
}
ruleKeys.put(entry.getKey(), ruleKeyFactory.build(rule));
}
return ruleKeys.build();
}
use of com.facebook.buck.rules.RuleKey in project buck by facebook.
the class HttpArtifactCacheTest method testStoreIOException.
@Test(expected = IOException.class)
public void testStoreIOException() throws Exception {
FakeProjectFilesystem filesystem = new FakeProjectFilesystem();
Path output = Paths.get("output/file");
filesystem.writeContentsToPath("data", output);
argsBuilder.setStoreClient(withMakeRequest(((path, requestBuilder) -> {
throw new IOException();
})));
HttpArtifactCache cache = new HttpArtifactCache(argsBuilder.build());
cache.storeImpl(ArtifactInfo.builder().addRuleKeys(new RuleKey("00000000000000000000000000000000")).build(), output, createFinishedEventBuilder());
cache.close();
}
Aggregations