Enforce example registration in test-examples#941
Conversation
The commit that refined em dash spacing (74d18f0) accidentally renamed the `cmd` field to `cmdPrefix`, so this commit restores it. Assisted-by: Claude Code:claude-fable-5
Background: `test-examples` promises that every directory under examples/ is registered in one of its registries, but it only printed a warning when one was not, so a new example could silently miss automated checks. In fact, examples/solidstart had never been registered. Changes: - Add registry-consistency tests that fail when an example in the examples/ directory is unregistered or a registered example has no matching directory. - Make examples/test-examples a root Deno workspace member so that CI picks up the added tests. - Register the solidstart example, which the new test caught as unregistered. Closes fedify-dev#886 Assisted-by: Claude Code:claude-fable-5
✅ Deploy Preview for fedify-json-schema canceled.
|
📝 WalkthroughWalkthroughThe example test runner registers a SolidStart example, exposes registry-scanning helpers, supports safe imports, and adds tests for missing or unregistered example directories. Deno workspace and task configuration supports running the focused tests and runner. ChangesExample registry validation
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request registers a new solidstart example and introduces a test suite (test-examples) to ensure consistency between the physical directories in examples/ and the registered examples in mod.ts. The review feedback recommends ignoring hidden directories (such as .DS_Store or .git) and decoupling logical example names from physical directory names by introducing and checking against a getRegisteredExampleDirs() helper instead of getRegisteredExampleNames(). All review comments are constructive and provide actionable code suggestions to improve test robustness.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| import assert from "node:assert/strict"; | ||
| import test from "node:test"; | ||
|
|
||
| import { getRegisteredExampleNames, scanUnregisteredExamples } from "./mod.ts"; |
There was a problem hiding this comment.
Update the import to use getRegisteredExampleDirs instead of getRegisteredExampleNames to support checking directory names rather than logical example names.
| import { getRegisteredExampleNames, scanUnregisteredExamples } from "./mod.ts"; | |
| import { getRegisteredExampleDirs, scanUnregisteredExamples } from "./mod.ts"; |
2chanhaeng
left a comment
There was a problem hiding this comment.
LGTM! I left a little suggestion. And next time you open another PR, would you please mention the related issue at the very beginning of the PR body? It really helps with understanding the context faster.
| return new Set([ | ||
| ...SERVER_EXAMPLES.map((e) => e.name), | ||
| ...SCRIPT_EXAMPLES.map((e) => e.name), | ||
| ...MULTI_HANDLE_EXAMPLES.map((e) => e.name), | ||
| ...SKIPPED_EXAMPLES.map((e) => e.name), | ||
| ]); |
There was a problem hiding this comment.
I think it will be better like this:
return new Set([
...SERVER_EXAMPLES,
...SCRIPT_EXAMPLES,
...MULTI_HANDLE_EXAMPLES,
...SKIPPED_EXAMPLES,
].map((e) => e.name))There was a problem hiding this comment.
@2chanhaeng Thank you for your review! I added a new commit 2d186c2
I also moved the comment about the related issue to the top of PR
Combine the registered example arrays before mapping their names to avoid repeated map operations.
Closes #886
Summary
cmdfield ofMultiHandleExamplethat a formatting sweep (74d18f0) accidentally renamed.Test plan
deno test --allow-all examples/test-examplesandmise testmkdir examples/zz-fake && deno test --allow-all examples/test-examplesfails, naming the unregistered directoryTest Screenshots
AI assistance disclosure: Claude Code (claude-fable-5) helped implement and verify the change.