Skip to content

Commit 7b2c80f

Browse files
tests(commands/mcms): isolate cobra command per parallel subtest (#734)
## What changed - Updated `TestSubcommands_HaveRequiredFlags` in `engine/cld/commands/mcms/command_test.go` so each parallel subtest creates its own command instance. - Removed the shared command instance that was previously reused across parallel subtests. ## Why Consistently failing for test due to race condition - https://github.com/smartcontractkit/chainlink-deployments-framework/actions/runs/22008698619/job/63598036705 ``` ================== ================== WARNING: DATA RACE Read at 0x00c000b65560 by goroutine 212: github.com/spf13/pflag.(*FlagSet).VisitAll() /home/runner/go/pkg/mod/github.com/spf13/pflag@v1.0.10/flag.go:305 +0x3a github.com/spf13/pflag.(*FlagSet).AddFlagSet() /home/runner/go/pkg/mod/github.com/spf13/pflag@v1.0.10/flag.go:915 +0x93 github.com/spf13/cobra.(*Command).mergePersistentFlags() /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.10.1/command.go:1900 +0x2f github.com/spf13/cobra.stripFlags() /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.10.1/command.go:678 +0x64 github.com/spf13/cobra.(*Command).Find.func1() ``` ``` ================== --- FAIL: TestSubcommands_HaveRequiredFlags (0.00s) --- FAIL: TestSubcommands_HaveRequiredFlags/analyze-proposal (0.00s) testing.go:1617: race detected during execution of test --- FAIL: TestSubcommands_HaveRequiredFlags/execute-fork (0.00s) testing.go:1617: race detected during execution of test --- FAIL: TestSubcommands_HaveRequiredFlags/error-decode-evm (0.00s) testing.go:1617: race detected during execution of test ```
1 parent f6d7d5c commit 7b2c80f

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

engine/cld/commands/mcms/command_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,6 @@ func TestNewCommand_InvalidConfigReturnsError(t *testing.T) {
126126
func TestSubcommands_HaveRequiredFlags(t *testing.T) {
127127
t.Parallel()
128128

129-
cmd, err := newTestCommand(t)
130-
require.NoError(t, err)
131-
132129
tests := []struct {
133130
subcommand string
134131
flags []string
@@ -155,6 +152,9 @@ func TestSubcommands_HaveRequiredFlags(t *testing.T) {
155152
t.Run(tt.subcommand, func(t *testing.T) {
156153
t.Parallel()
157154

155+
cmd, err := newTestCommand(t)
156+
require.NoError(t, err)
157+
158158
subCmd, _, err := cmd.Find([]string{tt.subcommand})
159159
require.NoError(t, err)
160160
require.Equal(t, tt.subcommand, subCmd.Use)

0 commit comments

Comments
 (0)