diff options
author | 2015-03-05 18:19:47 +0000 | |
---|---|---|
committer | 2015-03-05 18:31:55 +0000 | |
commit | 4ebe224ce0ee12c0f8c18a4440ba982a340b1375 (patch) | |
tree | 1a18140f3a3889540e6eacad9c91402ed14eb809 /src/main/java/com/google | |
parent | 8c8be38b0d8b342ef2cfe63874f3ae31f7b336b7 (diff) |
RELNOTES: Added ios_memleaks flag which when enabled will check the test application for memory leaks.
--
MOS_MIGRATED_REVID=87839695
Diffstat (limited to 'src/main/java/com/google')
3 files changed, 20 insertions, 0 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 87e3c209e7..1c94e9e14f 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 @@ -45,6 +45,7 @@ public abstract class IosTest implements RuleConfiguredTargetFactory { public static final String TARGET_DEVICE = "target_device"; public static final String IS_XCTEST = "xctest"; public static final String XCTEST_APP = "xctest_app"; + public static final String MEMLEAKS_DEP = "$memleaks_dep"; @VisibleForTesting public static final String REQUIRES_SOURCE_ERROR = @@ -166,6 +167,13 @@ public abstract class IosTest implements RuleConfiguredTargetFactory { extraDepObjcProviders.add(xcTestAppProvider(ruleContext).getObjcProvider()); } + // Add the memleaks library if the --ios_memleaks flag is true. The library pauses the test + // after all tests have been executed so that leaks can be run. + ObjcConfiguration config = ruleContext.getFragment(ObjcConfiguration.class); + if (config.runMemleaks()) { + extraDepObjcProviders + .add(ruleContext.getPrerequisite(MEMLEAKS_DEP, Mode.TARGET, ObjcProvider.class)); + } return ObjcLibrary.common(ruleContext, extraSdkFrameworks, /*alwayslink=*/false, new ObjcLibrary.ExtraImportLibraries(ObjcRuleClasses.j2ObjcLibraries(ruleContext)), extraDepObjcProviders); diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java index 0efcff88d2..6ce8f86f99 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java @@ -80,6 +80,12 @@ public class help = "Minimum compatible iOS version for target simulators and devices.") public String iosMinimumOs; + @Option(name = "ios_memleaks", + defaultValue = "false", + category = "misc", + help = "Enable checking for memory leaks in ios_test targets.") + public boolean runMemleaks; + @VisibleForTesting static final String DEFAULT_MINIMUM_IOS = "7.0"; @Override diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java index d1c77e30e2..3473e4b742 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java @@ -46,6 +46,7 @@ public class ObjcConfiguration extends BuildConfiguration.Fragment { private final String iosCpu; private final String xcodeOptions; private final boolean generateDebugSymbols; + private final boolean runMemleaks; private final List<String> copts; private final CompilationMode compilationMode; @@ -57,6 +58,7 @@ public class ObjcConfiguration extends BuildConfiguration.Fragment { this.iosCpu = Preconditions.checkNotNull(objcOptions.iosCpu, "iosCpu"); this.xcodeOptions = Preconditions.checkNotNull(objcOptions.xcodeOptions, "xcodeOptions"); this.generateDebugSymbols = objcOptions.generateDebugSymbols; + this.runMemleaks = objcOptions.runMemleaks; this.copts = ImmutableList.copyOf(objcOptions.copts); this.compilationMode = Preconditions.checkNotNull(options.compilationMode, "compilationMode"); } @@ -94,6 +96,10 @@ public class ObjcConfiguration extends BuildConfiguration.Fragment { return generateDebugSymbols; } + public boolean runMemleaks() { + return runMemleaks; + } + /** * Returns the current compilation mode. */ |