Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.0] On Darwin, allow XCTest to be missing if we're only building swift-testing tests. #7430

Merged

Conversation

grynspan
Copy link
Contributor

Explanation: This PR removes the constraint on Darwin that XCTest.framework must be present in order to build tests using swift-testing. On Darwin, XCTest is included as a framework inside Xcode, but if a developer installs the Xcode Command Line Tools instead of the full IDE, XCTest is not included.

Scope: Improves swift-testing functionality by allowing developers to build test targets that use swift-testing without an implicit XCTest dependency. No source- or language-breaking changes.

Issue: N/A

Original PR: #7426

Risk: Low; only impacts developers using Xcode CLTools on Darwin.

Testing: At-desk testing as well as CI runs. It is not possible to test the environment where the issue manifests in our CI because it would need to be configured with CLTools but no IDE.

Reviewer: @briancroom @MaxDesiatov

…sting tests. (#7426)

This PR removes the constraint on Darwin that XCTest.framework must be
present in order to build tests using swift-testing. On Darwin, XCTest
is included as a framework inside Xcode, but if a developer installs the
Xcode Command Line Tools instead of the full IDE, XCTest is not
included. They then get a diagnostic of the form:

> error: XCTest not available: terminated(1): /usr/bin/xcrun --sdk
macosx --show-sdk-platform-path output:
> xcrun: error: unable to lookup item 'PlatformPath' from command line
tools installation
> xcrun: error: unable to lookup item 'PlatformPath' in SDK
'/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk'

Which is a poor experience if they aren't even using XCTest.

This change, as a (positive) side effect, suppresses the same diagnostic
when running commands that are not usually dependent on the presence of
XCTest such as `swift build`.

Note that swift-corelibs-xctest is not supported on Darwin, so
installing the Xcode Command Line Tools and adding an explicit
dependency on swift-corelibs-xctest will not produce a functional test
target bundle. Supporting swift-corelibs-xctest on Darwin is a potential
future direction.

Automated testing for this change is difficult because it relies on a
build environment that is not supported in CI (namely the presence of
the CL tools but not Xcode nor XCTest.framework.) I have manually tested
the change against swift-testing's own test target.

A separate PR will be necessary in swift-testing to remove some
remaining XCTest dependencies. Those changes are not covered by this PR.

Resolves rdar://125372431.
@grynspan grynspan added bug swift test Changes impacting `swift test` tool swift 6.0 Related to Swift 6.0 release branch labels Mar 28, 2024
@grynspan grynspan self-assigned this Mar 28, 2024
@grynspan
Copy link
Contributor Author

@swift-ci please test

@bnbarham bnbarham changed the title On Darwin, allow XCTest to be missing if we're only building swift-testing tests. [6.0] On Darwin, allow XCTest to be missing if we're only building swift-testing tests. Mar 28, 2024
@grynspan
Copy link
Contributor Author

@swift-ci please test Windows

@grynspan grynspan enabled auto-merge (rebase) March 28, 2024 19:23
@grynspan grynspan merged commit 9ee1649 into release/6.0 Mar 28, 2024
5 checks passed
@grynspan grynspan deleted the jgrynspan/125372431-remove-xctest-requirement-6.0 branch March 28, 2024 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug swift test Changes impacting `swift test` tool swift 6.0 Related to Swift 6.0 release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants