aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules
diff options
context:
space:
mode:
authorGravatar Daniel Wagner-Hall <danielwh@google.com>2015-04-29 17:47:41 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2015-04-29 18:47:19 +0000
commitc6ab109e476f2661870114b1f8d1c535c19047ad (patch)
treefaeea5da8fd9fcf47a648a2e8fb669ddddfefd06 /src/main/java/com/google/devtools/build/lib/rules
parent3078a7332f388c37350669a77e4596059e7248a1 (diff)
ios_test: Export device-specific information on a provider
-- MOS_MIGRATED_REVID=92366919
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ExperimentalIosTestRule.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/IosDeviceProvider.java15
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/TestSupport.java33
3 files changed, 30 insertions, 22 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ExperimentalIosTestRule.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ExperimentalIosTestRule.java
index f26b8468aa..babed00135 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ExperimentalIosTestRule.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ExperimentalIosTestRule.java
@@ -45,6 +45,10 @@ public final class ExperimentalIosTestRule implements RuleDefinition {
<!-- #END_BLAZE_RULE.IMPLICIT_OUTPUTS -->*/
.setImplicitOutputsFunction(
ImplicitOutputsFunction.fromFunctions(ReleaseBundlingSupport.IPA, XcodeSupport.PBXPROJ))
+ .override(attr(IosTest.TARGET_DEVICE, LABEL)
+ .allowedFileTypes()
+ .allowedRuleClasses("ios_device")
+ .value(env.getLabel("//tools/objc/sim_devices:default")))
.add(attr("$test_template", LABEL)
.value(env.getLabel("//tools/objc:ios_test.sh.bazel_template")))
.build();
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IosDeviceProvider.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IosDeviceProvider.java
index 6f01e11fbc..e729a235c4 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/IosDeviceProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/IosDeviceProvider.java
@@ -15,9 +15,13 @@
package com.google.devtools.build.lib.rules.objc;
import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.analysis.TransitiveInfoProvider;
+import com.google.devtools.build.lib.analysis.actions.TemplateExpansionAction.Substitution;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
+import java.util.List;
+
/**
* Provider that describes a simulator device.
*/
@@ -70,4 +74,15 @@ public final class IosDeviceProvider implements TransitiveInfoProvider {
public String getLocale() {
return locale;
}
+
+ /**
+ * Returns a list of substitutions which should be performed to the test runner script, to fill
+ * in device-specific data which may be required in order to run tests.
+ */
+ public List<Substitution> getSubstitutionsForTestRunnerScript() {
+ return ImmutableList.of(
+ Substitution.of("%(device_type)s", getType()),
+ Substitution.of("%(simulator_sdk)s", getIosVersion())
+ );
+ }
}
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 70c047f8b7..abf40ef21e 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
@@ -62,17 +62,18 @@ class TestSupport {
IosDeviceProvider targetDevice = targetDevice();
- List<Substitution> substitutions = ImmutableList.of(
- Substitution.of("%(test_app_ipa)s", testIpa.getRootRelativePathString()),
- Substitution.of("%(test_app_name)s", baseNameWithoutIpa(testIpa)),
+ List<Substitution> substitutions = new ImmutableList.Builder<Substitution>()
+ .add(Substitution.of("%(test_app_ipa)s", testIpa.getRootRelativePathString()))
+ .add(Substitution.of("%(test_app_name)s", baseNameWithoutIpa(testIpa)))
- Substitution.of("%(xctest_app_ipa)s", xctestIpa.getRootRelativePathString()),
- Substitution.of("%(xctest_app_name)s", baseNameWithoutIpa(xctestIpa)),
+ .add(Substitution.of("%(xctest_app_ipa)s", xctestIpa.getRootRelativePathString()))
+ .add(Substitution.of("%(xctest_app_name)s", baseNameWithoutIpa(xctestIpa)))
- Substitution.of("%(iossim_path)s", iossim().getRootRelativePath().getPathString()),
- Substitution.of("%(device_type)s", targetDevice.getType()),
- Substitution.of("%(simulator_sdk)s", targetDevice.getIosVersion())
- );
+ .add(Substitution.of("%(iossim_path)s", iossim().getRootRelativePath().getPathString()))
+
+ .addAll(targetDevice.getSubstitutionsForTestRunnerScript())
+
+ .build();
Artifact template = ruleContext.getPrerequisiteArtifact("$test_template", Mode.TARGET);
@@ -81,19 +82,7 @@ class TestSupport {
}
private IosDeviceProvider targetDevice() {
- IosDeviceProvider targetDevice =
- ruleContext.getPrerequisite("target_device", Mode.TARGET, IosDeviceProvider.class);
- if (targetDevice == null) {
- ObjcConfiguration objcConfiguration = ObjcRuleClasses.objcConfiguration(ruleContext);
- targetDevice = new IosDeviceProvider.Builder()
- // iPhone 6 should be the default, but 32-bit (i386) simulators don't support the
- // iPhone 6.
- .setType(objcConfiguration.getIosCpu().equals("x86_64") ? "iPhone 6" : "iPhone 5")
- .setIosVersion(objcConfiguration.getIosSimulatorVersion())
- .setLocale("en")
- .build();
- }
- return targetDevice;
+ return ruleContext.getPrerequisite("target_device", Mode.TARGET, IosDeviceProvider.class);
}
private Artifact testIpa() {