-
Notifications
You must be signed in to change notification settings - Fork 10.5k
ForwardingUtils.swift fixes and unit tests #69002
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
Conversation
Would it work to add a computed property of type |
b6cdc68
to
1bbe514
Compare
The key thing is that the Once you decide the test function should get a |
1bbe514
to
ba8c4cf
Compare
@swift-ci test |
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.
lgtm!
The Windows failure is fixed by adding |
ba8c4cf
to
ccde72a
Compare
I don't agree with that. |
I don't see anything in FunctionPassContext that should not be called from a test. Function tests always run in a function pass, and there's nothing to hide about that. The only difference is that we don't need a separate pass for all tests and they don't pollute the pass namespace. Those are important differences, but they don't change anything about the Context. |
ccde72a
to
f17e271
Compare
A few examples:
Why shouldn't we have a separate context for tests? It's easy to add one. And better than re-using an existing type which ends up with a "fat" interface because it has to serve two different purposes. Also, when we move the test infrastructure to the SIL module at some day - including the basic Context type(s) - we cannot use |
You can pick out any of those APIs and say they don't make sense for a particular pass. Independent of this PR, it would make sense to split FunctionPassContext into something that should go in the SIL module. But I'm not going to resolve the module split debate in this PR. A FunctionTest runs in a function pass and needs to be able to do exactly anything that a function pass can do. I originally called it FunctionPassTest but Nate merged them for simplicity since we don't need anything in the SIL module today. |
Note that rewriting all of the utilities to take something other than |
Yeah, for simplicity, there should¹ be "one thing" that's used to test utilities While it's true that that name refers to different types depending on whether the test is in C++ or Swift, we shouldn't¹ burden people writing and testing utilities with thinking about that. Except to the extent that they already have to think about interface/architectural differences between C++ and Swift. Actually, the goal should¹ be to match those differences as much as possible so the test code uses the same idioms as the utility code being tested. In both languages, the third argument is some gadget from which dependencies are retrieved. In Swift, where the currency type for such dependency containers exists and is some sort of In the fullness of time, it might be nice to have a separate context type in the SIL module just for tests which grows abilities via extensions when used from downstream modules (e.g. As it is, though, it's common for ¹ In my opinion, currently. |
The test invocation is something completely different in this context.
f17e271
to
1f09723
Compare
1f09723
to
bd157b3
Compare
@swift-ci test |
Utilities and tests should have the same context. There can be a separate discussion about all the different types of contexts we might want. But we need to be able to write tests against all of them, and the tests should take exactly the same context as the utilities. |
Yes, that would be terrible
I designed the context types with following idea in mind: This is easily extendible. For example if we add utilities which need analysis, we could add an As I said before, it makes sense to move the Following this design, it makes sense to create a concrete |
To be clear: I'm suggesting this for a follow-up work, not for this PR |
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.
lgtm!
The one essential requirement is that tests get the same context as utilities. Currently, utilities take A We might want some other kind of test that cannot assume that it runs in a function pass. But then we will have multiple test types. That's fine with me, but when I tried to do that in this PR there was an objection. |
No, utilities should take a context protocol, like
I'm not sure what a
This is given by |
Why does FunctionPassContext have it's own API surface if we aren't supposed to use the type? Every API provided by FunctionPassContext should be testable. So whatever Context interface is passed to function tests should have those APIs. There's no reason to create a distinction between code that can run in a test vs. code that can run in a pass. The implementation of the function test runner is a function pass. So the implementation of whatever Context interface we pass to function tests should be a FunctionPassContext.
FunctionContext is a protocol that provides the interface currently defined in FunctionPassContext. I don't see any reason to use a protocol, but that's what you were asking for. |
No description provided.