use of com.google.devtools.build.lib.rules.SkylarkRuleContext in project bazel by bazelbuild.
the class SkylarkRuleContextTest method testFeatures.
@Test
public void testFeatures() throws Exception {
SkylarkRuleContext ruleContext = createRuleContext("//foo:cc_with_features");
Object result = evalRuleContextCode(ruleContext, "ruleContext.features");
assertThat((SkylarkList<?>) result).containsExactly("cc_include_scanning", "f1", "f2");
}
use of com.google.devtools.build.lib.rules.SkylarkRuleContext in project bazel by bazelbuild.
the class SkylarkRuleContextTest method testCoverageInstrumentedDoesNotMatchFilter.
@Test
public void testCoverageInstrumentedDoesNotMatchFilter() throws Exception {
setUpCoverageInstrumentedTest();
useConfiguration("--collect_code_coverage", "--instrumentation_filter=:foo");
SkylarkRuleContext ruleContext = createRuleContext("//test:bar");
Object result = evalRuleContextCode(ruleContext, "ruleContext.coverage_instrumented()");
assertThat((Boolean) result).isFalse();
}
use of com.google.devtools.build.lib.rules.SkylarkRuleContext in project bazel by bazelbuild.
the class SkylarkRuleContextTest method testGetRuleAttributeListValueNoGet.
@Test
public void testGetRuleAttributeListValueNoGet() 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 testFileWriteActionInterface.
@Test
public void testFileWriteActionInterface() throws Exception {
scratch.file("test/rules.bzl", getSimpleUnderTestDefinition("ctx.file_action(output=out, content='foo123')"), testingRuleDefinition);
scratch.file("test/BUILD", simpleBuildDefinition);
SkylarkRuleContext ruleContext = createRuleContext("//test:testing");
update("ruleContext", ruleContext);
update("file", eval("list(ruleContext.attr.dep.files)[0]"));
update("action", eval("ruleContext.attr.dep[Actions].by_file[file]"));
assertThat(eval("type(action)")).isEqualTo("Action");
Object contentUnchecked = eval("action.content");
assertThat(contentUnchecked).isInstanceOf(String.class);
assertThat(contentUnchecked).isEqualTo("foo123");
}
use of com.google.devtools.build.lib.rules.SkylarkRuleContext in project bazel by bazelbuild.
the class SkylarkRuleContextTest method testDeriveArtifactLegacy.
@Test
public void testDeriveArtifactLegacy() throws Exception {
SkylarkRuleContext ruleContext = createRuleContext("//foo:foo");
Object result = evalRuleContextCode(ruleContext, "ruleContext.new_file(ruleContext.genfiles_dir," + " 'a/b.txt')");
PathFragment fragment = ((Artifact) result).getRootRelativePath();
assertEquals("foo/a/b.txt", fragment.getPathString());
}
Aggregations