Search in sources :

Example 21 with RuleClass

use of com.google.devtools.build.lib.packages.RuleClass in project bazel by bazelbuild.

the class SkylarkRuleClassFunctionsTest method testRuleLabelDefaultValue.

@Test
public void testRuleLabelDefaultValue() throws Exception {
    evalAndExport("def impl(ctx): return None\n" + "r1 = rule(impl, attrs = {'a1': " + "attr.label(default = Label('//foo:foo'), allow_files=True)})");
    RuleClass c = ((RuleFunction) lookup("r1")).getRuleClass();
    Attribute a = c.getAttributeByName("a1");
    assertThat(a.getDefaultValueForTesting()).isInstanceOf(Label.class);
    assertEquals("//foo:foo", a.getDefaultValueForTesting().toString());
}
Also used : Attribute(com.google.devtools.build.lib.packages.Attribute) RuleFunction(com.google.devtools.build.lib.rules.SkylarkRuleClassFunctions.RuleFunction) RuleClass(com.google.devtools.build.lib.packages.RuleClass) Test(org.junit.Test)

Example 22 with RuleClass

use of com.google.devtools.build.lib.packages.RuleClass in project bazel by bazelbuild.

the class SkylarkRuleClassFunctionsTest method testOutputToGenfiles.

@Test
public void testOutputToGenfiles() throws Exception {
    evalAndExport("def impl(ctx): pass", "r1 = rule(impl, output_to_genfiles=True)");
    RuleClass c = ((RuleFunction) lookup("r1")).getRuleClass();
    assertFalse(c.hasBinaryOutput());
}
Also used : RuleFunction(com.google.devtools.build.lib.rules.SkylarkRuleClassFunctions.RuleFunction) RuleClass(com.google.devtools.build.lib.packages.RuleClass) Test(org.junit.Test)

Example 23 with RuleClass

use of com.google.devtools.build.lib.packages.RuleClass in project bazel by bazelbuild.

the class AbstractAttributeMapperTest method initializeRuleAndMapper.

@Before
public final void initializeRuleAndMapper() throws Exception {
    rule = scratchRule("p", "myrule", "cc_binary(name = 'myrule',", "          srcs = ['a', 'b', 'c'])");
    RuleClass ruleClass = rule.getRuleClassObject();
    mapper = new TestMapper(rule.getPackage(), ruleClass, rule.getLabel(), rule.getAttributeContainer());
}
Also used : RuleClass(com.google.devtools.build.lib.packages.RuleClass) Before(org.junit.Before)

Aggregations

RuleClass (com.google.devtools.build.lib.packages.RuleClass)23 RuleFunction (com.google.devtools.build.lib.rules.SkylarkRuleClassFunctions.RuleFunction)9 Test (org.junit.Test)9 Attribute (com.google.devtools.build.lib.packages.Attribute)6 ConfiguredRuleClassProvider (com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider)2 Rule (com.google.devtools.build.lib.packages.Rule)2 ArrayList (java.util.ArrayList)2 NoBuildEvent (com.google.devtools.build.lib.analysis.NoBuildEvent)1 ConfigurationFragmentFactory (com.google.devtools.build.lib.analysis.config.ConfigurationFragmentFactory)1 FragmentOptions (com.google.devtools.build.lib.analysis.config.FragmentOptions)1 Label (com.google.devtools.build.lib.cmdline.Label)1 TargetParsingException (com.google.devtools.build.lib.cmdline.TargetParsingException)1 AdvertisedProviderSet (com.google.devtools.build.lib.packages.AdvertisedProviderSet)1 Aspect (com.google.devtools.build.lib.packages.Aspect)1 FileTarget (com.google.devtools.build.lib.packages.FileTarget)1 ImplicitOutputsFunction (com.google.devtools.build.lib.packages.ImplicitOutputsFunction)1 PackageFactory (com.google.devtools.build.lib.packages.PackageFactory)1 RawAttributeMapper (com.google.devtools.build.lib.packages.RawAttributeMapper)1 RuleClassProvider (com.google.devtools.build.lib.packages.RuleClassProvider)1 AllowedRuleClassInfo (com.google.devtools.build.lib.query2.proto.proto2api.Build.AllowedRuleClassInfo)1