Run an XCTest unit-test bundle with leak detection (CI-runnable)
detectLeaksInXCTestDetects new retain cycles in XCTest unit tests by diffing before and after .memgraph snapshots, failing when cycles appear outside the allowlist.
Instructions
[mg.ci] Sibling to detectLeaksInXCUITest, targeting XCTest unit-test schemes. Build for testing, launch the test bundle with an optional -only-testing:<TestTarget>/<TestClass>[/<testMethod>] filter, poll for the runner process (xctest by default, configurable via processName for app-hosted test bundles), capture a baseline .memgraph once the runner appears, run the test to completion, capture an after .memgraph, and diff. Returns passed: false when new ROOT CYCLE blocks appear that are not in the allowlistPatterns list. Per-test granularity: call once per test method with different testCaseFilter values; aggregation is the caller's responsibility, keeping the response tied to a single, well-defined before/after pair. If the runner exits before the after-capture window (common for fast unit tests with no host), the response carries an explicit failureReason pointing at the tearDown workaround. Designed for CI gating: non-zero exit code on failure.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspace | No | Path to the `.xcworkspace`. Mutually exclusive with `project`. | |
| project | No | Path to the `.xcodeproj`. Mutually exclusive with `workspace`. | |
| scheme | Yes | Xcode scheme that builds and runs the XCTest unit-test target. | |
| destination | No | xcodebuild destination string. Default targets the most common iOS Simulator profile. | platform=iOS Simulator,name=iPhone 11,OS=latest |
| testCaseFilter | No | Optional `-only-testing` filter in `<TestTarget>/<TestClass>` or `<TestTarget>/<TestClass>/<testMethod>` form. Omit to run every test in the scheme (slower; produces one before/after pair for the entire run). | |
| processName | No | Process name to attach `leaks` against. `xctest` is the default unit-test runner on the simulator. If your tests are hosted in an app, pass the host app's process name instead (the same value `pgrep -x` would match). | xctest |
| outputDir | No | Directory where the baseline + after `.memgraph` snapshots are written. | /tmp/memorydetective-xctest |
| allowlistPatterns | No | Substrings of class names that are allowed to leak. Cycles whose root class contains any of these substrings will not fail the run. | |
| skipBuild | No | Skip the `build-for-testing` step (faster on CI when the build is cached). | |
| runnerStartTimeoutMs | No | How long to wait for the test runner process to appear under `pgrep -x <processName>` before giving up. Default 5 minutes. | |
| outputHtmlPath | No | Absolute path to write a self-contained HTML report (inline CSS, no external assets). When set, the response also gains an `htmlReportPath` field pointing at the same file. Designed for CI artifact upload + PR-comment attachment. |