Skip to content

test: cover the codegen CLI, introspect and the untested render paths - #29

Closed
TomChv wants to merge 2 commits into
feat/packager-staleness-checkfrom
feat/codegen-test-coverage
Closed

TomChv wants to merge 2 commits into
feat/packager-staleness-checkfrom
feat/codegen-test-coverage

Conversation

@TomChv

@TomChv TomChv commented Aug 12, 2026

Copy link
Copy Markdown
Member

Coverage was lopsided: the generator sat at 75% while the CLI this stack was
built around was at 0% for every subcommand, and three entrypoint render paths
had never executed. 56.3% overall, but not where a regression would hurt.

The real hole was enums and interfaces. The entrypoint golden happened to use
neither, so renderEnumDef, renderEnumMemberCall, renderInterfaceDef and
sortedEnumValueKeys had never run — for constructs modules use routinely.
Rather than hand-write typedef JSON, the fixture module grew an @EnumType, an
interface and a variadic and was rescanned with the real introspector, so the
golden still pins the renderer against input it actually receives.

The CLI tests cover dispatch and each required-flag error, and run each
generator into a temp dir, which also exercises the overlay that writes results
to disk. Introspect gets an httptest session: the token goes out as basic auth,
only the payload under "data" is written, and a GraphQL errors array fails
loudly rather than writing an empty schema — which would otherwise surface much
later as bindings with no API in them.

The routing check asserts what is otherwise invisible: both paths emit the same
file names, so the bundle each module ends up with is the only evidence of
which generator ran. Confirmed it fails when the condition is flipped.

Coverage is now 70.6%, with the CLI at 80-90% per subcommand.

Signed-off-by: Tom Chauveau [email protected]


Stack created with GitHub Stacks CLI • Give Feedback 💬

@TomChv
TomChv force-pushed the feat/codegen-test-coverage branch from f8d5ebb to 7f9fc67 Compare August 12, 2026 13:57
@TomChv
TomChv force-pushed the feat/codegen-test-coverage branch from 7f9fc67 to e02484f Compare August 19, 2026 14:53
@TomChv
TomChv force-pushed the feat/codegen-test-coverage branch from e02484f to d19c018 Compare August 21, 2026 12:11
@TomChv
TomChv force-pushed the feat/codegen-test-coverage branch from d19c018 to cd6cbc6 Compare August 25, 2026 16:06
@TomChv
TomChv marked this pull request as ready for review August 25, 2026 16:15
@TomChv
TomChv force-pushed the feat/codegen-test-coverage branch 2 times, most recently from 0912b81 to e430d32 Compare August 28, 2026 12:26
TomChv added 2 commits August 28, 2026 15:01
Coverage was lopsided: the generator sat at 75% while the CLI this stack was
built around was at 0% for every subcommand, and three entrypoint render paths
had never executed. 56.3% overall, but not where a regression would hurt.

The real hole was enums and interfaces. The entrypoint golden happened to use
neither, so renderEnumDef, renderEnumMemberCall, renderInterfaceDef and
sortedEnumValueKeys had never run — for constructs modules use routinely.
Rather than hand-write typedef JSON, the fixture module grew an @EnumType, an
interface and a variadic and was rescanned with the real introspector, so the
golden still pins the renderer against input it actually receives.

The CLI tests cover dispatch and each required-flag error, and run each
generator into a temp dir, which also exercises the overlay that writes results
to disk. Introspect gets an httptest session: the token goes out as basic auth,
only the payload under "data" is written, and a GraphQL errors array fails
loudly rather than writing an empty schema — which would otherwise surface much
later as bindings with no API in them.

The routing check asserts what is otherwise invisible: both paths emit the same
file names, so the bundle each module ends up with is the only evidence of
which generator ran. Confirmed it fails when the condition is flipped.

Coverage is now 70.6%, with the CLI at 80-90% per subcommand.

Signed-off-by: Tom Chauveau <[email protected]>
The check only went through `mod generate`, which is how generate-all kept
reaching the engine's generator long after the cutover without anything going
red. Every other generate check passes either way — both paths emit the same
file names — so the bundle a module ends up carrying is the only evidence of
which generator ran.

Confirmed it fails when generate-all is put back on the engine path.

Signed-off-by: Tom Chauveau <[email protected]>
@TomChv
TomChv force-pushed the feat/codegen-test-coverage branch from e430d32 to 3a315df Compare August 28, 2026 13:17
@TomChv

TomChv commented Aug 28, 2026

Copy link
Copy Markdown
Member Author

Superseded by #39, which squashes this whole stack into a single PR off main (same tree, byte for byte).

The stack had PRs overwriting each other — this one included — which made the intermediate states hard to reason about, and thirteen PRs each fanning out a full check suite made CI unreadable. Branch is left pushed, so nothing here is lost.

@TomChv TomChv closed this Aug 28, 2026
TomChv added a commit that referenced this pull request Oct 9, 2026
`dagger module client rm` deleted every file under a scope's clients/ that
the run did not render — a user's notes.txt inside the removed client's
package and one beside the packages — and the last target leaving wiped the
directory whole. Three sites treated clients/ as fully generated:
clientScope's empty-target branch (withoutDirectory on clients/),
prunedDirFiles (clientScope with targets left, and the entrypoint path of
moduleFiles), and prunedEmbeddedClientsDir (a legacy-layout module's
clients/, on every generation).

One ownership rule now serves all three, decided by shape rather than by
remembering what a previous run wrote: nothing remembers, and the layout has
changed more than once. Owned is every *.gen.ts under clients/, a
package.json beside the <name>.gen.ts that names its package, and the bundle
files beside dagger/client.gen.ts. Removals are the owned set minus this
run's output, and a directory goes only once nothing is left in it — so an
all-generated clients/ still disappears whole when the last target leaves,
while one holding a user's file stays, package directories included.

Reported as SDK Main-Engine Test Run 2026-10-07, issue #29 (case E9).

Signed-off-by: Tom Chauveau <[email protected]>
TomChv added a commit that referenced this pull request Oct 9, 2026
`dagger module client rm` deleted every file under a scope's clients/ that
the run did not render — a user's notes.txt inside the removed client's
package and one beside the packages — and the last target leaving wiped the
directory whole. Three sites treated clients/ as fully generated:
clientScope's empty-target branch (withoutDirectory on clients/),
prunedDirFiles (clientScope with targets left, and the entrypoint path of
moduleFiles), and prunedEmbeddedClientsDir (a legacy-layout module's
clients/, on every generation).

One ownership rule now serves all three, decided by shape rather than by
remembering what a previous run wrote: nothing remembers, and the layout has
changed more than once. Owned is every *.gen.ts under clients/, a
package.json beside the <name>.gen.ts that names its package, and the bundle
files beside dagger/client.gen.ts. Removals are the owned set minus this
run's output, and a directory goes only once nothing is left in it — so an
all-generated clients/ still disappears whole when the last target leaves,
while one holding a user's file stays, package directories included.

Reported as SDK Main-Engine Test Run 2026-10-07, issue #29 (case E9).

Signed-off-by: Tom Chauveau <[email protected]>
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