Skip to content

Fix ByteBufferTests when compiling with Swift 6 but running on macOS 14. #3217

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

Merged
merged 1 commit into from
Apr 22, 2025

Conversation

allevato
Copy link
Contributor

Writing @available(someOS...) on an XCTest test method only affects whether the compiler allows known-available APIs to be called, but it doesn't actually prevent the test from running on older OSes (XCTest doesn't see the annotation since it's not part of the Objective-C runtime metadata). So if this code is compiled with Swift 6 but run on an older OS, it will segfault when it tries to call an API that doesn't exist on that platform.

These tests need to use an #available guard instead to make the decision to skip them at runtime.

Writing `@available(someOS...)` on an XCTest test method only affects
whether the compiler allows known-available APIs to be called, but it
doesn't actually prevent the test from running on older OSes (XCTest
doesn't see the annotation since it's not part of the Objective-C
runtime metadata). So if this code is compiled with Swift 6 but run
on an older OS, it will segfault when it tries to call an API that
doesn't exist on that platform.

These tests need to use an `#available` guard instead to make the
decision to skip them at runtime.
@Lukasa Lukasa added the semver/none No version bump required. label Apr 22, 2025
Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

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

Thanks Tony, much appreciated!

@Lukasa Lukasa enabled auto-merge (squash) April 22, 2025 08:19
@Lukasa Lukasa merged commit 6615a44 into apple:main Apr 22, 2025
45 of 46 checks passed
@allevato allevato deleted the fix-tests branch April 22, 2025 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/none No version bump required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants