use of com.google.devtools.build.lib.rules.SkylarkRuleContext in project bazel by bazelbuild.
the class SkylarkRuleContextTest method testCoverageInstrumentedDoesNotMatchFilterNonDefaultLabel.
@Test
public void testCoverageInstrumentedDoesNotMatchFilterNonDefaultLabel() throws Exception {
setUpCoverageInstrumentedTest();
useConfiguration("--collect_code_coverage", "--instrumentation_filter=:foo");
SkylarkRuleContext ruleContext = createRuleContext("//test:foo");
// //test:bar does not match :foo, though //test:foo would.
Object result = evalRuleContextCode(ruleContext, "ruleContext.coverage_instrumented(ruleContext.attr.deps[0])");
assertThat((Boolean) result).isFalse();
}
use of com.google.devtools.build.lib.rules.SkylarkRuleContext in project bazel by bazelbuild.
the class SkylarkRuleContextTest method testWorkspaceName.
@Test
public void testWorkspaceName() throws Exception {
assertThat(ruleClassProvider.getRunfilesPrefix()).isNotNull();
assertThat(ruleClassProvider.getRunfilesPrefix()).isNotEmpty();
SkylarkRuleContext ruleContext = createRuleContext("//foo:foo");
Object result = evalRuleContextCode(ruleContext, "ruleContext.workspace_name");
assertSame(result, ruleClassProvider.getRunfilesPrefix());
}
use of com.google.devtools.build.lib.rules.SkylarkRuleContext in project bazel by bazelbuild.
the class SkylarkRuleContextTest method testGetRuleAttributeListValue.
@Test
public void testGetRuleAttributeListValue() throws Exception {
SkylarkRuleContext ruleContext = createRuleContext("//foo:foo");
Object result = evalRuleContextCode(ruleContext, "ruleContext.attr.outs");
assertEquals(1, ((SkylarkList) result).size());
}
use of com.google.devtools.build.lib.rules.SkylarkRuleContext in project bazel by bazelbuild.
the class SkylarkRuleContextTest method testSkylarkRuleContextStr.
@Test
public void testSkylarkRuleContextStr() throws Exception {
SkylarkRuleContext ruleContext = createRuleContext("//foo:foo");
Object result = evalRuleContextCode(ruleContext, "'%s' % ruleContext");
assertEquals("//foo:foo", result);
}
use of com.google.devtools.build.lib.rules.SkylarkRuleContext in project bazel by bazelbuild.
the class SkylarkRuleContextTest method testOutputs.
@Test
public void testOutputs() throws Exception {
SkylarkRuleContext ruleContext = createRuleContext("//foo:bar");
Iterable<?> result = (Iterable<?>) evalRuleContextCode(ruleContext, "ruleContext.outputs.outs");
assertEquals("d.txt", ((Artifact) Iterables.getOnlyElement(result)).getFilename());
}
Aggregations