Contain xcodebuild's derived data in the test's temp dir - #3050
Merged
Conversation
Every `xcodebuild test-without-building` invocation creates a ~/Library/Developer/Xcode/DerivedData/temporary-<hash>/ directory that nothing ever deletes. When the runner does not pass -resultBundlePath (any xcodebuild-path run without create_xcresult_bundle), that directory receives a full .xcresult of the run; passing -resultBundlePath alone does not fix it - a bookkeeping directory still leaks per run. One development machine had accumulated 267 of these totaling 26GB; CI agents leak one per simulator test run, silently. Pass -derivedDataPath pointed into the runner's test_tmp_dir, which the existing EXIT trap already deletes. Measured per invocation, new DerivedData directories: no flags -> 1 (152K incl. the orphan xcresult); -resultBundlePath alone -> 1 (24K bookkeeping); -derivedDataPath -> 0. An explicit -resultBundlePath (create_xcresult_bundle or xcodebuild_args) still wins for the result bundle itself: verified that with create_xcresult_bundle the bundle still lands in TEST_UNDECLARED_OUTPUTS_DIR while DerivedData stays untouched.
erneestoc
requested review from
aaronsky,
adincebic,
brentleyjones,
keith and
luispadron
as code owners
August 21, 2026 00:34
keith
approved these changes
Aug 21, 2026
keith
enabled auto-merge (squash)
August 21, 2026 00:36
Contributor
Author
|
The CI failures here are the pre-existing wedged-simulator flake, not this change:
#3026 adds the recovery machinery for this (its own CI is now fully green, including the previously-failing 9.x job, because its first run self-heals a wedged agent). Suggest retrying this build after #3026 lands — no change needed here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every
xcodebuild test-without-buildinginvocation creates a~/Library/Developer/Xcode/DerivedData/temporary-<hash>/directory that nothing ever deletes. When the runner does not pass-resultBundlePath— i.e. any xcodebuild-path run withoutcreate_xcresult_bundle— that directory receives a full.xcresultof the run; and passing-resultBundlePathalone does not fix it, a bookkeeping directory still leaks per run.One development machine had accumulated 267 of these directories totaling 26GB. Every CI agent running simulator tests through the xcodebuild path leaks one per test run, silently.
Fix: pass
-derivedDataPathpointed into the runner'stest_tmp_dir, which the existing EXIT trap already deletes. An explicit-resultBundlePath(fromcreate_xcresult_bundleorxcodebuild_args) still wins for the result bundle itself.Measurements
New DerivedData
temporary-*directories created per invocation (Xcode 26.2, iOS 26.2 simulator, hosted unit test):create_xcresult_bundle).xcresult-resultBundlePathonly-derivedDataPath(this PR)End-to-end through the runner after this change: default mode, dir count unchanged across runs (was +1 per run); with
create_xcresult_bundle = True, the bundle still lands inTEST_UNDECLARED_OUTPUTS_DIR(verified present inoutputs.zip) and DerivedData stays untouched.Steps to reproduce the leak
Test plan
xcodebuild test-without-buildingflag matrix above (each variant run against the same xctestrun).CREATE_XCRESULT_BUNDLE=1still producestests.xcresultin undeclared outputs with DerivedData untouched.bash -n.