use of com.google.devtools.build.lib.packages.Rule in project bazel by bazelbuild.
the class IncrementalLoadingTest method testTransientErrorsInGlobbing.
@Test
public void testTransientErrorsInGlobbing() throws Exception {
Path buildFile = tester.addFile("e/BUILD", "sh_library(name = 'e', data = glob(['*.txt']))");
Path parentDir = buildFile.getParentDirectory();
tester.addFile("e/data.txt");
throwOnReaddir = parentDir;
tester.sync();
Target target = tester.getTarget("//e:e");
assertThat(((Rule) target).containsErrors()).isTrue();
GlobList<?> globList = (GlobList<?>) ((Rule) target).getAttributeContainer().getAttr("data");
assertThat(globList).isEmpty();
throwOnReaddir = null;
tester.sync();
target = tester.getTarget("//e:e");
assertThat(((Rule) target).containsErrors()).isFalse();
globList = (GlobList<?>) ((Rule) target).getAttributeContainer().getAttr("data");
assertThat(globList).containsExactly(Label.parseAbsolute("//e:data.txt"));
}
use of com.google.devtools.build.lib.packages.Rule in project bazel by bazelbuild.
the class AggregatingAttributeMapperTest method testGetReachableLabelsWithDefaultValues.
@Test
public void testGetReachableLabelsWithDefaultValues() throws Exception {
Rule rule = scratchRule("a", "myrule", "cc_binary(name = 'myrule',", " srcs = [],", " malloc = select({", " '//conditions:a': None,", " }))");
AggregatingAttributeMapper mapper = AggregatingAttributeMapper.of(rule);
assertThat(mapper.getReachableLabels("malloc", true)).containsExactly(getDefaultMallocLabel(rule), Label.create("@//conditions", "a"));
}
use of com.google.devtools.build.lib.packages.Rule in project bazel by bazelbuild.
the class AggregatingAttributeMapperTest method testGetPossibleValuesDirectAttribute.
/**
* Tests that {@link AggregatingAttributeMapper#visitAttribute} returns an
* attribute's sole value when declared directly (i.e. not as a configurable dict).
*/
@Test
public void testGetPossibleValuesDirectAttribute() throws Exception {
Rule rule = scratchRule("a", "myrule", "sh_binary(name = 'myrule',", " srcs = ['a.sh'])");
assertThat(AggregatingAttributeMapper.of(rule).visitAttribute("srcs", BuildType.LABEL_LIST)).containsExactlyElementsIn(ImmutableList.of(ImmutableList.of(Label.create("@//a", "a.sh"))));
}
use of com.google.devtools.build.lib.packages.Rule in project bazel by bazelbuild.
the class AggregatingAttributeMapperTest method testComputedDefaultWithoutConfigurableDeps.
@Test
public void testComputedDefaultWithoutConfigurableDeps() throws Exception {
Rule rule = scratchRule("x", "bb", "rule_with_computed_defaults(", " name = 'bb',", " nonconfigurable = 'swim up')");
assertThat(AggregatingAttributeMapper.of(rule).visitAttribute("$computed_default_without_configurable_deps", STRING)).containsExactly("swim up");
}
Aggregations