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
RFC #16 - PRECONDITION_FAILED subtest result (status) #16
Merged
foolip
merged 9 commits into
web-platform-tests:master
from
lukebjerring:not-implemented
Sep 19, 2019
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8db39a9
Add not_implemented RFC
9f639a4
Tweak summary
0b81fdf
Example usage
daee6f5
Incorporate feedback
87ebb2f
Update not_implemented.md
lukebjerring 0f3d60c
Update not_implemented.md
lukebjerring 2de0990
Update not_implemented.md
lukebjerring 2632a24
Rename not_implemented.md to assert_precondition.md
foolip e43e858
Update assert_precondition.md
lukebjerring File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# RFC #16: 'PRECONDITION_FAILED' subtest result (status) | ||
|
||
## Summary | ||
|
||
Allow another distinct subtest result, different from `FAIL` or `MISSING` results, | ||
by asserting a precondition requirement for a subtest, where the precondition | ||
needs to be met for the test to actually produce any meaningful result. | ||
|
||
## Details | ||
|
||
### Background | ||
|
||
Some specs, such as [WebCryptoAPI](https://www.w3.org/TR/WebCryptoAPI/#scope-algorithms), | ||
focus on the discovery of the set of a user agent's implementations, but do not mandate | ||
any *particular* algorithm is implemented. As a result, it is perfectly spec compliant to | ||
omit any (or, even **all**!) implementations. | ||
|
||
With respect to testing, there are two options for results when enumerating the | ||
set of implementations: | ||
|
||
- Consider a lack of implementation a `FAIL` | ||
- Omit results for known non-implementations (`MISSING` on wpt.fyi) | ||
|
||
The current behaviour of [some WebCryptoAPI tests](https://wpt.fyi/results/WebCryptoAPI/encrypt_decrypt/aes_ctr.https.worker.html) actually has a mixture - some tests | ||
are missing, some are "failing". | ||
|
||
### Proposal | ||
|
||
Add subtest result of `PRECONDITION_FAILED` - a result for subtests which | ||
assert an unmet precondition, and thus do not run the remainder of the test. | ||
|
||
Add an `assert_precondition(condition, description)` function helper, which will conclude | ||
with a `PRECONDITION_FAILED` result when `condition` is not truthy. | ||
|
||
> __assert_precondition(condition, description)__ | ||
> | ||
> Concludes the test with `PRECONDITION_FAILED` status if `condition` is not truthy. | ||
> Used for skipping subtests will not produce a meaningful result without the condition, | ||
> e.g. optional features that are not implemented by the user agent. | ||
|
||
#### Example Usage | ||
|
||
promise_test(function(test) { | ||
return subtle.generateKey(algorithm, extractable, usages) | ||
.then( | ||
function(result) { ... }, | ||
function(err) { | ||
if (isUnsupported(err)) { // "Unsupported" case determined ad-hoc | ||
assert_precondition(false, algorithm + ' not implemented'); | ||
} else { | ||
assert_unreached("Threw an unexpected error: " + err.toString()); | ||
} | ||
}); | ||
} | ||
|
||
## Advantages | ||
|
||
For spec-compliant implementation omission, it would allow distinction from other | ||
outcome implications. | ||
|
||
- `FAIL` implies an incorrect implementation | ||
- `MISSING` implies a test was not run at all | ||
- `PRECONDITION_FAILED` implies a test was not applicable | ||
|
||
It also allows for more expressive tests, allowing authors to be explicit about their | ||
expectations. | ||
|
||
## Disadvantages | ||
|
||
- An extra outcome to consider | ||
- Will involve viral changes to logging, and log consumers | ||
- Possible metrics skewing from the point that tests change to use this status |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is it intentional that the execution continues after the
skip()
call in this example?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.
As a point of reference, mocha does throw in its
this.skip()
:https://github.com/mochajs/mocha/blob/186ca3657b4d3e0c0a602a500653a695f4e08930/lib/runnable.js#L138
We could do that with a specific error type, or we could treat this as
t.done()
and keep going but ignore anything the test does. The difference of course is that it's unlikely there's stuff aftert.done()
but very likely there's stuff aftert.skip()
.@lukebjerring WDYT?
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.
Not intentional (prototype was tweaked to fix that).
@foolip I would expect
t.skip
to be the "end of the road" in so far as the test content is concerned, since "ignoring" further execution would be more computationally expensive, and extra code for the testharness.