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

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

Merged
merged 3 commits into from Mar 26, 2024

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Mar 25, 2024

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 25, 2024
@grynspan grynspan self-assigned this Mar 25, 2024
…sting tests.

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 force-pushed the jgrynspan/125372431-remove-xctest-requirement branch from 4e0699f to a335fa6 Compare March 25, 2024 23:32
@grynspan
Copy link
Contributor Author

@swift-ci please test

grynspan added a commit to apple/swift-testing that referenced this pull request Mar 25, 2024
This PR removes some stray dependencies on XCTest that prevent building the
testing library and its test target when XCTest is not available on Darwin. This
can occur if the Xcode Command Line Tools are installed instead of the full IDE.

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.

For more information about this change, see apple/swift-package-manager#7426

Resolves rdar://125371899.
@grynspan
Copy link
Contributor Author

@swift-ci please test

@grynspan
Copy link
Contributor Author

@swift-ci please test Windows

Copy link
Member

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

grynspan added a commit to apple/swift-testing that referenced this pull request Mar 26, 2024
…316)

This PR removes some stray dependencies on XCTest that prevent building
the testing library and its test target when XCTest is not available on
Darwin. This can occur if the Xcode Command Line Tools are installed
instead of the full IDE.

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.

For more information about this change, see
apple/swift-package-manager#7426. That PR
affects the Swift main-branch toolchain (Swift 6), not Swift 5.10 or
earlier.

Resolves rdar://125371899.

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
@grynspan grynspan enabled auto-merge (squash) March 26, 2024 18:21
@grynspan grynspan merged commit 601d040 into main Mar 26, 2024
5 checks passed
@grynspan grynspan deleted the jgrynspan/125372431-remove-xctest-requirement branch March 26, 2024 19:00
grynspan added a commit that referenced this pull request Mar 28, 2024
…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 added a commit that referenced this pull request Mar 28, 2024
…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.
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