-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
add allow_fail
test attribute
#42219
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @GuillaumeGomez (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
a8ccc4e
to
9077e5c
Compare
Thanks for the PR! We’ll periodically check in on it to make sure that @GuillaumeGomez or someone else from the team reviews it soon. |
Can you give some summary as to what the use cases for this would be? I can't think of anything where a failure would be okay (but not |
I don't see the point of this add actually... :-/ |
This is basically for the same reasons you would set |
Yeah, that helps understand the reasoning. I think I'm neutral on it then -- I don't think we really need it but would be fine having it. |
I understand the reason but then: why not just use |
Well, |
Your change is included in rustdoc as well, but in there, it's pretty much useless. Then, for consistency, why not just add |
I find |
That's just completely the opposite of the purpose of a test. I really don't agree with you on this functionality. However, maybe some other people might be interested so let's request opinions. cc @rust-lang/compiler |
@pwoolcoc I've wanted this functionality from time to time, and wouldn't be opposed to seeing it land. @alexcrichton, @brson, @nrc, I imagine you might have opinions also? I'm not really sure whose jurisdiction this falls under, tbh. |
This definitely falls under the category of "I wish we had custom test frameworks" to allow this level of customization, but I don't personally have many thoughts here. I think that the most appropriate owner "team-wise" nowadays is the dev-tools team, but in general libtest needs a lot of love not just in ad-hoc additions but also in overall direction. I would not personally be opposed to landing this, although it would perhaps be nice to do it with a feature gate first. |
I think a feature gate is a good idea here, too. |
Am I right in inferring from the conversation that the reason that this |
Yes, that seems correct. |
@pnkfelix you are mostly correct. a test marked |
There is also, of course, the Usually in this scenario what I do is to write the test so that it passes with the current behavior (e.g., by adding I definitely think a feature-gate would be wise here, not sure how technically hard that would be to implement. I also think we might consider this as a "flag" to the existing |
Some frameworks have a "pending" flag instead; what this does is, run the test, and on a failure, do nothing. On a success, it fails your build and says "hey you thought this was not a real test but it works" |
That seems very much like a "should-fail" flag; so in that respect we have a pending flag already. |
To me this sounds like a tag for spurious/wont-fix-just-yet failures. This is not comparable to My primary concern with this feature is that once you add this tag, it is very easy to forget to remove it later (similar applies to Custom testing framework would be great. |
I agree that the primary purpose of |
This seems a reasonable thing to add to me, but should definitely be behind a feature gate. I also agree that libtest needs some direction (and some RFC discussion), rather than just ad hoc extensions, but this seems like something that would be useful to experiment with first. |
2109da5
to
a319007
Compare
This change allows the user to add an `#[allow_fail]` attribute to tests that will cause the test to compile & run, but if the test fails it will not cause the entire test run to fail. The test output will show the failure, but in yellow instead of red, and also indicate that it was an allowed failure.
a319007
to
0763717
Compare
0763717
to
8edc3ca
Compare
9de5d52
to
4154f89
Compare
Ok, I think this is in a good state. |
I just thought about something: should we add a warning saying that the |
I'm not sure about that, only because not all the use cases for this are for WIP code. For example, I also use it for some integration tests that contact an external service that is not 100% available. |
Can you at least display the result of the fail. For example:
Or something along the line. Like that, even if it succeeds; you can get the underlying result. |
It does show the test as "test allowed_to_fail ... FAILED (allowed)", but I'm certainly not married to that format: http://imgur.com/a/wt7ga |
📌 Commit 4154f89 has been approved by |
⌛ Testing commit 4154f89 with merge 1cd9a7050028a955b47c27d4d2789ba9e0c9c9d1... |
… r=GuillaumeGomez add `allow_fail` test attribute This change allows the user to add an `#[allow_fail]` attribute to tests that will cause the test to compile & run, but if the test fails it will not cause the entire test run to fail. The test output will show the failure, but in yellow instead of red, and also indicate that it was an allowed failure. Here is an example of the output: http://imgur.com/a/wt7ga
@bors retry - prioritizing rollup |
Does this have a issue tracking stabilization? /cc @GuillaumeGomez @arielb1 |
No. It should though. I'll open one. |
This change allows the user to add an
#[allow_fail]
attribute totests that will cause the test to compile & run, but if the test fails
it will not cause the entire test run to fail. The test output will
show the failure, but in yellow instead of red, and also indicate that
it was an allowed failure.
Here is an example of the output: http://imgur.com/a/wt7ga