|
| 1 | +# RFC 165: Support expected-fail-message in test metadata for subtests |
| 2 | + |
| 3 | +## Summary |
| 4 | + |
| 5 | +Add "expected-fail-message" in test metadata so that we can track how |
| 6 | +a subtest fails. |
| 7 | + |
| 8 | +## Details |
| 9 | + |
| 10 | +In Chromium developers are using [baselines](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/web_tests/external/wpt/editing/event-expected.txt) to track expected output message |
| 11 | +for testharness tests. While the output message for a pass subtest is |
| 12 | +generally not interesting, the output message for a failed subtest tracks |
| 13 | +how a subtest fails, and a change in how a test fails could be unintended |
| 14 | +and suggestive of a problem. Chromium developers want to keep such capability |
| 15 | +if we want to use Wptrunner to run WPTs in Chromium. |
| 16 | + |
| 17 | +The suggestion is to support "expected-fail-message" tag for subtests. When |
| 18 | +present, it takes effect on expected FAIL or expected PRECONDITION_FAILED |
| 19 | +results. The test runner should check if the actual output message matches |
| 20 | +with the "expected-fail-message". When a mismatch is found, the test runner |
| 21 | +should turn the results to unexpected FAIL or unexpected PRECONDITION_FAILED |
| 22 | +respectively, otherwise the results continue to be the expected one. |
| 23 | + |
| 24 | +Wdspec tests can also have subtests. "expected-fail-message" should work the |
| 25 | +same way for an expected FAIL Wdspec subtest. Other than that, "expected-fail-message" |
| 26 | +should not have impact on any other scenarios. |
| 27 | + |
| 28 | +One example metadata file will look like below: |
| 29 | +``` |
| 30 | +[event.html] |
| 31 | + expected: OK |
| 32 | + [Changing selection from handler: input event] |
| 33 | + expected: FAIL |
| 34 | +
|
| 35 | + [Command createLink, value "": input event] |
| 36 | + expected: [FAIL, PRECONDITION_FAILED, PASS] |
| 37 | + expected-fail-message: "number of input events fired expectei 1 but got 0" |
| 38 | +``` |
| 39 | + |
| 40 | +### Implementations |
| 41 | + |
| 42 | +The current implementation for test metadata parser is flexible enough to |
| 43 | +understand any additional tag. The changes needed is 1) wpttest.Test to have one |
| 44 | +additional member function to return "expected-fail-message", |
| 45 | +2)testrunner.TestRunnerManager.test_ended to have additional logic to turn |
| 46 | +expected FAIL or PRECONDITION_FAILED to unexpected failures per the rule |
| 47 | +discribed above. |
| 48 | + |
| 49 | +How to add "expected-fail-message" to test metadata is out of scope of this RFC. |
| 50 | +Usually this tag can be added manually by developers after carefully review the |
| 51 | +test results and implementations. |
| 52 | + |
| 53 | +### Alternatives Considered |
| 54 | + |
| 55 | +Various alternatives have been considered, e.g. writing a new test to assert the |
| 56 | +behavior a baseline wants to assert, or duplicate the test in question as a |
| 57 | +legacy web test so that baseline will continue work. Those all would be a |
| 58 | +maintanance headache, and are rejected consequently. |
| 59 | + |
| 60 | +## Risks |
| 61 | + |
| 62 | +"expected-fail-message" will only take effect when it presents in the metadata |
| 63 | +file. When not presented, the test will behave exactly the same way as before. |
| 64 | +It would be at developers' own discretion to use this feature or not. There is a |
| 65 | +chance this could be abused, but as the metadata file sits in each vendor's |
| 66 | +repository, the impact should be limited. |
| 67 | + |
| 68 | +The existence of this feature should not be used as an implication that subtest |
| 69 | +output messages are expected to be stable. When a subtest output message is found |
| 70 | +to be not stable, "expected-fail-message" should simply not be used, or if a |
| 71 | +vendor still want to assert on the output message, they can choose to revise |
| 72 | +the test without sacrifice the usefulness of the test. The original test author |
| 73 | +bears no responsibility of this. |
| 74 | + |
| 75 | +This feature will not have any impact to the results presented at wpt.fyi, as |
| 76 | +this only changes if a FAIL is expected or not, but not the actual result |
| 77 | +itself. |
0 commit comments