From a63bd8885b03d047fb3b18b713f77f535768345c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 4 Nov 2025 16:28:14 +0000 Subject: [PATCH 1/2] Initial plan From 9b4dd0c75c63309cf36734cf6ec85ebdd56973ab Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 4 Nov 2025 16:51:46 +0000 Subject: [PATCH 2/2] refactor: remove unnecessary sync.Once wrapper in TestMain TestMain runs exactly once before all tests, making the sync.Once wrapper redundant. Simplified by moving build logic directly into TestMain body. Changes: - Removed sync.Once import and globalBinaryOnce variable - Moved binary build logic directly into TestMain (no wrapper) - Zero functional changes - all tests still pass - Maintains same performance benefits Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/cli/compile_integration_test.go | 49 +++++++++++++---------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/pkg/cli/compile_integration_test.go b/pkg/cli/compile_integration_test.go index 578008d667..ee15fe13c2 100644 --- a/pkg/cli/compile_integration_test.go +++ b/pkg/cli/compile_integration_test.go @@ -9,7 +9,6 @@ import ( "os/exec" "path/filepath" "strings" - "sync" "testing" "time" @@ -19,7 +18,6 @@ import ( // Global binary path shared across all integration tests var ( globalBinaryPath string - globalBinaryOnce sync.Once projectRoot string ) @@ -32,35 +30,32 @@ func TestMain(m *testing.M) { } projectRoot = filepath.Join(wd, "..", "..") - // Build the binary once for all tests - globalBinaryOnce.Do(func() { - // Create temp directory for the shared binary - tempDir, err := os.MkdirTemp("", "gh-aw-integration-binary-*") - if err != nil { - panic("Failed to create temp directory for binary: " + err.Error()) - } + // Create temp directory for the shared binary + tempDir, err := os.MkdirTemp("", "gh-aw-integration-binary-*") + if err != nil { + panic("Failed to create temp directory for binary: " + err.Error()) + } - globalBinaryPath = filepath.Join(tempDir, "gh-aw") + globalBinaryPath = filepath.Join(tempDir, "gh-aw") - // Build the gh-aw binary - buildCmd := exec.Command("make", "build") - buildCmd.Dir = projectRoot - buildCmd.Stderr = os.Stderr - if err := buildCmd.Run(); err != nil { - panic("Failed to build gh-aw binary: " + err.Error()) - } + // Build the gh-aw binary + buildCmd := exec.Command("make", "build") + buildCmd.Dir = projectRoot + buildCmd.Stderr = os.Stderr + if err := buildCmd.Run(); err != nil { + panic("Failed to build gh-aw binary: " + err.Error()) + } - // Copy binary to temp directory - srcBinary := filepath.Join(projectRoot, "gh-aw") - if err := copyFile(srcBinary, globalBinaryPath); err != nil { - panic("Failed to copy gh-aw binary to temp directory: " + err.Error()) - } + // Copy binary to temp directory + srcBinary := filepath.Join(projectRoot, "gh-aw") + if err := copyFile(srcBinary, globalBinaryPath); err != nil { + panic("Failed to copy gh-aw binary to temp directory: " + err.Error()) + } - // Make the binary executable - if err := os.Chmod(globalBinaryPath, 0755); err != nil { - panic("Failed to make binary executable: " + err.Error()) - } - }) + // Make the binary executable + if err := os.Chmod(globalBinaryPath, 0755); err != nil { + panic("Failed to make binary executable: " + err.Error()) + } // Run the tests code := m.Run()