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
SR-6032 fix private class printing with String(describing:) #12298
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me! Can you also add a negative test for String(reflecting:)
? The names that get output by that should be stable enough to encode in this test case.
test/stdlib/StringDescribing.swift
Outdated
|
||
var StringDescribingTestSuite = TestSuite("StringDescribing") | ||
|
||
StringDescribingTestSuite.test("String(reflecting:) shouldn't include extra stuff if the class is private") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should say "String(describing:)".
You can run a limited set of tests using lit's |
Ok I think I got it, the new tests looks good? |
test/stdlib/StringDescribing.swift
Outdated
|
||
StringDescribingTestSuite.test("String(reflecting:) should include extra stuff if the class is private") { | ||
expectEqual(String(reflecting: Bar.self), "main.Bar") | ||
expectNotEqual(String(reflecting: Foo.self), "main.Foo") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry, I'd like you to put the actual thing it uses here. It's not that we care about it directly, but that we'd want to know if any part of it disappeared. (That is, "Foo" and "main.(private).Foo" would also pass this test.)
Something like this? |
test/stdlib/StringDescribing.swift
Outdated
|
||
StringDescribingTestSuite.test("String(reflecting:) should include extra stuff if the class is private") { | ||
expectEqual(String(reflecting: Bar.self), "main.Bar") | ||
expectNotEqual(String(reflecting: Foo.self), "main.(private).Foo") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I meant to actually use expectEqual
here for the current format. You can even mention in a comment that no one's relying on the details of the full demangled string, but that we want to know when it changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I had not understood the first time.
But the se mangled string will be equal between different platform?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should be. The "private discriminator" part of the mangled name needs to be consistent on one platform so that rebuilding doesn't give you something different, but at the moment it's also consistent across platforms, and we have other tests that already rely on that.
Private classes doesn't add extra stuff when passed to String(describing:)
Ok, I think this time is the right one 😀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, let's go with that. Thanks, Jacopo!
@swift-ci Please test |
Build failed |
Build failed |
Private classes doesn't add extra stuff when passed to String(describing:)
I'm not at all sure if the test done in this way is correct, launched with:
will end with a success, but I haven't found how to launch all the tests for sodlib without launching all 3000.
Resolves SR-6032.