test_runner: simplify logic, nix dead reporter code #59700
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.
While trying to understand the underlying logic of the built-in test reporters, necessary because documentation of the semantics of TestsStream is minimal, I was thoroughly confused by this code in
formatTestReport
:...and not just because of the obfuscation. It made sense that if
data.details?.error?.failureType === 'subtestsFailed'
, the error should not be reported against the parent test, and even that this condition is only tested ifhasChildren
is true. But all callers that do pass inhasChildren
(which otherwise defaults to false) also pass inshowErrorDetails: false
, so that part of the convoluted nested ternary never even fires.Ok, I thought, maybe
formatTestReport
represents an API the current built-in reporters do not use fully. But that seems a little odd because it is internal. So I reduced it to its essence, as currently used. I did it in four steps because I'm old and need to break things down more than you young'uns might need. Each step is a commit, with explanation in the commit message, with each commit passing all tests.The upshot is the above gets reduced to
along with an easier to understand formatTestReport function signature and removal of more dead code in the spec reporter.