Skip to content

[test] Adjust new Substring test #29446

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 2 commits into from
Jan 27, 2020

Conversation

lorentey
Copy link
Member

@lorentey lorentey commented Jan 25, 2020

This fixes the new Substring test that checks for the behavioral change introduced in #29094/#29146.

We don't have a good way to test exactly what version of the stdlib we're running on, so it isn't feasible to write two-way tests for behavior that is expected to change between stdlib versions. The if #available(9999) checks we have now will fail when we run these tests on a future released version of the stdlib that includes these changes. Even worse, the expected behavior on older stdlibs depends on whether the method is called in a Sequence-generic context. (The implementation is marked @_alwaysEmitIntoClient, so client code that directly calls it will have the new behavior; however, the Sequence witness table for Substring will still point to the default implementation in old stdlibs.)

Therefore, if the availability test fails, we cannot tell which behavior we need to expect, so we must stop checking for it.

On the other hand, if the availability check succeeds, then we are guaranteed to have a new stdlib -- so we need to look at the expected behavior in that case, and only that case.

rdar://58868606

We don’t have an easy way to check for the runtime version of the stdlib, so a two-way check for behavioral changes isn’t feasible. (Checking for the OS version isn’t good enough.)

Only check for the new behavior, and only when we know for sure that it’s available.
The previous commit made these redundant.
@lorentey lorentey requested a review from milseman January 25, 2020 01:00
@lorentey
Copy link
Member Author

Cc @Lukasa

@lorentey
Copy link
Member Author

@swift-ci test

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 for this @lorentey, this looks like it preserves the test intent but fixes the issues.

Copy link
Member

@milseman milseman left a comment

Choose a reason for hiding this comment

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

LGTM

@lorentey lorentey merged commit 509ffb3 into swiftlang:master Jan 27, 2020
@lorentey lorentey deleted the substring-test-cleanup branch January 27, 2020 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants