Open source a few more analysis tests.
--
MOS_MIGRATED_REVID=92715161
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredAttributeMapper.java b/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredAttributeMapper.java
index a773cd0..59a01f3 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredAttributeMapper.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredAttributeMapper.java
@@ -13,6 +13,7 @@
// limitations under the License.
package com.google.devtools.build.lib.analysis;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.base.Verify;
import com.google.common.collect.ImmutableMap;
@@ -76,7 +77,9 @@
* <p>If you don't know how to do this, you really want to use one of the "do-it-all"
* constructors.
*/
- static ConfiguredAttributeMapper of(Rule rule, Set<ConfigMatchingProvider> configConditions) {
+ @VisibleForTesting
+ public static ConfiguredAttributeMapper of(
+ Rule rule, Set<ConfigMatchingProvider> configConditions) {
return new ConfiguredAttributeMapper(rule, configConditions);
}
diff --git a/src/main/java/com/google/devtools/build/lib/packages/AbstractAttributeMapper.java b/src/main/java/com/google/devtools/build/lib/packages/AbstractAttributeMapper.java
index 2742b1e..f142c96 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/AbstractAttributeMapper.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/AbstractAttributeMapper.java
@@ -13,6 +13,7 @@
// limitations under the License.
package com.google.devtools.build.lib.packages;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.syntax.Label;
@@ -74,7 +75,8 @@
* @throws IllegalArgumentException if the given attribute doesn't exist with the specified
* type. This happens whether or not it's a computed default.
*/
- protected <T> Attribute.ComputedDefault getComputedDefault(String attributeName, Type<T> type) {
+ @VisibleForTesting // Should be protected
+ public <T> Attribute.ComputedDefault getComputedDefault(String attributeName, Type<T> type) {
int index = getIndexWithTypeCheck(attributeName, type);
Object value = attributes.getAttributeValue(index);
if (value instanceof Attribute.ComputedDefault) {
@@ -177,7 +179,7 @@
if (!(attrValue instanceof Type.SelectorList)) {
return null;
}
- if (((Type.SelectorList) attrValue).getOriginalType() != type) {
+ if (((Type.SelectorList<?>) attrValue).getOriginalType() != type) {
throw new IllegalArgumentException("Attribute " + attributeName
+ " is not of type " + type + " in rule " + ruleLabel);
}
diff --git a/src/main/java/com/google/devtools/build/lib/packages/Package.java b/src/main/java/com/google/devtools/build/lib/packages/Package.java
index b6328a3..1b4db38 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/Package.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/Package.java
@@ -528,8 +528,8 @@
* for walking through the dependency graph of a target.
* Fails if the target is not a Rule.
*/
- @VisibleForTesting
- Rule getRule(String targetName) {
+ @VisibleForTesting // Should be package-private
+ public Rule getRule(String targetName) {
return (Rule) targets.get(targetName);
}