Repository navigation
Add apple.test_bundle_tree_artifacts feature to output test bundles as tree artifacts - #3146
Open
tinder-cwybranowski wants to merge 1 commit into
Open
tinder-cwybranowski wants to merge 1 commit into
tinder-cwybranowski wants to merge 1 commit into
Conversation
With the feature enabled, test bundles are output as a tree artifact .xctest instead of a .zip, as if use_tree_artifacts_outputs were set for the test bundle only. Test hosts, applications, extensions and frameworks keep the output type set by the build setting. Test bundles aren't distributed, so their archive is only unzipped again by the test runner. Skipping it saves the zip and unzip, and lets a remote cache store and transfer the bundle's files individually instead of as one large blob. The global build setting can't be used for this when applications still need an .ipa.
tinder-cwybranowski
requested review from
aaronsky,
adincebic,
brentleyjones,
keith and
luispadron
as code owners
November 20, 2026 17:54
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.
Summary
Adds an opt-in
apple.test_bundle_tree_artifactsfeature. With it enabled,*_unit_testand*_ui_testtargets output their.xctestbundle as a tree artifact instead of a.zip, as ifuse_tree_artifacts_outputswere set for the test bundle only.use_tree_artifacts_outputs(an.ipaor.zipby default).--features=apple.test_bundle_tree_artifacts) or per target (features = ["apple.test_bundle_tree_artifacts"]). Withuse_tree_artifacts_outputsalready set, it changes nothing.apple_test_bundle_support.bzl), so it applies to every platform's test rules. A small helper overridesuse_tree_artifacts_outputsin the build settings used for the test bundle'splatform_prerequisites, so the existing tree artifact code path is reused as is..xctestdirectory and unzip anything else, and they handle the test bundle and the test host independently.Motivation
Test bundles are never shipped or distributed, so their archive exists only to be unzipped again by the test runner. Zipping a large test bundle takes time on every change. With remote execution or a remote cache, the archive is also uploaded and downloaded as a single large blob, which can't be deduplicated against the files of the bundle that are already in the cache.
use_tree_artifacts_outputsavoids that, but it's global: it also turns applications into tree artifacts, so no.ipais produced. Builds that still need archives for distribution can't use it, and there's currently no way to get tree artifacts for test bundles only.Alternatives considered
apple.skip_codesign_simulator_bundles. Happy to switch to a build setting if that's preferred.apple.tree_artifact_test_bundleswould follow theapple.tree_artifact_dsym_filesdefine.apple.test_bundle_tree_artifactsseemed closer to the existinguse_tree_artifacts_outputssetting.Testing
apple_test_info_testanalysis test rule, with three cases inios_unit_test_tests.bzlon a unit test with a test host:unit_test.zipand the test host isapp.ipa, neither a tree artifact.--features=apple.test_bundle_tree_artifacts, the test bundle is aunit_test.xctesttree artifact and the test host is stillapp.ipa.use_tree_artifacts_outputs, both are tree artifacts, as before.ios_unit_test_test_bundle_tree_artifacts_contents_testbuilds the test bundle with the feature and checks its contents.test_ios_unit_test_with_host_and_test_bundle_tree_artifacts_passintest/ios_xctestrun_runner_unit_test.shruns a hosted unit test with the feature through the xctestrun runner, and checks that the test bundle is a directory and the test host an.ipa.ios_unit_test,ios_ui_test,macos_unit_testandtvos_unit_testStarlark test suites locally, and they pass, including the new tests. With the change toapple_test_bundle_support.bzlreverted, the new feature test fails as expected.iPhone Xsused byios_xctestrun_runner_unit_test.shcan't be created with my local simulator runtimes, so I swapped the device type in a local copy. With that, hosted unit tests (including the existingtest_ios_unit_test_with_host_pass) fail on my machine before the tests start (The test runner crashed before establishing connection), with or without this change, so I couldn't run the new hosted test locally. An unhosted unit test with the feature enabled does pass through the xctestrun runner with a tree artifact.xctest.buildifier --lint=warnpasses on the changed.bzlandBUILDfiles.