Skip to content

Embed the wire-shape parity corpus in Swift - #25

Open
coenttb wants to merge 1 commit into
mainfrom
fixtures-to-swift
Open

Embed the wire-shape parity corpus in Swift#25
coenttb wants to merge 1 commit into
mainfrom
fixtures-to-swift

Conversation

@coenttb

@coenttb coenttb commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Converts the last non-Swift files under Tests/ to generated Swift, per swift-institute/.github#600.

The 9 Tests/Authentication Router Parity Tests/__Corpus__/*.txt fixtures become one generated Corpus.swift: an enum Corpus whose documents dictionary is keyed by fixture basename and exposed through static subscript(_:) -> String?. Documents are extended raw-string literals, so nothing is escaped, and the trailing newline is appended explicitly because Swift drops the final newline of a multiline literal.

assertParity and recordNonRoundTrips now compare against the embedded document instead of resolving a path under __Corpus__ relative to #filePath, so exclude: ["__Corpus__"] is dropped from the manifest. The corpora are looked up by the same names and compared the same way.

One deliberate behaviour change: Parity.fixture(_:at:) recorded a fixture when the file was absent. There is no file to record into now, so a missing document is reported as an issue instead. Re-recording becomes a matter of regenerating the corpus, which is the point of embedding it — the expected bytes are reviewable in the diff rather than appearing silently on a first run.

Gate: each embedded document was decoded back out of the generated Swift by an independent parser and compared byte-for-byte against git show origin/main:<path> — 9/9 identical. The generated file type-checks clean under Swift 6.

Note on the base: main does not build locally here — resolution pulls a swift-favicon/WHATWG_HTML_FormAttributes ambiguity in from a dependency checkout, untouched by this change — so this PR's own CI run is the evidence.

Replaces the 9 `__Corpus__/*.txt` fixtures with one generated
`Corpus.swift` holding the same documents as raw-string literals keyed
by fixture basename. Each embedded document is byte-identical to the file
it replaces, verified programmatically against the blobs at main.

`assertParity` and `recordNonRoundTrips` compare against the embedded
document instead of reading and record-when-absent writing a path under
`__Corpus__`, so the target no longer excludes that directory. Corpora
are still looked up by the same names and compared the same way; a
missing document is now reported rather than silently recorded.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant