-
-
Notifications
You must be signed in to change notification settings - Fork 643
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
Use @union to make the v2 test runner generic #7661
Use @union to make the v2 test runner generic #7661
Conversation
The commits are useful to review independently. |
6cec590
to
de006a8
Compare
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.
Looks great!
...python/tests/python/pants_test/contrib/awslambda/python/test_python_awslambda_integration.py
Outdated
Show resolved
Hide resolved
de006a8
to
f4abaa9
Compare
}) | ||
|
||
self.assertEqual(result, TestResult(status=Status.FAILURE, stdout='foo')) | ||
|
||
def test_coordinator_unknown_test(self): |
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.
Can you restore this test to validate the claim in the implementation that "If the TargetAdaptor is not a member of the union, it will fail at runtime with a useful error message."?
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.
Hah. You got me.
It will fail at runtime with a slightly awkward error message (that I attempted to improve over here: #7502)... namely, that there is no declared Get(TestResult, $type)
.
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.
I suspect that if we continue to improve that error message code path by either/or:
- using more readable
@rule
signatures (as in Call for proposals: improved @rule display #7509), - allowing
@union
s to be directly included in error messages (which I encouraged @cosmicexplorer not to do in the original union PR, in order to keep things simpler)
... that this can become significantly more friendly.
With 2. in particular (and perhaps with something that consumes the docstring of the union, or takes a description to the union annotation?), something like:
Type $x is not a member of the TestTarget @union ($description).
... would be possible.
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.
I'm not quite sure whether this would be a mostly-rule-author-facing error, or whether it could also leak into general users... If the former, either of those sound good. If the latter, we should be a lot more verbose and explainy...
Either way, this sounds good. Happy to punt on this until some-time-this-week in the interests of getting this merged and avoiding merge conflicts for @Eric-Arellano, but I'd like us to come back to this soon :)
…order to allow matching on them in @rule definitions.
f4abaa9
to
91054de
Compare
…er than the existence of members) to decide whether it is concrete.
91054de
to
60d96c2
Compare
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.
Looking great! Thanks!
Problem
Fixing #4535 moved us closer to supporting a
Target
API for v2, but did not begin to use@union
andUnionRule
to make the v2 test@console_rule
generic.Solution
Add
@union TestTarget
, and consume it in the v2test
@console_rule
. The result is that a language implementer that wants to add support for testing a target typeMyTestTarget
can declare aUnionRule(TestTarget, MyTestTarget)
in their registered rules, which would in turn require a declared@rule
to produce aTestResult
forMyTestTarget
.In order to use
PythonTestAdaptor
as a member of theTestTarget
union, the bottom commit refactors theSymbolTable
manipulation that we do to preserve the concreteTargetAdaptor
classes.Result
Although we're not quite ready to "bless"
TargetAdaptor
by requiring it in theSymbolTable
or coupling it to the v1Target
class, this change represents an incremental step in the direction of using (a likely renamed)TargetAdaptor
incarnation as the v2 Target class.