diff options
author | 2016-02-03 21:24:45 +0000 | |
---|---|---|
committer | 2016-02-03 22:07:25 +0000 | |
commit | a09fb73fddc936cc48821b0bcbfb8b4cbf38eb20 (patch) | |
tree | bcf081da53b72dc2a4207b2cdd159b184725b729 /src/main/java/com/google/devtools/build/lib/rules | |
parent | 9e1a604c4d5a754821d8ca571aa2dca9349e450a (diff) |
Make xctest extension for test bundles that have xctest=true defined. (It used to be .app)
--
MOS_MIGRATED_REVID=113775781
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
3 files changed, 31 insertions, 18 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IosTest.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IosTest.java index e0a748f701..92b3f9d669 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/IosTest.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/IosTest.java @@ -90,9 +90,11 @@ public final class IosTest implements RuleConfiguredTargetFactory { XcodeProductType productType = getProductType(ruleContext); ExtraLinkArgs extraLinkArgs; Iterable<Artifact> extraLinkInputs; + String bundleFormat; if (!isXcTest(ruleContext)) { extraLinkArgs = new ExtraLinkArgs(); extraLinkInputs = ImmutableList.of(); + bundleFormat = ReleaseBundlingSupport.APP_BUNDLE_DIR_FORMAT; } else { XcodeProvider appIpaXcodeProvider = ruleContext.getPrerequisite(XCTEST_APP, Mode.TARGET, XcodeProvider.class); @@ -113,7 +115,8 @@ public final class IosTest implements RuleConfiguredTargetFactory { "-bundle_loader", bundleLoader.getExecPathString()); extraLinkInputs = ImmutableList.of(bundleLoader); - + bundleFormat = ReleaseBundlingSupport.XCTEST_BUNDLE_DIR_FORMAT; + filesToBuild.add(testApp.getIpa()); } @@ -129,7 +132,7 @@ public final class IosTest implements RuleConfiguredTargetFactory { ruleContext, common.getObjcProvider(), LinkedBinary.LOCAL_AND_DEPENDENCIES, - ReleaseBundlingSupport.APP_BUNDLE_DIR_FORMAT, + bundleFormat, objcConfiguration.getMinimumOs()) .registerActions() .addXcodeSettings(xcodeProviderBuilder) diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java index b337fc9b8b..6741b927d1 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java @@ -103,6 +103,8 @@ public final class ReleaseBundlingSupport { @VisibleForTesting static final String APP_BUNDLE_DIR_FORMAT = "Payload/%s.app"; @VisibleForTesting + static final String XCTEST_BUNDLE_DIR_FORMAT = "Payload/%s.xctest"; + @VisibleForTesting static final String EXTENSION_BUNDLE_DIR_FORMAT = "PlugIns/%s.appex"; @VisibleForTesting static final String FRAMEWORK_BUNDLE_DIR_FORMAT = "Frameworks/%s.framework"; 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 ce49995630..0cdbf79de4 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 @@ -69,31 +69,32 @@ public class TestSupport { } private void registerTestScriptSubstitutionAction() throws InterruptedException { - // testIpa is the app actually containing the tests - Artifact testIpa = testIpa(); + // testBundleIpa is the bundle actually containing the tests. + Artifact testBundleIpa = testBundleIpa(); String runMemleaks = ruleContext.getFragment(ObjcConfiguration.class).runMemleaks() ? "true" : "false"; Map<String, String> testEnv = ruleContext.getConfiguration().getTestEnv(); - + // The substitutions below are common for simulator and lab device. ImmutableList.Builder<Substitution> substitutions = new ImmutableList.Builder<Substitution>() .add(Substitution.of("%(memleaks)s", runMemleaks)) - .add(Substitution.of("%(test_app_ipa)s", testIpa.getRootRelativePathString())) - .add(Substitution.of("%(test_app_name)s", baseNameWithoutIpa(testIpa))) + .add(Substitution.of("%(test_app_ipa)s", testBundleIpa.getRootRelativePathString())) + .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)); - - // xctestIpa is the app bundle being tested - Optional<Artifact> xctestIpa = xctestIpa(); - if (xctestIpa.isPresent()) { + + // testHarnessIpa is the app being tested in the case where testBundleIpa is a .xctest bundle. + Optional<Artifact> testHarnessIpa = testHarnessIpa(); + if (testHarnessIpa.isPresent()) { substitutions - .add(Substitution.of("%(xctest_app_ipa)s", xctestIpa.get().getRootRelativePathString())) - .add(Substitution.of("%(xctest_app_name)s", baseNameWithoutIpa(xctestIpa.get()))); + .add(Substitution.of("%(xctest_app_ipa)s", + testHarnessIpa.get().getRootRelativePathString())) + .add(Substitution.of("%(xctest_app_name)s", baseNameWithoutIpa(testHarnessIpa.get()))); } else { substitutions .add(Substitution.of("%(xctest_app_ipa)s", "")) @@ -140,11 +141,18 @@ public class TestSupport { "target_device", Mode.TARGET, IosTestSubstitutionProvider.class); } - private Artifact testIpa() throws InterruptedException { + /* + * The IPA of the bundle that contains the tests. Typically will be a .xctest bundle, but in the + * case where the xctest attribute is false, it will be a .app bundle. + */ + private Artifact testBundleIpa() throws InterruptedException { return ruleContext.getImplicitOutputArtifact(ReleaseBundlingSupport.IPA); } - private Optional<Artifact> xctestIpa() { + /* + * The IPA of the testHarness in the case where the testBundleIpa is an .xctest bundle. + */ + private Optional<Artifact> testHarnessIpa() { FileProvider fileProvider = ruleContext.getPrerequisite("xctest_app", Mode.TARGET, FileProvider.class); if (fileProvider == null) { @@ -209,8 +217,8 @@ public class TestSupport { */ public TestSupport addRunfiles(Builder runfilesBuilder) throws InterruptedException { runfilesBuilder - .addArtifact(testIpa()) - .addArtifacts(xctestIpa().asSet()) + .addArtifact(testBundleIpa()) + .addArtifacts(testHarnessIpa().asSet()) .addArtifact(generatedTestScript()) .addTransitiveArtifacts(plugins()); if (!runWithLabDevice()) { @@ -283,7 +291,7 @@ public class TestSupport { */ public TestSupport addFilesToBuild(NestedSetBuilder<Artifact> builder) throws InterruptedException { - builder.add(testIpa()).addAll(xctestIpa().asSet()); + builder.add(testBundleIpa()).addAll(testHarnessIpa().asSet()); return this; } |