use of com.google.devtools.build.lib.analysis.FileConfiguredTarget in project bazel by bazelbuild.
the class SkylarkIntegrationTest method testActions.
@Test
public void testActions() throws Exception {
scratch.file("test/skylark/extension.bzl", "def custom_rule_impl(ctx):", " attr1 = ctx.files.attr1", " output = ctx.outputs.o", " ctx.action(", " inputs = attr1,", " outputs = [output],", " command = 'echo')", "", "custom_rule = rule(implementation = custom_rule_impl,", " attrs = {'attr1': attr.label_list(mandatory=True, allow_files=True)},", " outputs = {'o': 'o.txt'})");
scratch.file("test/skylark/BUILD", "load('/test/skylark/extension', 'custom_rule')", "", "custom_rule(name = 'cr', attr1 = [':a.txt'])");
getConfiguredTarget("//test/skylark:cr");
FileConfiguredTarget target = getFileConfiguredTarget("//test/skylark:o.txt");
assertThat(ActionsTestUtil.baseArtifactNames(getGeneratingAction(target.getArtifact()).getInputs())).containsExactly("a.txt");
}
use of com.google.devtools.build.lib.analysis.FileConfiguredTarget in project bazel by bazelbuild.
the class AarImportTest method testExportsPropagatesResources.
@Test
public void testExportsPropagatesResources() throws Exception {
FileConfiguredTarget appTarget = getFileConfiguredTarget("//java:app.apk");
Set<Artifact> artifacts = actionsTestUtil().artifactClosureOf(appTarget.getArtifact());
ConfiguredTarget bar = getConfiguredTarget("//a:bar");
Artifact barResources = ActionsTestUtil.getFirstArtifactEndingWith(artifacts, "_aar/unzipped/resources/bar");
assertThat(barResources).isNotNull();
assertThat(barResources.getArtifactOwner().getLabel()).isEqualTo(bar.getLabel());
ConfiguredTarget foo = getConfiguredTarget("//a:foo");
Artifact fooResources = ActionsTestUtil.getFirstArtifactEndingWith(artifacts, "_aar/unzipped/resources/foo");
assertThat(fooResources).isNotNull();
assertThat(fooResources.getArtifactOwner().getLabel()).isEqualTo(foo.getLabel());
}
use of com.google.devtools.build.lib.analysis.FileConfiguredTarget in project bazel by bazelbuild.
the class GenRuleConfiguredTargetTest method testDependenciesViaFiles.
/**
* Ensure that the actions / artifacts created by genrule dependencies allow us to follow the
* chain of generated files backward.
*/
@Test
public void testDependenciesViaFiles() throws Exception {
scratch.file("foo/BUILD", "genrule(name = 'bar',", " srcs = ['bar_in.txt'],", " cmd = 'touch $(OUTS)',", " outs = ['bar_out.txt'])", "genrule(name = 'baz',", " srcs = ['bar_out.txt'],", " cmd = 'touch $(OUTS)',", " outs = ['baz_out.txt'])");
FileConfiguredTarget bazOutTarget = getFileConfiguredTarget("//foo:baz_out.txt");
Action bazAction = getGeneratingAction(bazOutTarget.getArtifact());
Artifact barOut = bazAction.getInputs().iterator().next();
assertTrue(barOut.getExecPath().endsWith(new PathFragment("foo/bar_out.txt")));
Action barAction = getGeneratingAction(barOut);
Artifact barIn = barAction.getInputs().iterator().next();
assertTrue(barIn.getExecPath().endsWith(new PathFragment("foo/bar_in.txt")));
}
use of com.google.devtools.build.lib.analysis.FileConfiguredTarget in project bazel by bazelbuild.
the class FilegroupConfiguredTargetTest method testDependencyGraph.
@Test
public void testDependencyGraph() throws Exception {
scratch.file("java/com/google/test/BUILD", "java_binary(name = 'test_app',", " resources = [':data'],", " create_executable = 0,", " srcs = ['InputFile.java', 'InputFile2.java'])", "filegroup(name = 'data',", " srcs = ['b.txt', 'a.txt'])");
FileConfiguredTarget appOutput = getFileConfiguredTarget("//java/com/google/test:test_app.jar");
assertEquals("b.txt a.txt", actionsTestUtil().predecessorClosureOf(appOutput.getArtifact(), FileType.of(".txt")));
}
use of com.google.devtools.build.lib.analysis.FileConfiguredTarget in project bazel by bazelbuild.
the class AarImportTest method testExportsPropagatesMergedAarJars.
@Test
public void testExportsPropagatesMergedAarJars() throws Exception {
FileConfiguredTarget appTarget = getFileConfiguredTarget("//java:app.apk");
Set<Artifact> artifacts = actionsTestUtil().artifactClosureOf(appTarget.getArtifact());
ConfiguredTarget bar = getConfiguredTarget("//a:bar");
Artifact barClassesJar = ActionsTestUtil.getFirstArtifactEndingWith(artifacts, "bar/classes_and_libs_merged.jar");
// Verify that bar/classes_and_libs_merged.jar was in the artifact closure.
assertThat(barClassesJar).isNotNull();
assertThat(barClassesJar.getArtifactOwner().getLabel()).isEqualTo(bar.getLabel());
ConfiguredTarget foo = getConfiguredTarget("//a:foo");
Artifact fooClassesJar = ActionsTestUtil.getFirstArtifactEndingWith(artifacts, "foo/classes_and_libs_merged.jar");
// Verify that foo/classes_and_libs_merged.jar was in the artifact closure.
assertThat(fooClassesJar).isNotNull();
assertThat(fooClassesJar.getArtifactOwner().getLabel()).isEqualTo(foo.getLabel());
ConfiguredTarget baz = getConfiguredTarget("//java:baz.jar");
Artifact bazJar = ActionsTestUtil.getFirstArtifactEndingWith(artifacts, "baz.jar");
// Verify that baz.jar was in the artifact closure
assertThat(bazJar).isNotNull();
assertThat(bazJar.getArtifactOwner().getLabel()).isEqualTo(baz.getLabel());
}
Aggregations