Skip to content

🍒 [6.4] Simplify and fix encoded event ordering issues with test repetitions#1803

Merged
harlanhaskins merged 1 commit into
release/6.4.xfrom
harlan/fix-test-case-iteration-output-6.4
Jul 18, 2026
Merged

🍒 [6.4] Simplify and fix encoded event ordering issues with test repetitions#1803
harlanhaskins merged 1 commit into
release/6.4.xfrom
harlan/fix-test-case-iteration-output-6.4

Conversation

@harlanhaskins

Copy link
Copy Markdown
Contributor
  • Explanation:

This fixes a bug in event emission for testStarted/testEnded events introduced with the implementation of ST-0024

  • Scope:

Affects clients of JSON event schema, but not existing clients of Snapshot SPI.

Low (only affects consumers of the JSON event schema, fixes a regression since 6.3)

  • Testing:
    Ran existing unit tests in CI and locally, added new unit tests.

  • Reviewers:
    @stmontgomery

@harlanhaskins harlanhaskins changed the title Simplify and fix encoded event ordering issues with test repetitions 🍒 [6.4] Simplify and fix encoded event ordering issues with test repetitions Jul 17, 2026
@harlanhaskins harlanhaskins self-assigned this Jul 17, 2026
@harlanhaskins harlanhaskins added this to the Swift 6.4.0 milestone Jul 17, 2026
@harlanhaskins harlanhaskins added the bug 🪲 Something isn't working label Jul 17, 2026
Base automatically changed from harlan/expose-iteration-to-json-schema-6.4 to release/6.4.x July 18, 2026 00:07
…1793)

This fixes an issue introduced with #1528 where we now accidentally
report `testStarted`/`testEnded` for non-parameterized repeated tests in
an inconsistent way.

(this is copy/pasted from a comment I left in-source, and normally I
don't like leaving verbose comments in source but this one's confusing
enough.)

For all test cases of a given test, we emit the following set of events
internally.

```
testStarted
testCaseStarted (for each case)
...
testCaseEnded (for each case)
...
testEnded
```

For parameterized tests, this is what clients expect; the test itself
has a distinct start/end from all the cases.

For non-parameterized tests, however, clients don't need a redundant
`testCaseStarted`/`testCaseEnded` for a single case, so we elide it.

However, we don't know which `iteration` we're on until we've started
running test cases, and subsequent iterations will post additional
`testCaseStarted`/`testCaseEnded` events.

To provide a coherent façade to our clients:
- For non-parameterized tests, elide the outer `testStarted`/`testEnded`
events, and replace `testCaseStarted`/`testCaseEnded` with
`testStarted`/`testEnded`.
- For parameterized tests, emit all events.

This extracts the mapping from `Event.Kind` to `EncodedEvent.Kind` into
a failable initializer on `EncodedEvent.Kind`, which splits the
kind-mapping from the field-population logic, and then simplifies the
logic for determining when to substitute/elide `test`/`testCase` events.

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.

Resolves rdar://182236497
@harlanhaskins
harlanhaskins force-pushed the harlan/fix-test-case-iteration-output-6.4 branch from 552776c to 0e1e450 Compare July 18, 2026 01:48
@harlanhaskins
harlanhaskins merged commit bfb3d71 into release/6.4.x Jul 18, 2026
28 of 35 checks passed
@harlanhaskins
harlanhaskins deleted the harlan/fix-test-case-iteration-output-6.4 branch July 18, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🪲 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants