Skip to content

Commit

Permalink
Add warning that android_robolectric_test is deprecated in favor of a…
Browse files Browse the repository at this point in the history
…ndroid_local_test.

RELNOTES: None
PiperOrigin-RevId: 186699885
  • Loading branch information
dkelmer authored and Copybara-Service committed Feb 23, 2018
1 parent b2a9e78 commit ec77ac9
Showing 1 changed file with 54 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.google.devtools.build.lib.packages.AggregatingAttributeMapper;
import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException;
import com.google.devtools.build.lib.packages.Target;
import com.google.devtools.build.lib.rules.android.AndroidConfiguration.AndroidAaptVersion.AndroidRobolectricTestDeprecationLevel;
import com.google.devtools.build.lib.rules.cpp.CppConfiguration.DynamicMode;
import com.google.devtools.build.lib.rules.cpp.CppOptions.DynamicModeConverter;
import com.google.devtools.build.lib.rules.cpp.CppOptions.LibcTopLabelConverter;
Expand Down Expand Up @@ -96,6 +97,14 @@ public AndroidAaptConverter() {
}
}

/** Converter for {@link AndroidRobolectricTestDeprecationLevel} */
public static final class AndroidRobolectricTestDeprecationLevelConverter
extends EnumConverter<AndroidRobolectricTestDeprecationLevel> {
public AndroidRobolectricTestDeprecationLevelConverter() {
super(AndroidRobolectricTestDeprecationLevel.class, "android robolectric deprecation level");
}
}

/**
* Value used to avoid multiple configurations from conflicting.
*
Expand Down Expand Up @@ -199,6 +208,30 @@ public static AndroidAaptVersion fromString(String value) {
return null;
}

/** android_robolectric_test deprecation levels */
public enum AndroidRobolectricTestDeprecationLevel {
OFF,
WARNING,
DEPRECATED;

public static List<String> getAttributeValues() {
return ImmutableList.of(
OFF.name().toLowerCase(),
WARNING.name().toLowerCase(),
DEPRECATED.name().toLowerCase());
}

public static AndroidRobolectricTestDeprecationLevel fromString(String value) {
for (AndroidRobolectricTestDeprecationLevel level :
AndroidRobolectricTestDeprecationLevel.values()) {
if (level.name().equals(value)) {
return level;
}
}
return null;
}
}

// TODO(corysmith): Move to ApplicationManifest when no longer needed as a public function.
@Nullable
public static AndroidAaptVersion chooseTargetAaptVersion(RuleContext ruleContext)
Expand Down Expand Up @@ -786,6 +819,18 @@ public static class Options extends FragmentOptions {
)
public boolean fixedResourceNeverlinking;

@Option(
name = "android_robolectric_test_deprecation_level",
defaultValue = "off",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BUILD_FILE_SEMANTICS},
converter = AndroidRobolectricTestDeprecationLevelConverter.class,
help =
"Determine the deprecation level of android_robolectric_test. Can be 'off', "
+ "'warning', or 'deprecated'."
)
public AndroidRobolectricTestDeprecationLevel robolectricTestDeprecationLevel;

@Override
public FragmentOptions getHost() {
Options host = (Options) super.getHost();
Expand Down Expand Up @@ -868,6 +913,7 @@ public ImmutableSet<Class<? extends FragmentOptions>> requiredOptions() {
private final boolean useParallelDex2Oat;
private final boolean skipParsingAction;
private final boolean fixedResourceNeverlinking;
private final AndroidRobolectricTestDeprecationLevel robolectricTestDeprecationLevel;

AndroidConfiguration(Options options) throws InvalidConfigurationException {
this.sdk = options.sdk;
Expand Down Expand Up @@ -905,6 +951,7 @@ public ImmutableSet<Class<? extends FragmentOptions>> requiredOptions() {
this.useParallelDex2Oat = options.useParallelDex2Oat;
this.skipParsingAction = options.skipParsingAction;
this.fixedResourceNeverlinking = options.fixedResourceNeverlinking;
this.robolectricTestDeprecationLevel = options.robolectricTestDeprecationLevel;

if (incrementalDexingShardsAfterProguard < 0) {
throw new InvalidConfigurationException(
Expand Down Expand Up @@ -954,7 +1001,8 @@ public ImmutableSet<Class<? extends FragmentOptions>> requiredOptions() {
boolean throwOnResourceConflict,
boolean useParallelDex2Oat,
boolean skipParsingAction,
boolean fixedResourceNeverlinking) {
boolean fixedResourceNeverlinking,
AndroidRobolectricTestDeprecationLevel robolectricTestDeprecationLevel) {
this.sdk = sdk;
this.cpu = cpu;
this.useIncrementalNativeLibs = useIncrementalNativeLibs;
Expand Down Expand Up @@ -987,6 +1035,7 @@ public ImmutableSet<Class<? extends FragmentOptions>> requiredOptions() {
this.useParallelDex2Oat = useParallelDex2Oat;
this.skipParsingAction = skipParsingAction;
this.fixedResourceNeverlinking = fixedResourceNeverlinking;
this.robolectricTestDeprecationLevel = robolectricTestDeprecationLevel;
}

public String getCpu() {
Expand Down Expand Up @@ -1134,6 +1183,10 @@ public boolean fixedResourceNeverlinking() {
return this.fixedResourceNeverlinking;
}

public AndroidRobolectricTestDeprecationLevel getRobolectricTestDeprecationLevel() {
return robolectricTestDeprecationLevel;
}

@Override
public void addGlobalMakeVariables(ImmutableMap.Builder<String, String> globalMakeEnvBuilder) {
globalMakeEnvBuilder.put("ANDROID_CPU", cpu);
Expand Down

0 comments on commit ec77ac9

Please sign in to comment.