use of com.google.devtools.build.lib.rules.SkylarkRuleContext in project bazel by bazelbuild.
the class SkylarkRuleContextTest method shouldGetPrerequisiteArtifacts.
@Test
public void shouldGetPrerequisiteArtifacts() throws Exception {
SkylarkRuleContext ruleContext = createRuleContext("//foo:foo");
Object result = evalRuleContextCode(ruleContext, "ruleContext.files.srcs");
assertArtifactList(result, ImmutableList.of("a.txt", "b.img"));
}
use of com.google.devtools.build.lib.rules.SkylarkRuleContext in project bazel by bazelbuild.
the class SkylarkRuleContextTest method testParamFileSuffix.
@Test
public void testParamFileSuffix() throws Exception {
SkylarkRuleContext ruleContext = createRuleContext("//foo:foo");
Object result = evalRuleContextCode(ruleContext, "ruleContext.new_file(ruleContext.files.tools[0], " + "ruleContext.files.tools[0].basename + '.params')");
PathFragment fragment = ((Artifact) result).getRootRelativePath();
assertEquals("foo/t.exe.params", fragment.getPathString());
}
use of com.google.devtools.build.lib.rules.SkylarkRuleContext in project bazel by bazelbuild.
the class SkylarkRuleContextTest method testExpandMakeVariablesShell.
@Test
public void testExpandMakeVariablesShell() throws Exception {
SkylarkRuleContext ruleContext = createRuleContext("//foo:foo");
Object result = evalRuleContextCode(ruleContext, "ruleContext.expand_make_variables('cmd', '$$ABC', {})");
assertEquals("$ABC", result);
}
use of com.google.devtools.build.lib.rules.SkylarkRuleContext in project bazel by bazelbuild.
the class SkylarkRuleContextTest method testRelativeLabelInExternalRepository.
@Test
public void testRelativeLabelInExternalRepository() throws Exception {
scratch.file("external_rule.bzl", "def _impl(ctx):", " return", "external_rule = rule(", " implementation = _impl,", " attrs = {", " 'internal_dep': attr.label(default = Label('//:dep'))", " }", ")");
scratch.file("BUILD", "filegroup(name='dep')");
scratch.file("/r/a/BUILD", "load('/external_rule', 'external_rule')", "external_rule(name='r')");
scratch.overwriteFile("WORKSPACE", new ImmutableList.Builder<String>().addAll(analysisMock.getWorkspaceContents(mockToolsConfig)).add("local_repository(name='r', path='/r')").build());
// Repository shuffling messes with toolchain labels.
invalidatePackages(/*alsoConfigs=*/
false);
SkylarkRuleContext context = createRuleContext("@r//a:r");
Label depLabel = (Label) evalRuleContextCode(context, "ruleContext.attr.internal_dep.label");
assertThat(depLabel).isEqualTo(Label.parseAbsolute("//:dep"));
}
use of com.google.devtools.build.lib.rules.SkylarkRuleContext in project bazel by bazelbuild.
the class SkylarkRuleContextTest method testExpandMakeVariables.
@Test
public void testExpandMakeVariables() throws Exception {
SkylarkRuleContext ruleContext = createRuleContext("//foo:foo");
Object result = evalRuleContextCode(ruleContext, "ruleContext.expand_make_variables('cmd', '$(ABC)', {'ABC': 'DEF'})");
assertEquals("DEF", result);
}
Aggregations