use of com.google.devtools.build.lib.rules.SkylarkRuleContext in project bazel by bazelbuild.
the class SkylarkRuleImplementationFunctionsTest method testRunfilesArtifactsFromDefaultAndFiles.
@Test
public void testRunfilesArtifactsFromDefaultAndFiles() throws Exception {
SkylarkRuleContext ruleContext = createRuleContext("//foo:bar");
Object result = evalRuleContextCode(ruleContext, "artifacts = ruleContext.files.srcs", // is an ImmutableList and Skylark interprets it as a tuple.
"ruleContext.runfiles(collect_default = True, files = artifacts)");
// From DEFAULT only libjl.jar comes, see testRunfilesAddFromDependencies().
assertEquals(ActionsTestUtil.baseArtifactNames(getRunfileArtifacts(result)), ImmutableList.of("libjl.jar", "gl.a", "gl.gcgox"));
}
use of com.google.devtools.build.lib.rules.SkylarkRuleContext in project bazel by bazelbuild.
the class SkylarkRuleImplementationFunctionsTest method testCodeCoverageConfigurationAccess.
@Test
public void testCodeCoverageConfigurationAccess() throws Exception {
SkylarkRuleContext ctx = createRuleContext("//foo:baz");
boolean coverage = (Boolean) evalRuleContextCode(ctx, "ruleContext.configuration.coverage_enabled");
assertEquals(coverage, ctx.getRuleContext().getConfiguration().isCodeCoverageEnabled());
}
use of com.google.devtools.build.lib.rules.SkylarkRuleContext in project bazel by bazelbuild.
the class SkylarkRuleImplementationFunctionsTest method testRunfilesAddFromDependencies.
@Test
public void testRunfilesAddFromDependencies() throws Exception {
SkylarkRuleContext ruleContext = createRuleContext("//foo:bar");
Object result = evalRuleContextCode(ruleContext, "ruleContext.runfiles(collect_default = True)");
assertThat(ActionsTestUtil.baseArtifactNames(getRunfileArtifacts(result))).contains("libjl.jar");
}
use of com.google.devtools.build.lib.rules.SkylarkRuleContext in project bazel by bazelbuild.
the class SkylarkRuleImplementationFunctionsTest method testCreateSpawnActionUnknownParam.
@Test
public void testCreateSpawnActionUnknownParam() throws Exception {
SkylarkRuleContext ruleContext = createRuleContext("//foo:foo");
checkErrorContains(ruleContext, "unexpected keyword 'bad_param' in call to action(self: ctx, *, ", "ruleContext.action(outputs=[], bad_param = 'some text')");
}
use of com.google.devtools.build.lib.rules.SkylarkRuleContext in project bazel by bazelbuild.
the class SkylarkRuleImplementationFunctionsTest method testEmptyLabelListTypeAttrInCtx.
@Test
public void testEmptyLabelListTypeAttrInCtx() throws Exception {
SkylarkRuleContext ctx = createRuleContext("//foo:baz");
Object result = evalRuleContextCode(ctx, "ruleContext.attr.srcs");
assertEquals(MutableList.EMPTY, result);
}
Aggregations