refactor formMasterScript #537
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request refactors the way master scripts are generated for running parallel scripts, switching from manual string concatenation to Go's
text/templatefor improved maintainability and testability. It also introduces a comprehensive unit test suite for the new templated master script logic, ensuring correctness and robustness for various scenarios.Master script generation improvements:
formMasterScriptwith atext/template-based approach, making the script structure clearer and easier to modify. The template covers script launching, signal handling, output collection, and summary printing. (internal/script/script.go)formMasterScriptand its caller, propagating template parsing and execution errors for better reliability. (internal/script/script.go)Testing and validation:
internal/script/script_master_test.gocontaining unit and integration tests forformMasterScriptandparseMasterScriptOutput. The tests validate template structure, privilege flag logic, behavior with empty scripts, and real execution/parsing of generated scripts. (internal/script/script_master_test.go)Dependency and import updates:
text/templatepackage to support the new templating approach in master script generation. (internal/script/script.go)