-
Notifications
You must be signed in to change notification settings - Fork 2
feat: complete code generation architecture for assert/require packages #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements a comprehensive code generation architecture that inverts the previous model, making internal/assertions the single source of truth for generating both assert and require packages with all their variants. The system now generates 608 functions (76 base functions × 8 variants) with corresponding tests and examples, achieving ~100% test coverage in generated packages.
Key changes:
- New scanner/generator architecture replaces previous semi-manual approach
- Example-driven test generation from godoc "Examples:" sections
- Modern Go 1.23 iterator-based table-driven tests throughout
- Comprehensive documentation added (MAINTAINERS.md, CLAUDE.md)
Reviewed changes
Copilot reviewed 67 out of 161 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| doc.go | Updated package documentation to reflect fork differences and code generation approach |
| codegen/main.go | New entry point for code generator with configuration flags |
| codegen/main_test.go | Smoke tests for code generation execution |
| codegen/internal/scanner/*.go | AST/types analysis for extracting functions and metadata |
| codegen/internal/generator/*.go | Template-based generation of assertion packages |
| codegen/internal/model/model.go | Data structures bridging scanner and generator |
| codegen/internal/generator/templates/*.gotmpl | Templates for generating assert/require variants |
| assert/*.go | Generated assertion package files |
| .codecov.yml | Updated to ignore new codegen directory |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8 +/- ##
===========================================
+ Coverage 53.82% 95.78% +41.96%
===========================================
Files 18 37 +19
Lines 4964 5627 +663
===========================================
+ Hits 2672 5390 +2718
+ Misses 2227 166 -2061
- Partials 65 71 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
fixes #6 |
d4bc2d1 to
d67df7a
Compare
Inverts the generation model: internal/assertions is now the single source of truth, with assert/ and require/ packages fully generated including all variants (format, forward, tests, examples). Architecture: - Scanner: AST/types analysis extracts functions, signatures, and test examples - Generator: Template-based generation of 76 functions × 8 variants = 608 functions - Model: Structured representation bridging scanner and generator Key improvements: - Example-driven test generation from godoc "Examples:" sections - Achieves ~100% coverage in generated packages (99.5% - 0.5% gap from helpers) - Modern Go 1.23 iterator-based table-driven tests throughout - Domain-organized source (boolean, collection, compare, equal, error, etc.) - Function type detection for proper generation of type/var function signatures - Comprehensive documentation (MAINTAINERS.md, CLAUDE.md) - Codegen smoke tests (24.4% coverage) Generated packages: - assert/require: assertions, format variants, forward methods - All with corresponding tests and runnable examples - Helper types and interfaces This replaces the previous semi-hand-written/semi-generated approach where adding a single assertion required manually updating 6+ files that already had thousands of lines. Now: write once in internal/assertions/ in small focused source files, run go generate, done. Trade-off: the existing code generator has been rewritten entirely. The new one is more complex, but also more readable. This added (mostly stable) complexity should be outweighted by the simplification of the assertion development workflow. Signed-off-by: Frederic BIDON <fredbi@yahoo.com> ci: enforced Windows TMP to reside on the same drive Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
d67df7a to
e378d7d
Compare
Inverts the generation model: internal/assertions is now the single source
of truth, with assert/ and require/ packages fully generated including all
variants (format, forward, tests, examples).
Architecture:
Key improvements:
Generated packages:
This replaces the previous semi-hand-written/semi-generated approach where adding a single
assertion required manually updating 6+ files that already had thousands of lines.
Now: write once in internal/assertions/ in small focused source files, run go generate, done.
Trade-off: the existing code generator has been rewritten entirely.
The new one is more complex, but also more readable.
This added (mostly stable) complexity should be outweighted by the
simplification of the assertion development workflow.
Change type
Please select: 🆕 New feature or enhancement|🔧 Bug fix'|📃 Documentation update
Short description
Fixes
Full description
Checklist