Skip to content

Conversation

@alexgarzao
Copy link
Collaborator

Closes #93

This PR refactors the test generation logic in the testgen package and updates the Makefile and related test files to streamline how generated test files are handled. The main improvements include consolidating template execution logic, improving error handling, and simplifying the structure of generated tests. The changes also remove redundant and outdated unit tests.

Test Generation Refactoring:

  • Added a new helper function ExecTemplate in testgen/execute_template.go to centralize template reading, formatting, and file writing for generated tests, reducing code duplication and improving maintainability.
  • Refactored testgen/generate_cmp_perf_tests.go and testgen/generate_function_code_tests.go to use the new ExecTemplate helper, improving error handling and replacing log calls with fmt.Printf for more consistent output. The test generation functions now return errors instead of exiting abruptly. [1] [2] [3] [4] [5] [6] [7]

Makefile and Test File Management:

  • Updated the Makefile to move all generated comparative performance test files directly into tests/cmpbenchtests/ instead of a subdirectory, and adjusted the test commands to match the new file locations for consistency and easier management. [1] [2]

Test Cleanup:

  • Removed outdated and redundant unit tests from internal/codegenerator/build_validator_test.go, including pointer type validation tests and many basic field validation cases, leaving only the most relevant and complex test scenarios. [1] [2] [3] [4] [5]

@alexgarzao alexgarzao requested a review from Copilot November 7, 2025 22:25
@alexgarzao alexgarzao self-assigned this Nov 7, 2025
Copy link
Contributor

Copilot AI left a 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 test generation infrastructure for ValidGen by removing old template-based benchmark tests and replacing them with a new comprehensive pointer validation benchmark suite. The changes improve error handling in the test generator and introduce a reusable template execution utility.

Key Changes

  • Removed old comparative performance test templates and generated files
  • Added new comprehensive pointer validation benchmarks (9097 lines covering all validation types for pointer fields)
  • Improved error handling in test generation with proper error propagation and exit codes
  • Extracted template execution logic into a reusable utility function

Reviewed Changes

Copilot reviewed 8 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/endtoend/generated_numeric_int_tests.go Minor whitespace cleanup (removed trailing whitespace)
tests/cmpbenchtests/validgen_vs_validator_test.tpl Deleted old benchmark test template
tests/cmpbenchtests/validator__.go Removed old string validation benchmarks
tests/cmpbenchtests/types.tpl Deleted old types template
tests/cmpbenchtests/generated_tests/validgen_vs_validator_test.go Deleted old generated benchmark tests
tests/cmpbenchtests/generated_tests/types.go Deleted old generated type definitions
tests/cmpbenchtests/generated_cmp_perf_pointer_test.go Added comprehensive pointer validation benchmarks
testgen/generate_tests.go Enhanced error handling with proper error checking and exit codes
testgen/execute_template.go New reusable template execution utility

@alexgarzao alexgarzao merged commit 7144ed9 into main Nov 11, 2025
4 checks passed
@alexgarzao alexgarzao deleted the 93-cleanup-old-tests branch November 11, 2025 22:18
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.

One tool to generate all test cases

3 participants