Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ require (
github.com/spf13/cobra v1.10.2
github.com/spf13/pflag v1.0.10
github.com/stretchr/testify v1.11.1
go.uber.org/goleak v1.3.0
golang.org/x/crypto v0.54.0
golang.org/x/mod v0.38.0
golang.org/x/sync v0.22.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ go.opentelemetry.io/otel/sdk/metric v1.44.0 h1:3LlKgI+VjbVsjNRFZJZAJ30WjXC5VkNRk
go.opentelemetry.io/otel/sdk/metric v1.44.0/go.mod h1:5B5pMARnXxKhltooO4xUuCBorl65a4EpnTalObqOigA=
go.opentelemetry.io/otel/trace v1.44.0 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/6gtIk=
go.opentelemetry.io/otel/trace v1.44.0/go.mod h1:oLl1jrMQAVo6v3GAggN+1VH9VIz9iUSvW53sW1Q8PIE=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
Expand Down
21 changes: 10 additions & 11 deletions pkg/cli/test_main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"os"
"path/filepath"
"testing"

"go.uber.org/goleak"
)

// TestMain provides setup and teardown for unit tests in the cli package
Expand All @@ -17,15 +19,12 @@ func TestMain(m *testing.M) {
panic("Failed to get current working directory: " + err.Error())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/codebase-design] Missing //go:build !integration build tag — pkg/console/test_main_test.go has it but pkg/cli/test_main_test.go does not. This means goleak runs during integration tests for pkg/cli but not for pkg/console, creating inconsistent leak coverage.

💡 Suggested fix

Add the build constraint at the top of pkg/cli/test_main_test.go to match pkg/console:

(go/redacted):build !integration

package cli

Or remove the tag from pkg/console/test_main_test.go if goleak should cover integration test runs in both packages.

@copilot please address this.

}

// Run all tests
code := m.Run()

// Clean up any action cache files created during tests
// Tests may create .github/aw/actions-lock.json in the pkg/cli directory
actionCacheDir := filepath.Join(wd, ".github")
if _, err := os.Stat(actionCacheDir); err == nil {
_ = os.RemoveAll(actionCacheDir)
}

os.Exit(code)
goleak.VerifyTestMain(m, goleak.Cleanup(func(_ int) {
// Clean up any action cache files created during tests
// Tests may create .github/aw/actions-lock.json in the pkg/cli directory
actionCacheDir := filepath.Join(wd, ".github")
if _, err := os.Stat(actionCacheDir); err == nil {
_ = os.RemoveAll(actionCacheDir)
}
}))
}
13 changes: 13 additions & 0 deletions pkg/console/test_main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//go:build !integration

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing !js && !wasm build constraints: goleak.VerifyTestMain is imported, but go.uber.org/goleak is not wasm/js-compatible. Other test files in this package (e.g., confirm_test.go, prompt_form_test.go) gate themselves with !js && !wasm, but this new TestMain does not—breaking compilation for those targets.

💡 Suggested fix

Change line 1 from:

(go/redacted):build !integration

to:

(go/redacted):build !integration && !js && !wasm

This matches the constraint pattern in the other wasm-incompatible test files in pkg/console.


package console

import (
"testing"

"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
}
Loading