Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@harp-intel
Copy link
Contributor

This pull request refactors the way master scripts are generated for running parallel scripts, switching from manual string concatenation to Go's text/template for 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:

  • Replaced manual string concatenation in formMasterScript with a text/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)
  • Enhanced error handling in formMasterScript and its caller, propagating template parsing and execution errors for better reliability. (internal/script/script.go)

Testing and validation:

  • Added a new file internal/script/script_master_test.go containing unit and integration tests for formMasterScript and parseMasterScriptOutput. 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:

  • Imported Go's text/template package to support the new templating approach in master script generation. (internal/script/script.go)

@harp-intel harp-intel requested a review from Copilot November 1, 2025 00:25
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 master script generation from manual string concatenation to using Go's text/template package, improving maintainability and enabling comprehensive unit testing. The changes enhance error handling and make the script structure more readable and testable.

  • Replaced string concatenation with templated approach for better maintainability
  • Added comprehensive error handling for template parsing and execution
  • Introduced thorough unit test suite covering template structure, privilege logic, and integration scenarios

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
internal/script/script.go Refactored formMasterScript to use text/template instead of manual string building, added error handling for template operations
internal/script/script_master_test.go Added comprehensive unit tests for master script generation and output parsing functionality

@harp-intel harp-intel merged commit edf4040 into main Nov 1, 2025
5 checks passed
@harp-intel harp-intel deleted the parallelmaster branch November 1, 2025 16:29
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.

2 participants