Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita7bc37e

Browse files
committed
fix: prevent data race
1 parent23356f6 commita7bc37e

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

‎cli/errors_test.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ type commandErrorCase struct {
2424
funcTestErrorExamples(t*testing.T) {
2525
t.Parallel()
2626

27-
varroot cli.RootCmd
28-
rootCmd,err:=root.Command(root.AGPL())
29-
require.NoError(t,err)
27+
rootCmd:=getRoot(t)
3028

3129
varcases []commandErrorCase
3230

@@ -52,8 +50,7 @@ ExtractCommandPathsLoop:
5250

5351
varoutBuf bytes.Buffer
5452

55-
rootCmd,err:=root.Command(root.AGPL())
56-
require.NoError(t,err)
53+
rootCmd:=getRoot(t)
5754

5855
inv,_:=clitest.NewWithCommand(t,rootCmd,tt.Cmd...)
5956
inv.Stderr=&outBuf
@@ -65,7 +62,7 @@ ExtractCommandPathsLoop:
6562
inv.Stdin=os.Stdin
6663
}
6764

68-
err=inv.Run()
65+
err:=inv.Run()
6966

7067
errFormatter:=cli.ExportNewPrettyErrorFormatter(&outBuf,false)
7168
cli.ExportFormat(errFormatter,err)
@@ -84,3 +81,14 @@ func extractCommandPaths(cmdPath []string, cmds []*serpent.Command) [][]string {
8481
}
8582
returncmdPaths
8683
}
84+
85+
// Must return a fresh instance of cmds each time.
86+
funcgetRoot(t*testing.T)*serpent.Command {
87+
t.Helper()
88+
89+
varroot cli.RootCmd
90+
rootCmd,err:=root.Command(root.AGPL())
91+
require.NoError(t,err)
92+
93+
returnrootCmd
94+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp