-
Notifications
You must be signed in to change notification settings - Fork 2
refactor testgen (#93) #99
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 refactors the benchmark test infrastructure by removing a template-based generation approach and replacing it with a large, directly committed pointer-based benchmark test file. The changes include:
- Removal of template files (
types.tpl,validgen_vs_validator_test.tpl) and the template generator main file - Deletion of generated test files that used the old template system
- Addition of a comprehensive 9097-line benchmark test file covering pointer types
- Minor whitespace cleanup in existing test files
Reviewed Changes
Copilot reviewed 13 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
tests/endtoend/generated_numeric_int_tests.go |
Removed trailing whitespace on line 19 |
tests/cmpbenchtests/validgen_vs_validator_test.tpl |
Deleted template file for generating benchmark tests |
tests/cmpbenchtests/validator__.go |
Removed 10 generated string validation functions (email, eq, len, etc.) |
tests/cmpbenchtests/types.tpl |
Deleted template file for generating test types |
tests/cmpbenchtests/generated_tests/validgen_vs_validator_test.go |
Deleted 279-line generated benchmark test file |
tests/cmpbenchtests/generated_tests/types.go |
Deleted 83-line generated type definitions file |
tests/cmpbenchtests/generated_cmp_perf_pointer_test.go |
Added comprehensive 9097-line pointer-based benchmark tests |
tests/cmpbenchtests/generate_cmp_benchtests_main.go |
Deleted 134-line template generation utility |
51bd54a to
8d09241
Compare
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
Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.
This PR refactors the test generation code to simplify and standardize file generation logic, improve error handling, and reduce code duplication. The main changes include extracting template execution into a reusable function, updating all test generation functions to return errors, and ensuring errors are properly surfaced to the main entrypoint. Additionally, verbose logging is replaced with standard output, and custom file generation methods are removed in favor of a shared utility.
Refactoring and code simplification:
ExecTemplatefunction inexecute_template.goto handle reading, parsing, executing, formatting, and writing template-based code generation; this eliminates repeated logic across test generators.GenerateFilemethods and replaced their usage with the newExecTemplateutility in all test generation files (generate_validation_types_tests.go,generate_validation_code_tests.go,generate_function_code_tests.go,generate_cmp_perf_tests.go). [1] [2] [3] [4]Error handling improvements:
generateValidationTypesEndToEndTests,generateValidationCodeUnitTests,generateFunctionCodeUnitTests,generateComparativePerformanceTests) to return errors instead of panicking or logging fatally; errors are now checked and handled inmain(), which exits with a non-zero status on failure. [1] [2] [3] [4] [5]log.Fatalfandlog.Printfcalls withfmt.Printfand error returns, ensuring that errors are consistently propagated and logged in a uniform way. [1] [2] [3] [4] [5] [6] [7]General cleanup:
log,os,bytes,text/template,go/format) from generator files since this logic is now encapsulated inExecTemplate. [1] [2] [3] [4]These changes make the codebase easier to maintain, reduce duplication, and provide more predictable error handling during test code generation.