Skip to content

test: parse unit-test fixtures from WIT text - #229

Merged
arcjet-rei merged 4 commits into
mainfrom
rei/fix/ENG-1378-wit-test-fixtures
Oct 3, 2026
Merged

arcjet-rei merged 4 commits into
mainfrom
rei/fix/ENG-1378-wit-test-fixtures

Conversation

@arcjet-rei

Copy link
Copy Markdown
Contributor

The unit tests in exports.rs and imports.rs built wit_parser values as struct literals. Every wit-parser release that added a field broke them: the bump to 0.258 in #202 needed 25 field additions. The literals could also describe states the parser never produces, such as a function named take_wide under the world key take-wide.

A test-only Fixture parses a WIT document with Resolve::push_source, fills the type sizes, and looks up functions and types by name. Each test now states its fixture as WIT and keeps its assertions. The two export assertions that spelled function names with underscores now use the kebab-case names gravity emits for real WIT. test_record_type_generation now asserts against the self-referential alias that it previously only printed a message about.

🤖 Generated with Claude Code

arcjet-rei and others added 2 commits October 2, 2026 19:06
The unit tests in exports.rs and imports.rs built wit_parser values
(Function, TypeDef, World, Interface, Package) as struct literals, so
every wit-parser release that added a field broke them: the bump to
wit-parser 0.258 needed 25 additions across 22 literals. They could also
describe states the parser never produces, such as a function named
take_wide under the world key take-wide.

A test-only Fixture parses a WIT document with Resolve::push_source,
fills the type sizes, and looks up exported functions, interface
functions and types by name. Each test now states its fixture as WIT and
keeps its assertions; the two export assertions that named the function
with underscores now use the kebab-case name gravity emits for real
WIT. test_record_type_generation keeps its checks and drops its debug
printing, asserting the self-referential alias it described instead of
printing about it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@arcjet-rei
arcjet-rei requested a review from a team as a code owner October 3, 2026 02:16

@arcjet-review arcjet-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arcjet Review — 🟢 Low Risk

Decision: Checked

Rationale: The PR refactors test fixtures to parse real WIT text instead of manually constructing wit-parser structs, adds a cfg(test)-only helper module, and updates assertions to match parser-produced kebab-case names. The changes are confined to unit tests and test-only code, introduce no runtime behavior changes, no dependency changes, and no authentication, authorization, data handling, or injection-relevant paths. Security review found no hardcoded secrets or security-sensitive behavior.

Summary of Changes

Replaces hand-built wit_parser fixtures in codegen import/export tests with a new test-only Fixture helper that parses WIT text, fills size information, and provides lookup helpers for worlds, functions, exports, and types. Several tests are updated to use real WIT names and one record generation test now asserts the generated code does not contain a self-referential alias.

Notes

The diff appears to exceed the configured 500-line threshold, largely due to replacing verbose test fixture construction with WIT text. Automated review is still feasible because the changes are test-only, but human reviewers may want to skim the fixture helper and representative test conversions.

The AI assessed this PR as approvable, but the trust level (1) does not allow auto-approval. A human reviewer must approve this PR.

Review: 2035844d | Model: openai/gpt-5.5 | Powered by Arcjet Review

Comment thread cmd/gravity/src/codegen/test_wit.rs
@arcjet-review arcjet-review Bot removed ai-review-in-progress needs review Awaiting human review labels Oct 3, 2026
arcjet-rei and others added 2 commits October 3, 2026 09:26
type_id returned the first type with a matching name, so a fixture that
declared the same name in two interfaces would get whichever came first.
It now panics unless exactly one type has the name, and a test covers the
ambiguous case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve the conflict in exports.rs by keeping main's formatting of the
code outside the test module and this branch's WIT-parsed test module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@arcjet-rei
arcjet-rei merged commit 9b55557 into main Oct 3, 2026
5 checks passed
@arcjet-rei
arcjet-rei deleted the rei/fix/ENG-1378-wit-test-fixtures branch October 3, 2026 16:32
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.

2 participants