aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/objc/TestSupport.java
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-09-16 15:21:39 +0000
committerGravatar Laszlo Csomor <laszlocsomor@google.com>2016-09-19 07:34:37 +0000
commit94d35deeb44bdac33d58430d0441b34d5c5c630e (patch)
treee8b217fb0f6c6b033834bf26e816aef3afac8531 /src/main/java/com/google/devtools/build/lib/rules/objc/TestSupport.java
parentc484f19a2cf7427887d6e4c71c8534806e1ba83e (diff)
Add a specialized TransitiveInfoProviderMap to map TransitiveInfoProviders by class.
TransitiveInfoProviderMap enforces that the provider implements the interface it's keyed by and provides accessors the reduce the amount of casting. This in general reduces boilerplate throughout wherever TransitiveInfoProviders are mapped by their class. Also add shorthand for adding a provider where it only implements TransitiveInfoProvider once, reducing the redundant specification of the TransitiveInfoProvider class. Infer the class as the exclusive direct implementor of TransitiveInfoProvider to account for special cases like AutoValue and LicenseProvider. -- MOS_MIGRATED_REVID=133386336
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/objc/TestSupport.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/TestSupport.java18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/TestSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/TestSupport.java
index 50ad82d419..8dcab44fd3 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/TestSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/TestSupport.java
@@ -14,8 +14,6 @@
package com.google.devtools.build.lib.rules.objc;
-import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.SimulatorRule;
-
import com.google.common.base.Joiner;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
@@ -28,22 +26,20 @@ import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.Runfiles.Builder;
import com.google.devtools.build.lib.analysis.RunfilesProvider;
-import com.google.devtools.build.lib.analysis.TransitiveInfoProvider;
+import com.google.devtools.build.lib.analysis.TransitiveInfoProviderMap;
import com.google.devtools.build.lib.analysis.actions.TemplateExpansionAction;
import com.google.devtools.build.lib.analysis.actions.TemplateExpansionAction.Substitution;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.rules.apple.AppleConfiguration;
import com.google.devtools.build.lib.rules.apple.DottedVersion;
+import com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.SimulatorRule;
import com.google.devtools.build.lib.rules.test.InstrumentedFilesProvider;
import com.google.devtools.build.lib.rules.test.TestEnvironmentProvider;
import com.google.devtools.build.lib.syntax.Type;
import com.google.devtools.build.lib.util.FileType;
import com.google.devtools.build.lib.util.Preconditions;
-
import java.util.List;
-import java.util.Map;
-
import javax.annotation.Nullable;
/**
@@ -58,7 +54,8 @@ public class TestSupport {
/**
* Registers actions to create all files needed in order to actually run the test.
- * @throws InterruptedException
+ *
+ * @throws InterruptedException
*/
public TestSupport registerTestRunnerActions() throws InterruptedException {
registerTestScriptSubstitutionAction();
@@ -89,7 +86,7 @@ public class TestSupport {
.add(Substitution.of("%(test_app_name)s", baseNameWithoutIpa(testBundleIpa)))
.add(
Substitution.of("%(plugin_jars)s", Artifact.joinRootRelativePaths(":", plugins())));
-
+
substitutions.add(Substitution.ofSpaceSeparatedMap("%(test_env)s", testEnv));
// testHarnessIpa is the app being tested in the case where testBundleIpa is a .xctest bundle.
@@ -245,7 +242,7 @@ public class TestSupport {
* Returns any additional providers that need to be exported to the rule context to the passed
* builder.
*/
- public Map<Class<? extends TransitiveInfoProvider>, TransitiveInfoProvider> getExtraProviders() {
+ public TransitiveInfoProviderMap getExtraProviders() {
IosDeviceProvider deviceProvider =
ruleContext.getPrerequisite(IosTest.TARGET_DEVICE, Mode.TARGET, IosDeviceProvider.class);
DottedVersion xcodeVersion = deviceProvider.getXcodeVersion();
@@ -263,8 +260,7 @@ public class TestSupport {
envBuilder.put("APPLE_COVERAGE", "1");
}
- return ImmutableMap.<Class<? extends TransitiveInfoProvider>, TransitiveInfoProvider>of(
- TestEnvironmentProvider.class, new TestEnvironmentProvider(envBuilder.build()));
+ return TransitiveInfoProviderMap.of(new TestEnvironmentProvider(envBuilder.build()));
}
/**